Skip to content

Commit

Permalink
imp(templates): removed 'GetModuleAddress' helper (#89)
Browse files Browse the repository at this point in the history
* imp(templates): removed 'GetModuleAddress' helper

* docs: added changelog
  • Loading branch information
srdtrk authored Jun 7, 2024
1 parent 6fcbfe2 commit 075a705
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [Unreleased]

- Removed `GetModuleAddress` helper function from the generated test suite [#88](https://github.com/srdtrk/go-codegen/issues/88)

## v0.2.4 (2024-06-07)

- Fixed the geenration of some incorrectly formated query responses [#79](https://github.com/srdtrk/go-codegen/pull/79)
Expand Down
21 changes: 0 additions & 21 deletions templates/interchaintestv8/e2esuite/files/e2esuite/utils.go.plush
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
Expand Down Expand Up @@ -54,26 +53,6 @@ func (s *TestSuite) BroadcastMessages(ctx context.Context, chain *cosmos.CosmosC
return &resp, nil
}

// GetModuleAddress returns the address of the given module on the given chain.
// Added because interchaintest's method doesn't work.
func (s *TestSuite) GetModuleAddress(ctx context.Context, chain *cosmos.CosmosChain, moduleName string) string {
modAccResp, err := GRPCQuery[authtypes.QueryModuleAccountByNameResponse](
ctx, chain, &authtypes.QueryModuleAccountByNameRequest{Name: moduleName},
)
s.Require().NoError(err)

cfg := chain.Config().EncodingConfig
var account sdk.AccountI
err = cfg.InterfaceRegistry.UnpackAny(modAccResp.Account, &account)
s.Require().NoError(err)

govAccount, ok := account.(authtypes.ModuleAccountI)
s.Require().True(ok)
s.Require().NotEmpty(govAccount.GetAddress().String())

return govAccount.GetAddress().String()
}

// fundAddress sends funds to the given address on the given chain
func (s *TestSuite) fundAddress(ctx context.Context, chain *cosmos.CosmosChain, keyName, address string) {
err := chain.SendFunds(ctx, keyName, ibc.WalletAmount{
Expand Down

0 comments on commit 075a705

Please sign in to comment.