-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
packet-forward-middleware packet memo, retry on timeout, and atomic f…
…orwards (#306) * Make examples its own module * Make cosmos specific module and run in CI in separate task * Update e2e test for memo refactor * Update test to chain-level params * Use gaia with pfm with configurable timeout and retries * Update SendIBCTransfer uses * fix interchain test * Add GetClients method to Relayer and helper for getting transfer channel between chains * Update packet forward test for multi-hop, add multi-hop refund test * Update tests for atomic forwards * Wait for a block after ack before checking balances * reduce wait to 1 block * Add multi-hop flow with refund through chain with native denom. Add assertions for escrow accounts * Remove stale comment * handle feedback * Add TransferOptions
- Loading branch information
Showing
19 changed files
with
900 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package cosmos_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" | ||
ibctest "github.com/strangelove-ventures/ibctest/v3" | ||
"github.com/strangelove-ventures/ibctest/v3/chain/cosmos" | ||
"github.com/strangelove-ventures/ibctest/v3/ibc" | ||
"github.com/strangelove-ventures/ibctest/v3/testreporter" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap/zaptest" | ||
) | ||
|
||
func TestUpdateLightClients(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("skipping in short mode") | ||
} | ||
|
||
t.Parallel() | ||
|
||
ctx := context.Background() | ||
|
||
// Chains | ||
cf := ibctest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*ibctest.ChainSpec{ | ||
{Name: "gaia", Version: gaiaVersion}, | ||
{Name: "osmosis", Version: osmosisVersion}, | ||
}) | ||
|
||
chains, err := cf.Chains(t.Name()) | ||
require.NoError(t, err) | ||
gaia, osmosis := chains[0], chains[1] | ||
|
||
// Relayer | ||
client, network := ibctest.DockerSetup(t) | ||
r := ibctest.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t)).Build( | ||
t, client, network) | ||
|
||
ic := ibctest.NewInterchain(). | ||
AddChain(gaia). | ||
AddChain(osmosis). | ||
AddRelayer(r, "relayer"). | ||
AddLink(ibctest.InterchainLink{ | ||
Chain1: gaia, | ||
Chain2: osmosis, | ||
Relayer: r, | ||
Path: "client-test-path", | ||
}) | ||
|
||
// Build interchain | ||
rep := testreporter.NewNopReporter() | ||
eRep := rep.RelayerExecReporter(t) | ||
require.NoError(t, ic.Build(ctx, eRep, ibctest.InterchainBuildOptions{ | ||
TestName: t.Name(), | ||
Client: client, | ||
NetworkID: network, | ||
})) | ||
t.Cleanup(func() { | ||
_ = ic.Close() | ||
}) | ||
|
||
require.NoError(t, r.StartRelayer(ctx, eRep)) | ||
t.Cleanup(func() { | ||
_ = r.StopRelayer(ctx, eRep) | ||
}) | ||
|
||
// Create and Fund User Wallets | ||
fundAmount := int64(10_000_000) | ||
users := ibctest.GetAndFundTestUsers(t, ctx, "default", fundAmount, gaia, osmosis) | ||
gaiaUser, osmoUser := users[0], users[1] | ||
|
||
// Get Channel ID | ||
gaiaChannelInfo, err := r.GetChannels(ctx, eRep, gaia.Config().ChainID) | ||
require.NoError(t, err) | ||
chanID := gaiaChannelInfo[0].ChannelID | ||
|
||
height, err := osmosis.Height(ctx) | ||
require.NoError(t, err) | ||
|
||
amountToSend := int64(553255) // Unique amount to make log searching easier. | ||
dstAddress := osmoUser.Bech32Address(osmosis.Config().Bech32Prefix) | ||
transfer := ibc.WalletAmount{ | ||
Address: dstAddress, | ||
Denom: gaia.Config().Denom, | ||
Amount: amountToSend, | ||
} | ||
tx, err := gaia.SendIBCTransfer(ctx, chanID, gaiaUser.KeyName, transfer, ibc.TransferOptions{}) | ||
require.NoError(t, err) | ||
require.NoError(t, tx.Validate()) | ||
|
||
chain := osmosis.(*cosmos.CosmosChain) | ||
reg := chain.Config().EncodingConfig.InterfaceRegistry | ||
msg, err := cosmos.PollForMessage[*clienttypes.MsgUpdateClient](ctx, chain, reg, height, height+10, nil) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, "07-tendermint-0", msg.ClientId) | ||
require.NotEmpty(t, msg.Signer) | ||
// TODO: Assert header information | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.