Skip to content

Commit

Permalink
test: update e2e test cases to account for recent changes in intercha…
Browse files Browse the repository at this point in the history
…intest
  • Loading branch information
jtieri committed Nov 15, 2023
1 parent 52c6ee8 commit ba7e1d6
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 52 deletions.
28 changes: 20 additions & 8 deletions interchaintest/fee_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,23 @@ func TestRelayerFeeMiddleware(t *testing.T) {

// Get both chains
cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{Name: "juno", ChainName: "chaina", Version: "v13.0.0", NumValidators: &nv, NumFullNodes: &nf, ChainConfig: ibc.ChainConfig{ChainID: "chaina", GasPrices: "0.0ujuno"}},
{Name: "juno", ChainName: "chainb", Version: "v13.0.0", NumValidators: &nv, NumFullNodes: &nf, ChainConfig: ibc.ChainConfig{ChainID: "chainb", GasPrices: "0.0ujuno"}}},
)
{
Name: "juno",
ChainName: "chaina",
Version: "v13.0.0",
NumValidators: &nv,
NumFullNodes: &nf,
ChainConfig: ibc.ChainConfig{ChainID: "chaina", GasPrices: "0.0ujuno"},
},
{
Name: "juno",
ChainName: "chainb",
Version: "v13.0.0",
NumValidators: &nv,
NumFullNodes: &nf,
ChainConfig: ibc.ChainConfig{ChainID: "chainb", GasPrices: "0.0ujuno"},
},
})

chains, err := cf.Chains(t.Name())
require.NoError(t, err)
Expand Down Expand Up @@ -90,8 +104,8 @@ func TestRelayerFeeMiddleware(t *testing.T) {
channelA := chA[0]

// Fund a user account on chain1 and chain2
const userFunds = int64(1_000_000_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), userFunds, chainA, chainB)
initBal := sdkmath.NewInt(1_000_000_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), initBal, chainA, chainB)
userA := users[0]
userAddressA := userA.FormattedAddress()
userB := users[1]
Expand Down Expand Up @@ -128,8 +142,6 @@ func TestRelayerFeeMiddleware(t *testing.T) {
require.NoError(t, err)

// Get initial account balances
initBal := sdkmath.NewInt(userFunds)

userAOrigBal, err := chainA.GetBalance(ctx, userAddressA, chainA.Config().Denom)
require.NoError(t, err)
require.True(t, initBal.Equal(userAOrigBal))
Expand Down Expand Up @@ -177,7 +189,7 @@ func TestRelayerFeeMiddleware(t *testing.T) {
func() {
err := r.StopRelayer(ctx, eRep)
if err != nil {
t.Logf("an error occured while stopping the relayer: %s", err)
t.Logf("an error occurred while stopping the relayer: %s", err)
}
},
)
Expand Down
20 changes: 10 additions & 10 deletions interchaintest/feegrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,37 +161,37 @@ func TestRelayerFeeGrant(t *testing.T) {
osmosisChannel := gaiaChans[0].Counterparty

// Create and Fund User Wallets
fundAmount := int64(10_000_000)
fundAmount := sdkmath.NewInt(10_000_000)

// Tiny amount of funding, not enough to pay for a single TX fee (the GRANTER should be paying the fee)
granteeFundAmount := int64(10)
granteeFundAmount := sdkmath.NewInt(10)
granteeKeyPrefix := "grantee1"
grantee2KeyPrefix := "grantee2"
grantee3KeyPrefix := "grantee3"
granterKeyPrefix := "default"

mnemonicAny := genMnemonic(t)
gaiaGranterWallet, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, granterKeyPrefix, mnemonicAny, int64(fundAmount), gaia)
gaiaGranterWallet, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, granterKeyPrefix, mnemonicAny, fundAmount, gaia)
require.NoError(t, err)

mnemonicAny = genMnemonic(t)
gaiaGranteeWallet, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, granteeKeyPrefix, mnemonicAny, int64(granteeFundAmount), gaia)
gaiaGranteeWallet, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, granteeKeyPrefix, mnemonicAny, granteeFundAmount, gaia)
require.NoError(t, err)

mnemonicAny = genMnemonic(t)
gaiaGrantee2Wallet, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, grantee2KeyPrefix, mnemonicAny, int64(granteeFundAmount), gaia)
gaiaGrantee2Wallet, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, grantee2KeyPrefix, mnemonicAny, granteeFundAmount, gaia)
require.NoError(t, err)

mnemonicAny = genMnemonic(t)
gaiaGrantee3Wallet, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, grantee3KeyPrefix, mnemonicAny, int64(granteeFundAmount), gaia)
gaiaGrantee3Wallet, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, grantee3KeyPrefix, mnemonicAny, granteeFundAmount, gaia)
require.NoError(t, err)

mnemonicAny = genMnemonic(t)
osmosisUser, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, "recipient", mnemonicAny, int64(fundAmount), osmosis)
osmosisUser, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, "recipient", mnemonicAny, fundAmount, osmosis)
require.NoError(t, err)

mnemonicAny = genMnemonic(t)
gaiaUser, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, "recipient", mnemonicAny, int64(fundAmount), gaia)
gaiaUser, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, "recipient", mnemonicAny, fundAmount, gaia)
require.NoError(t, err)

mnemonic := gaiaGranterWallet.Mnemonic()
Expand Down Expand Up @@ -525,12 +525,12 @@ func TestRelayerFeeGrant(t *testing.T) {
// Test grantee still has exact amount expected
gaiaGranteeIBCBalance, err := gaia.GetBalance(ctx, gaiaGranteeAddr, gaia.Config().Denom)
require.NoError(t, err)
require.True(t, gaiaGranteeIBCBalance.Equal(sdkmath.NewInt(granteeFundAmount)))
require.True(t, gaiaGranteeIBCBalance.Equal(granteeFundAmount))

// Test granter has less than they started with, meaning fees came from their account
gaiaGranterIBCBalance, err := gaia.GetBalance(ctx, gaiaGranterAddr, gaia.Config().Denom)
require.NoError(t, err)
require.True(t, gaiaGranterIBCBalance.LT(sdkmath.NewInt(fundAmount)))
require.True(t, gaiaGranterIBCBalance.LT(fundAmount))
r.StopRelayer(ctx, eRep)
})
}
Expand Down
4 changes: 2 additions & 2 deletions interchaintest/ica_channel_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func TestScenarioICAChannelClose(t *testing.T) {
t.Parallel()

// Fund a user account on chain1 and chain2
const userFunds = int64(10_000_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), userFunds, chain1, chain2)
initBal := sdkmath.NewInt(10_000_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), initBal, chain1, chain2)
chain1User := users[0]
chain2User := users[1]

Expand Down
4 changes: 2 additions & 2 deletions interchaintest/interchain_accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func TestScenarioInterchainAccounts(t *testing.T) {
t.Parallel()

// Fund a user account on chain1 and chain2
const userFunds = int64(10_000_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), userFunds, chain1, chain2)
initBal := sdkmath.NewInt(10_000_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), initBal, chain1, chain2)
chain1User := users[0]
chain2User := users[1]

Expand Down
12 changes: 5 additions & 7 deletions interchaintest/localhost_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ func TestLocalhost_TokenTransfers(t *testing.T) {

// initialize a new acc for the relayer along with a couple user accs
initBal := sdkmath.NewInt(10_000_000)
_, err = interchaintest.GetAndFundTestUserWithMnemonic(ctx, relayerKey, mnemonic, initBal.Int64(), chainA)
_, err = interchaintest.GetAndFundTestUserWithMnemonic(ctx, relayerKey, mnemonic, initBal, chainA)
require.NoError(t, err)

users := interchaintest.GetAndFundTestUsers(t, ctx, "test-key", initBal.Int64(), chainA, chainA)
users := interchaintest.GetAndFundTestUsers(t, ctx, "test-key", initBal, chainA, chainA)
err = testutil.WaitForBlocks(ctx, 5, chainA)
require.NoError(t, err)

Expand Down Expand Up @@ -357,19 +357,17 @@ func TestLocalhost_InterchainAccounts(t *testing.T) {
)

// initialize a new acc for the relayer along with a new user acc
const initAmount = int64(10_000_000)
_, err = interchaintest.GetAndFundTestUserWithMnemonic(ctx, relayerKey, mnemonic, initAmount, chainA)
initBal := sdkmath.NewInt(10_000_000)
_, err = interchaintest.GetAndFundTestUserWithMnemonic(ctx, relayerKey, mnemonic, initBal, chainA)
require.NoError(t, err)

users := interchaintest.GetAndFundTestUsers(t, ctx, "test-key", initAmount, chainA)
users := interchaintest.GetAndFundTestUsers(t, ctx, "test-key", initBal, chainA)
userA := users[0]

err = testutil.WaitForBlocks(ctx, 5, chainA)
require.NoError(t, err)

// assert initial balance is correct
initBal := sdkmath.NewInt(initAmount)

userABal, err := chainA.GetBalance(ctx, userA.FormattedAddress(), chainA.Config().Denom)
require.NoError(t, err)
require.True(t, initBal.Equal(userABal))
Expand Down
4 changes: 3 additions & 1 deletion interchaintest/misbehaviour_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"
"time"

sdkmath "cosmossdk.io/math"
simappparams "cosmossdk.io/simapp/params"
"github.com/cometbft/cometbft/crypto/tmhash"
cometproto "github.com/cometbft/cometbft/proto/tendermint/types"
Expand Down Expand Up @@ -93,7 +94,8 @@ func TestRelayerMisbehaviourDetection(t *testing.T) {
})

// create a new user account and wait a few blocks for it to be created on chain
user := interchaintest.GetAndFundTestUsers(t, ctx, "user-1", 10_000_000, chainA)[0]
initBal := sdkmath.NewInt(10_000_000)
user := interchaintest.GetAndFundTestUsers(t, ctx, "user-1", initBal, chainA)[0]
err = testutil.WaitForBlocks(ctx, 5, chainA)
require.NoError(t, err)

Expand Down
8 changes: 4 additions & 4 deletions interchaintest/multi_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func TestMultipleChannelsOneConnection(t *testing.T) {
})

// Create user accounts on both chains
const initFunds = int64(10_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, "user-key", initFunds, gaia, osmosis)
initBal := sdkmath.NewInt(10_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, "user-key", initBal, gaia, osmosis)

gaiaUser, osmosisUser := users[0], users[1]

Expand Down Expand Up @@ -147,7 +147,7 @@ func TestMultipleChannelsOneConnection(t *testing.T) {
ibcDenoms[2] = transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(channels[2].Counterparty.PortID, channels[2].Counterparty.ChannelID, gaia.Config().Denom))

// Assert that the transfers are all successful out of the src chain account
expectedBal := sdkmath.NewInt(initFunds).Sub(transferAmount.MulRaw(3))
expectedBal := initBal.Sub(transferAmount.MulRaw(3))
nativeGaiaBal, err := gaia.GetBalance(ctx, gaiaUser.FormattedAddress(), gaia.Config().Denom)
require.NoError(t, err)
require.True(t, expectedBal.Equal(nativeGaiaBal))
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestMultipleChannelsOneConnection(t *testing.T) {
// Assert that the transfers are all successful back on the original src chain account
nativeGaiaBal, err = gaia.GetBalance(ctx, gaiaUser.FormattedAddress(), gaia.Config().Denom)
require.NoError(t, err)
require.True(t, nativeGaiaBal.Equal(sdkmath.NewInt(initFunds)))
require.True(t, nativeGaiaBal.Equal(initBal))

// Assert that the transfers are all successfully sent back to the original src chain account
for _, denom := range ibcDenoms {
Expand Down
8 changes: 4 additions & 4 deletions interchaintest/path_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ func TestScenarioPathFilterAllow(t *testing.T) {
})

// Create and Fund User Wallets
fundAmount := int64(10_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, "default", int64(fundAmount), gaia, osmosis)
initBal := sdkmath.NewInt(10_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, "default", initBal, gaia, osmosis)

gaiaUser, osmosisUser := users[0].(*cosmos.CosmosWallet), users[1].(*cosmos.CosmosWallet)

Expand Down Expand Up @@ -231,8 +231,8 @@ func TestScenarioPathFilterDeny(t *testing.T) {
})

// Create and Fund User Wallets
fundAmount := int64(10_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, "default", int64(fundAmount), gaia, osmosis)
initBal := sdkmath.NewInt(10_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, "default", initBal, gaia, osmosis)

gaiaUser, osmosisUser := users[0].(*cosmos.CosmosWallet), users[1].(*cosmos.CosmosWallet)

Expand Down
4 changes: 2 additions & 2 deletions interchaintest/relay_many_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ func TestRelayerMultiplePathsSingleProcess(t *testing.T) {
)

// Fund user accounts, so we can query balances and make assertions.
const userFunds = int64(10_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), userFunds, gaia, osmosis, juno)
initBal := sdkmath.NewInt(10_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), initBal, gaia, osmosis, juno)
gaiaUser, osmosisUser, junoUser := users[0].(*cosmos.CosmosWallet), users[1].(*cosmos.CosmosWallet), users[2].(*cosmos.CosmosWallet)

// Wait a few blocks for user accounts to be created on chain.
Expand Down
6 changes: 3 additions & 3 deletions interchaintest/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Relayer struct {
cancel context.CancelFunc
}

// Build returns a relayer interface
// NewRelayer returns a relayer interface
func NewRelayer(
t *testing.T,
config RelayerConfig,
Expand Down Expand Up @@ -63,7 +63,7 @@ func (r *Relayer) log() *zap.Logger {
return zaptest.NewLogger(r.t)
}

func (r *Relayer) AddChainConfiguration(ctx context.Context, _ ibc.RelayerExecReporter, chainConfig ibc.ChainConfig, keyName, rpcAddr, grpcAddr string) error {
func (r *Relayer) AddChainConfiguration(_ context.Context, _ ibc.RelayerExecReporter, chainConfig ibc.ChainConfig, keyName, rpcAddr, _ string) error {
sys := &relayertest.System{HomeDir: r.home}
sys.MustAddChain(r.t, chainConfig.ChainID, cmd.ProviderConfigWrapper{
Type: "cosmos",
Expand Down Expand Up @@ -300,7 +300,7 @@ func (r *Relayer) start(ctx context.Context, remainingArgs ...string) {

func (r *Relayer) UseDockerNetwork() bool { return false }

func (r *Relayer) Exec(ctx context.Context, _ ibc.RelayerExecReporter, cmd, env []string) ibc.RelayerExecResult {
func (r *Relayer) Exec(ctx context.Context, _ ibc.RelayerExecReporter, cmd, _ []string) ibc.RelayerExecResult {
// TODO: env would be ignored for now.
// We may want to modify the call to sys() to accept environment overrides,
// so this relayer can continue to be used in parallel without environment cross-contamination.
Expand Down
8 changes: 2 additions & 6 deletions interchaintest/relayer_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type RelayerFactory struct {
config RelayerConfig
}

// LocalRelayerConfig defines parameters for customizing a LocalRelayer.
// RelayerConfig defines parameters for customizing a LocalRelayer.
type RelayerConfig struct {
Processor string
Memo string
Expand All @@ -28,11 +28,7 @@ func NewRelayerFactory(config RelayerConfig) RelayerFactory {
}

// Build returns a relayer interface
func (rf RelayerFactory) Build(
t interchaintest.TestName,
cli *client.Client,
networkID string,
) ibc.Relayer {
func (rf RelayerFactory) Build(interchaintest.TestName, *client.Client, string) ibc.Relayer {
tst := &testing.T{}
return NewRelayer(tst, rf.config)
}
Expand Down
5 changes: 2 additions & 3 deletions interchaintest/stride/stride_icq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ func TestScenarioStrideICAandICQ(t *testing.T) {
logger.Info("TestScenarioStrideICAandICQ [1]")

// Fund user accounts, so we can query balances and make assertions.
const userFunds = int64(10_000_000_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), userFunds, stride, gaia)
initBal := sdkmath.NewInt(10_000_000_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), initBal, stride, gaia)
strideUser, gaiaUser := users[0], users[1]

strideFullNode := stride.Validators[0]
Expand Down Expand Up @@ -156,7 +156,6 @@ func TestScenarioStrideICAandICQ(t *testing.T) {

logger.Info("TestScenarioStrideICAandICQ [3]")

initBal := sdkmath.NewInt(userFunds)
err = stride.SendFunds(ctx, interchaintest.FaucetAccountKeyName, ibc.WalletAmount{
Address: strideAdminAddr,
Amount: initBal,
Expand Down

0 comments on commit ba7e1d6

Please sign in to comment.