Skip to content

Commit

Permalink
fixes e2e (#2)
Browse files Browse the repository at this point in the history
`atone` bech32 prefix should be set also in the test setup.

Co-authored-by: Thomas Bruyelle <[email protected]>
Co-authored-by: Adam Hanna <[email protected]>
  • Loading branch information
3 people authored Aug 28, 2024
1 parent f533d72 commit 21a6030
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 28 deletions.
30 changes: 30 additions & 0 deletions cmd/atomoned/cmd/config.go
Original file line number Diff line number Diff line change
@@ -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()
}
23 changes: 1 addition & 22 deletions cmd/atomoned/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/e2e_distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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()

Expand Down
15 changes: 9 additions & 6 deletions tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
)

Expand All @@ -103,6 +102,8 @@ type AddressResponse struct {
}

func TestIntegrationTestSuite(t *testing.T) {
// Setup bech32 prefix
cmd.InitSDKConfig()
suite.Run(t, new(IntegrationTestSuite))
}

Expand Down Expand Up @@ -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":[
Expand Down

0 comments on commit 21a6030

Please sign in to comment.