2020-08-12 17:55:43 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"reflect"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/BurntSushi/toml"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDefaultFullNodeRoundtrip(t *testing.T) {
|
|
|
|
c := DefaultFullNode()
|
|
|
|
|
|
|
|
var s string
|
|
|
|
{
|
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
_, _ = buf.WriteString("# Default config:\n")
|
|
|
|
e := toml.NewEncoder(buf)
|
|
|
|
require.NoError(t, e.Encode(c))
|
|
|
|
|
|
|
|
s = buf.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
c2, err := FromReader(strings.NewReader(s), DefaultFullNode())
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
fmt.Println(s)
|
|
|
|
|
|
|
|
require.True(t, reflect.DeepEqual(c, c2))
|
|
|
|
}
|
|
|
|
|
2022-03-10 10:58:31 +00:00
|
|
|
func TestDefaultFullNodeCommentRoundtrip(t *testing.T) {
|
|
|
|
c := DefaultFullNode()
|
|
|
|
|
|
|
|
var s string
|
|
|
|
{
|
|
|
|
c, err := ConfigComment(DefaultFullNode())
|
|
|
|
require.NoError(t, err)
|
|
|
|
s = string(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
c2, err := FromReader(strings.NewReader(s), DefaultFullNode())
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
fmt.Println(s)
|
|
|
|
|
|
|
|
require.True(t, reflect.DeepEqual(c, c2))
|
|
|
|
}
|
|
|
|
|
2020-08-12 17:55:43 +00:00
|
|
|
func TestDefaultMinerRoundtrip(t *testing.T) {
|
|
|
|
c := DefaultStorageMiner()
|
|
|
|
|
|
|
|
var s string
|
|
|
|
{
|
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
_, _ = buf.WriteString("# Default config:\n")
|
|
|
|
e := toml.NewEncoder(buf)
|
|
|
|
require.NoError(t, e.Encode(c))
|
|
|
|
|
|
|
|
s = buf.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
c2, err := FromReader(strings.NewReader(s), DefaultStorageMiner())
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
fmt.Println(s)
|
|
|
|
|
|
|
|
require.True(t, reflect.DeepEqual(c, c2))
|
|
|
|
}
|
2021-12-13 14:44:56 +00:00
|
|
|
|
|
|
|
func TestDefaultStorageMiner_SetsIndexIngestTopic(t *testing.T) {
|
|
|
|
subject := DefaultStorageMiner()
|
2022-03-02 13:49:00 +00:00
|
|
|
require.False(t, subject.IndexProvider.Enable)
|
|
|
|
require.Equal(t, "/indexer/ingest/mainnet", subject.IndexProvider.TopicName)
|
2021-12-13 14:44:56 +00:00
|
|
|
}
|