f273a440f0
Index provider integration uses a gossipsub topic to announce changes to the advertised content. The topic name was fixed to the default topic which is `/indexer/ingest/mainnet`. In the case of lotus, the gossipsub validators enforce a list of topics the instance is permitted to join by setting subscription filter option when `PubSub` instance is constructed via DI. Having the fixed topic name meant that any SP starting up a node on a network other than `mainnet` would have to override the default config to avoid the node crashing when index provider is enabled. Instead of a fixed default, the changes here infer the allowed indexer topic name from network name automatically if the topic configuration is left empty. Fixes #8510
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)
|
|
|
|
require.True(t, reflect.DeepEqual(c, c2))
|
|
}
|
|
|
|
func TestDefaultStorageMiner_IsEmpty(t *testing.T) {
|
|
subject := DefaultStorageMiner()
|
|
require.True(t, subject.IndexProvider.Enable)
|
|
require.Equal(t, "", subject.IndexProvider.TopicName)
|
|
}
|