Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
69 lines
1.8 KiB
Go
69 lines
1.8 KiB
Go
package v1_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
v1 "github.com/ignite/cli/v29/ignite/config/chain/v1"
|
|
"github.com/ignite/cli/v29/ignite/pkg/xyaml"
|
|
)
|
|
|
|
func TestValidatorGetServers(t *testing.T) {
|
|
// Arrange
|
|
want := v1.DefaultServers()
|
|
want.RPC.Address = "127.0.0.0:1"
|
|
want.P2P.Address = "127.0.0.0:2"
|
|
want.GRPC.Address = "127.0.0.0:3"
|
|
want.GRPCWeb.Address = "127.0.0.0:4"
|
|
want.RPC.PProfAddress = "127.0.0.0:5"
|
|
want.API.Address = "127.0.0.0:6"
|
|
|
|
v := v1.Validator{
|
|
App: map[string]interface{}{
|
|
"grpc": map[string]interface{}{"address": want.GRPC.Address},
|
|
"grpc-web": map[string]interface{}{"address": want.GRPCWeb.Address},
|
|
"api": map[string]interface{}{"address": want.API.Address},
|
|
},
|
|
Config: map[string]interface{}{
|
|
"p2p": map[string]interface{}{"laddr": want.P2P.Address},
|
|
"rpc": map[string]interface{}{
|
|
"laddr": want.RPC.Address,
|
|
"pprof_laddr": want.RPC.PProfAddress,
|
|
},
|
|
},
|
|
}
|
|
|
|
// Act
|
|
s, err := v.GetServers()
|
|
|
|
// Assert
|
|
require.NoError(t, err)
|
|
require.Equal(t, want, s)
|
|
}
|
|
|
|
func TestValidatorSetServers(t *testing.T) {
|
|
// Arrange
|
|
v := v1.Validator{}
|
|
s := v1.DefaultServers()
|
|
wantApp := xyaml.Map{
|
|
"grpc": map[string]interface{}{"address": s.GRPC.Address},
|
|
"grpc-web": map[string]interface{}{"address": s.GRPCWeb.Address},
|
|
"api": map[string]interface{}{"address": s.API.Address},
|
|
}
|
|
wantConfig := xyaml.Map{
|
|
"p2p": map[string]interface{}{"laddr": s.P2P.Address},
|
|
"rpc": map[string]interface{}{
|
|
"laddr": s.RPC.Address,
|
|
"pprof_laddr": s.RPC.PProfAddress,
|
|
},
|
|
}
|
|
|
|
// Act
|
|
err := v.SetServers(s)
|
|
|
|
// Assert
|
|
require.NoError(t, err)
|
|
require.Equal(t, wantApp, v.App, "cosmos app config is not equal")
|
|
require.Equal(t, wantConfig, v.Config, "tendermint config is not equal")
|
|
}
|