Skip to content

Commit

Permalink
contemporary
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdv2429 committed Mar 25, 2024
1 parent 1a72d84 commit f767190
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions conv/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,33 @@ func TestGetNodeConfig(t *testing.T) {

validCosmos := "127.0.0.1:1234"
validDymint := "/ip4/127.0.0.1/tcp/1234"
validSeed := "https://[email protected]:20556"

cases := []struct {
name string
input *tmcfg.Config
expected config.NodeConfig
name string
input *tmcfg.Config
expected config.NodeConfig
expectError bool
}{
{"empty", nil, config.NodeConfig{}},
{"Seeds", &tmcfg.Config{P2P: &tmcfg.P2PConfig{Seeds: "seeds"}}, config.NodeConfig{P2P: config.P2PConfig{Seeds: "seeds"}}},
{"empty", nil, config.NodeConfig{}, true},
// TODO: get a valid seed and replace its value
{"Seeds", &tmcfg.Config{P2P: &tmcfg.P2PConfig{Seeds: validSeed}}, config.NodeConfig{P2P: config.P2PConfig{Seeds: validSeed}}, true},
//GetNodeConfig translates the listen address, so we expect the translated address
{"ListenAddress", &tmcfg.Config{P2P: &tmcfg.P2PConfig{ListenAddress: validCosmos}}, config.NodeConfig{P2P: config.P2PConfig{ListenAddress: validDymint}}},
{"RootDir", &tmcfg.Config{BaseConfig: tmcfg.BaseConfig{RootDir: "~/root"}}, config.NodeConfig{RootDir: "~/root"}},
{"DBPath", &tmcfg.Config{BaseConfig: tmcfg.BaseConfig{DBPath: "./database"}}, config.NodeConfig{DBPath: "./database"}},
{"ListenAddress", &tmcfg.Config{P2P: &tmcfg.P2PConfig{ListenAddress: validCosmos}}, config.NodeConfig{P2P: config.P2PConfig{ListenAddress: validDymint}}, false},
{"RootDir", &tmcfg.Config{BaseConfig: tmcfg.BaseConfig{RootDir: "~/root"}}, config.NodeConfig{RootDir: "~/root"}, false},
{"DBPath", &tmcfg.Config{BaseConfig: tmcfg.BaseConfig{DBPath: "./database"}}, config.NodeConfig{DBPath: "./database"}, false},
}

for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
var actual config.NodeConfig
err := GetNodeConfig(&actual, c.input)
assert.NoError(t, err)
if c.expectError {
assert.Error(t, err)
} else {
assert.NoError(t, err)
assert.Equal(t, c.expected, actual)
}
assert.Equal(t, c.expected, actual)
})
}
Expand Down

0 comments on commit f767190

Please sign in to comment.