From f767190d4bc3aed7637d023c52afc3c78ca4cc07 Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Mon, 25 Mar 2024 12:47:55 +0700 Subject: [PATCH] contemporary --- conv/config_test.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/conv/config_test.go b/conv/config_test.go index 94e532a9d..9eab92b82 100644 --- a/conv/config_test.go +++ b/conv/config_test.go @@ -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://ade4d8bc8cbe014af6ebdf3cb7b1e9ad36f412c0@seeds.polkachu.com: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) }) }