-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a72d84
commit f767190
Showing
1 changed file
with
17 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
}) | ||
} | ||
|