Skip to content

Commit

Permalink
updated tests and wasm bytecode
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslara committed Dec 5, 2024
1 parent 2c41b60 commit 187fa63
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
Binary file modified tests/ibc-hooks/bytecode/crosschain_registry.wasm
Binary file not shown.
Binary file modified tests/ibc-hooks/bytecode/crosschain_swaps.wasm
Binary file not shown.
Binary file modified tests/ibc-hooks/bytecode/outpost.wasm
Binary file not shown.
Binary file modified tests/ibc-hooks/bytecode/swaprouter.wasm
Binary file not shown.
31 changes: 30 additions & 1 deletion tests/ibc-hooks/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

abci "github.com/cometbft/cometbft/abci/types"

appparams "github.com/osmosis-labs/osmosis/v28/app/params"

"github.com/tidwall/gjson"
Expand Down Expand Up @@ -1004,7 +1005,7 @@ func (suite *HooksTestSuite) TestCrosschainRegistry() {

_, err := suite.chainA.GetOsmosisApp().WasmKeeper.QuerySmart(suite.chainA.GetContext(), registryAddr, []byte(channelQuery))
suite.Require().Error(err)
suite.Require().Contains(err.Error(), "RegistryValue not found")
suite.Require().Contains(err.Error(), "not found")

// Unwrap token0CB and check that the path has changed
channelQuery = `{"get_channel_from_chain_pair": {"source_chain": "osmosis", "destination_chain": "chainD"}}`
Expand Down Expand Up @@ -1766,6 +1767,34 @@ func (suite *HooksTestSuite) TestMultiHopXCS() {
requireAck: []bool{true},
},

{
name: "Swap tokenChain's native (in SwapperChain) for XCSChain's native, receive in SwapperChain",
sender: actorChainB, // SwapperChain
swapFor: "token0", // XCSChain's native token
receiver: actorChainB, // Back to SwapperChain
receivedToken: suite.GetIBCDenom(ChainA, ChainB, "token0"), // XCSChain's token0 as seen in SwapperChain
setupInitialToken: func() string {
// First, send tokenChain's native token to SwapperChain
suite.SimpleNativeTransfer("token0", osmomath.NewInt(12000000), []Chain{ChainC, ChainB})

// Setup pool on XCSChain (ChainA) between its native token0 and tokenChain's token
suite.SimpleNativeTransfer("token0", osmomath.NewInt(defaultPoolAmount), []Chain{ChainC, ChainA})
tokenCNative := suite.GetIBCDenom(ChainC, ChainA, "token0")
poolId := suite.CreateIBCNativePoolOnChain(ChainA, tokenCNative)
suite.SetupIBCRouteOnChain(swapRouterAddr, suite.chainA.SenderAccount.GetAddress(), poolId, ChainA, tokenCNative)

// Return the denom of tokenChain's token as seen in SwapperChain
return suite.GetIBCDenom(ChainC, ChainB, "token0")
},
// The packet flow:
// 1. B->A: Initial transfer with swap instructions
// 2. A->C: Unwrap tokenChain's token
// 3. C->A: Return unwrapped token
// 4. A->B: Send swapped tokens back to SwapperChain
relayChain: []Direction{AtoB, BtoC, CtoA, AtoB},
requireAck: []bool{false, false, true, true},
},

{
name: "Swap two IBC'd tokens",
sender: actorChainB,
Expand Down

0 comments on commit 187fa63

Please sign in to comment.