e3deda0b2b
* remove client CLI * remove markets CLI from miner * remove markets from all CLI * remove client API * update go mod * remove EnableMarkets flag * remove market subsystem * remove dagstore * remove index provider * remove graphsync and data-transfer * remove markets * go mod tidy * fix cbor gen deps * remove deal making from config * remove eol alert * go mod tidy * changes as per review * make jen * changes as per review * merge master * remove libp2p from config * miner does not have libp2p conn in api test
82 lines
1.5 KiB
Go
82 lines
1.5 KiB
Go
// stm: #unit
|
|
package config
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"reflect"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/BurntSushi/toml"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDefaultFullNodeRoundtrip(t *testing.T) {
|
|
//stm: @OTHER_IMPLEMENTATION_001
|
|
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))
|
|
}
|
|
|
|
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))
|
|
}
|
|
|
|
func TestDefaultMinerRoundtrip(t *testing.T) {
|
|
//stm: @OTHER_IMPLEMENTATION_001
|
|
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)
|
|
|
|
// Differs between test envs
|
|
c.HarmonyDB = HarmonyDB{}
|
|
c2.(*StorageMiner).HarmonyDB = HarmonyDB{}
|
|
|
|
fmt.Println(c)
|
|
fmt.Println(c2)
|
|
require.True(t, reflect.DeepEqual(c, c2))
|
|
}
|