Skip to content

Commit

Permalink
chore: replace gaia with chain
Browse files Browse the repository at this point in the history
  • Loading branch information
boojamya committed Oct 17, 2024
1 parent 6bcfcaa commit 4b1b5e8
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions interchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ func duplicateChainTest(t *testing.T, relayerImpl ibc.RelayerImplementation) {
chains, err := cf.Chains(t.Name())
require.NoError(t, err)

gaia0, gaia1 := chains[0], chains[1]
chain0, chain1 := chains[0], chains[1]

r := interchaintest.NewBuiltinRelayerFactory(relayerImpl, zaptest.NewLogger(t)).Build(
t, client, network,
)

ic := interchaintest.NewInterchain().
AddChain(gaia0).
AddChain(gaia1).
AddChain(chain0).
AddChain(chain1).
AddRelayer(r, "r").
AddLink(interchaintest.InterchainLink{
Chain1: gaia0,
Chain2: gaia1,
Chain1: chain0,
Chain2: chain1,
Relayer: r,
})

Expand Down Expand Up @@ -121,19 +121,19 @@ func getRelayerWalletsTest(t *testing.T, relayerImpl ibc.RelayerImplementation)
chains, err := cf.Chains(t.Name())
require.NoError(t, err)

gaia0, gaia1 := chains[0], chains[1]
chain0, chain1 := chains[0], chains[1]

r := interchaintest.NewBuiltinRelayerFactory(relayerImpl, zaptest.NewLogger(t)).Build(
t, client, network,
)

ic := interchaintest.NewInterchain().
AddChain(gaia0).
AddChain(gaia1).
AddChain(chain0).
AddChain(chain1).
AddRelayer(r, "r").
AddLink(interchaintest.InterchainLink{
Chain1: gaia0,
Chain2: gaia1,
Chain1: chain0,
Chain2: chain1,
Relayer: r,
})

Expand Down Expand Up @@ -199,9 +199,9 @@ func TestInterchain_CreateUser(t *testing.T) {
chains, err := cf.Chains(t.Name())
require.NoError(t, err)

gaia0 := chains[0]
chain0 := chains[0]

ic := interchaintest.NewInterchain().AddChain(gaia0)
ic := interchaintest.NewInterchain().AddChain(chain0)
defer ic.Close()

rep := testreporter.NewNopReporter()
Expand Down Expand Up @@ -235,26 +235,26 @@ func TestInterchain_CreateUser(t *testing.T) {
require.NoError(t, err)
require.NotEmpty(t, mnemonic)

user, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, keyName, mnemonic, initBal, gaia0)
user, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, keyName, mnemonic, initBal, chain0)
require.NoError(t, err)
require.NoError(t, testutil.WaitForBlocks(ctx, 2, gaia0))
require.NoError(t, testutil.WaitForBlocks(ctx, 2, chain0))
require.NotEmpty(t, user.Address())
require.NotEmpty(t, user.KeyName())

actualBalance, err := gaia0.GetBalance(ctx, user.FormattedAddress(), gaia0.Config().Denom)
actualBalance, err := chain0.GetBalance(ctx, user.FormattedAddress(), chain0.Config().Denom)
require.NoError(t, err)
require.True(t, actualBalance.Equal(initBal))
})

t.Run("without mnemonic", func(t *testing.T) {
keyName := "regular-user-name"
users := interchaintest.GetAndFundTestUsers(t, ctx, keyName, initBal, gaia0)
require.NoError(t, testutil.WaitForBlocks(ctx, 2, gaia0))
users := interchaintest.GetAndFundTestUsers(t, ctx, keyName, initBal, chain0)
require.NoError(t, testutil.WaitForBlocks(ctx, 2, chain0))
require.Len(t, users, 1)
require.NotEmpty(t, users[0].Address())
require.NotEmpty(t, users[0].KeyName())

actualBalance, err := gaia0.GetBalance(ctx, users[0].FormattedAddress(), gaia0.Config().Denom)
actualBalance, err := chain0.GetBalance(ctx, users[0].FormattedAddress(), chain0.Config().Denom)
require.NoError(t, err)
require.True(t, actualBalance.Equal(initBal))
})
Expand Down Expand Up @@ -377,20 +377,20 @@ func broadcastTxCosmosChainTest(t *testing.T, relayerImpl ibc.RelayerImplementat
chains, err := cf.Chains(t.Name())
require.NoError(t, err)

gaia0, gaia1 := chains[0], chains[1]
chain0, chain1 := chains[0], chains[1]

r := interchaintest.NewBuiltinRelayerFactory(relayerImpl, zaptest.NewLogger(t)).Build(
t, client, network,
)

pathName := "p"
ic := interchaintest.NewInterchain().
AddChain(gaia0).
AddChain(gaia1).
AddChain(chain0).
AddChain(chain1).
AddRelayer(r, "r").
AddLink(interchaintest.InterchainLink{
Chain1: gaia0,
Chain2: gaia1,
Chain1: chain0,
Chain2: chain1,
Relayer: r,
Path: pathName,
})
Expand All @@ -405,7 +405,7 @@ func broadcastTxCosmosChainTest(t *testing.T, relayerImpl ibc.RelayerImplementat
NetworkID: network,
}))

testUser := interchaintest.GetAndFundTestUsers(t, ctx, "gaia-user-1", math.NewInt(10_000_000), gaia0)[0]
testUser := interchaintest.GetAndFundTestUsers(t, ctx, "chain-user-1", math.NewInt(10_000_000), chain0)[0]

sendAmount := math.NewInt(10_000)

Expand All @@ -414,16 +414,16 @@ func broadcastTxCosmosChainTest(t *testing.T, relayerImpl ibc.RelayerImplementat
})

t.Run("broadcast success", func(t *testing.T) {
b := cosmos.NewBroadcaster(t, gaia0.(*cosmos.CosmosChain))
transferAmount := sdk.Coin{Denom: gaia0.Config().Denom, Amount: sendAmount}
b := cosmos.NewBroadcaster(t, chain0.(*cosmos.CosmosChain))
transferAmount := sdk.Coin{Denom: chain0.Config().Denom, Amount: sendAmount}
memo := ""

msg := transfertypes.NewMsgTransfer(
"transfer",
"channel-0",
transferAmount,
testUser.FormattedAddress(),
testUser.(*cosmos.CosmosWallet).FormattedAddressWithPrefix(gaia1.Config().Bech32Prefix),
testUser.(*cosmos.CosmosWallet).FormattedAddressWithPrefix(chain1.Config().Bech32Prefix),
clienttypes.NewHeight(1, 1000),
0,
memo,
Expand All @@ -434,12 +434,12 @@ func broadcastTxCosmosChainTest(t *testing.T, relayerImpl ibc.RelayerImplementat
})

t.Run("transfer success", func(t *testing.T) {
require.NoError(t, testutil.WaitForBlocks(ctx, 5, gaia0, gaia1))
require.NoError(t, testutil.WaitForBlocks(ctx, 5, chain0, chain1))

srcDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", gaia0.Config().Denom))
srcDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", chain0.Config().Denom))
dstIbcDenom := srcDenomTrace.IBCDenom()

dstFinalBalance, err := gaia1.GetBalance(ctx, testUser.(*cosmos.CosmosWallet).FormattedAddressWithPrefix(gaia1.Config().Bech32Prefix), dstIbcDenom)
dstFinalBalance, err := chain1.GetBalance(ctx, testUser.(*cosmos.CosmosWallet).FormattedAddressWithPrefix(chain1.Config().Bech32Prefix), dstIbcDenom)
require.NoError(t, err, "failed to get balance from dest chain")
require.True(t, dstFinalBalance.Equal(sendAmount))
})
Expand All @@ -462,10 +462,10 @@ func TestInterchain_OmitGitSHA(t *testing.T) {

chains, err := cf.Chains(t.Name())
require.NoError(t, err)
gaia := chains[0]
chain := chains[0]

ic := interchaintest.NewInterchain().
AddChain(gaia)
AddChain(chain)

rep := testreporter.NewNopReporter()
eRep := rep.RelayerExecReporter(t)
Expand Down

0 comments on commit 4b1b5e8

Please sign in to comment.