From 21a603018536bc94507dc8ea69e80fe27f2c1980 Mon Sep 17 00:00:00 2001 From: Adam Hanna Date: Wed, 28 Aug 2024 13:16:11 -0400 Subject: [PATCH] fixes e2e (#2) `atone` bech32 prefix should be set also in the test setup. Co-authored-by: Thomas Bruyelle Co-authored-by: Adam Hanna --- cmd/atomoned/cmd/config.go | 30 ++++++++++++++++++++++++++++++ cmd/atomoned/cmd/root.go | 23 +---------------------- tests/e2e/e2e_distribution_test.go | 4 ++++ tests/e2e/e2e_setup_test.go | 15 +++++++++------ 4 files changed, 44 insertions(+), 28 deletions(-) create mode 100644 cmd/atomoned/cmd/config.go diff --git a/cmd/atomoned/cmd/config.go b/cmd/atomoned/cmd/config.go new file mode 100644 index 00000000..b309abbf --- /dev/null +++ b/cmd/atomoned/cmd/config.go @@ -0,0 +1,30 @@ +package cmd + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + Bech32PrefixAccAddr = "atone" +) + +var ( + // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key. + Bech32PrefixAccPub = Bech32PrefixAccAddr + "pub" + // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address. + Bech32PrefixValAddr = Bech32PrefixAccAddr + "valoper" + // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key. + Bech32PrefixValPub = Bech32PrefixAccAddr + "valoperpub" + // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address. + Bech32PrefixConsAddr = Bech32PrefixAccAddr + "valcons" + // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key. + Bech32PrefixConsPub = Bech32PrefixAccAddr + "valconspub" +) + +func InitSDKConfig() { + cfg := sdk.GetConfig() + cfg.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub) + cfg.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub) + cfg.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub) + cfg.Seal() +} diff --git a/cmd/atomoned/cmd/root.go b/cmd/atomoned/cmd/root.go index 2d940488..4301a4e6 100644 --- a/cmd/atomoned/cmd/root.go +++ b/cmd/atomoned/cmd/root.go @@ -123,29 +123,8 @@ func initAppConfig() (string, interface{}) { return defaultAppTemplate, customAppConfig } -const ( - Bech32PrefixAccAddr = "atone" -) - -var ( - // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key. - Bech32PrefixAccPub = Bech32PrefixAccAddr + "pub" - // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address. - Bech32PrefixValAddr = Bech32PrefixAccAddr + "valoper" - // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key. - Bech32PrefixValPub = Bech32PrefixAccAddr + "valoperpub" - // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address. - Bech32PrefixConsAddr = Bech32PrefixAccAddr + "valcons" - // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key. - Bech32PrefixConsPub = Bech32PrefixAccAddr + "valconspub" -) - func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { - cfg := sdk.GetConfig() - cfg.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub) - cfg.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub) - cfg.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub) - cfg.Seal() + InitSDKConfig() ac := appCreator{encodingConfig} diff --git a/tests/e2e/e2e_distribution_test.go b/tests/e2e/e2e_distribution_test.go index 5c5739d0..bbf56f19 100644 --- a/tests/e2e/e2e_distribution_test.go +++ b/tests/e2e/e2e_distribution_test.go @@ -5,6 +5,8 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" ) func (s *IntegrationTestSuite) testDistribution() { @@ -61,6 +63,8 @@ Test Benchmarks: 3. Verification that correct funds have been deposited to distribution module account */ func (s *IntegrationTestSuite) fundCommunityPool() { + distModuleAddress := authtypes.NewModuleAddress(distrtypes.ModuleName).String() + chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) sender, _ := s.chainA.validators[0].keyInfo.GetAddress() diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 8da315ab..9182a2a3 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -13,7 +13,9 @@ import ( "testing" "time" + "github.com/atomone-hub/atomone/cmd/atomoned/cmd" "github.com/ory/dockertest/v3" + // "github.com/cosmos/cosmos-sdk/crypto/hd" // "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/ory/dockertest/v3/docker" @@ -34,7 +36,6 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -74,11 +75,9 @@ var ( atomoneConfigPath = filepath.Join(atomoneHomePath, "config") stakingAmount = sdk.NewInt(100000000000) stakingAmountCoin = sdk.NewCoin(uatoneDenom, stakingAmount) - tokenAmount = sdk.NewCoin(uatoneDenom, sdk.NewInt(3300000000)) // 3,300uatone - standardFees = sdk.NewCoin(uatoneDenom, sdk.NewInt(330000)) // 0.33uatone - depositAmount = sdk.NewCoin(uatoneDenom, sdk.NewInt(330000000)) // 3,300uatone - distModuleAddress = authtypes.NewModuleAddress(distrtypes.ModuleName).String() - govModuleAddress = authtypes.NewModuleAddress(govtypes.ModuleName).String() + tokenAmount = sdk.NewCoin(uatoneDenom, sdk.NewInt(3300000000)) // 3,300uatom + standardFees = sdk.NewCoin(uatoneDenom, sdk.NewInt(330000)) // 0.33uatom + depositAmount = sdk.NewCoin(uatoneDenom, sdk.NewInt(330000000)) // 3,300uatom proposalCounter = 0 ) @@ -103,6 +102,8 @@ type AddressResponse struct { } func TestIntegrationTestSuite(t *testing.T) { + // Setup bech32 prefix + cmd.InitSDKConfig() suite.Run(t, new(IntegrationTestSuite)) } @@ -581,6 +582,8 @@ func noRestart(config *docker.HostConfig) { } func (s *IntegrationTestSuite) writeGovCommunitySpendProposal(c *chain, amount sdk.Coin, recipient string) { + govModuleAddress := authtypes.NewModuleAddress(govtypes.ModuleName).String() + template := ` { "messages":[