Skip to content

Commit

Permalink
test: ibc hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
duvbell committed Jan 5, 2024
1 parent 91895ac commit df50119
Show file tree
Hide file tree
Showing 16 changed files with 833 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ test-alliance:
./scripts/tests/alliance/delegate.sh


test-ibc-hooks:
@echo "Testing ibc-hooks..."
./scripts/tests/ibc-hooks/increment.sh

clean-testing-data:
@echo "Killing migallod and removing previous data"
-@pkill $(BINARY) 2>/dev/null
Expand Down
13 changes: 7 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package app
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"sort"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -42,11 +48,6 @@ import (
solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
icq "github.com/strangelove-ventures/async-icq/v7"
"io"
"net/http"
"os"
"path/filepath"
"sort"

distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
Expand Down Expand Up @@ -651,7 +652,7 @@ func NewMigalooApp(
transferStack = router.NewIBCMiddleware(
transferStack,
&app.RouterKeeper,
0,
5,
routerkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
routerkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)
Expand Down
43 changes: 43 additions & 0 deletions scripts/tests/ibc-hooks/counter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[package]
name = "counter"
description = "Cosmwasm counter dapp, with permissions for testing Osmosis wasmhooks"
version = "0.1.0"
authors = ["osmosis contributors"]
edition = "2021"

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.6
"""

[dependencies]
cosmwasm-schema = "1.1.3"
cosmwasm-std = "1.1.3"
cosmwasm-storage = "1.1.3"
cw-storage-plus = "0.16.0"
cw2 = "0.16.0"
schemars = "0.8.10"
serde = { version = "1.0.145", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.31" }

[dev-dependencies]
cw-multi-test = "0.16.0"
11 changes: 11 additions & 0 deletions scripts/tests/ibc-hooks/counter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Counter contract from [Osmosis Labs](https://github.com/osmosis-labs/osmosis/commit/64393a14e18b2562d72a3892eec716197a3716c7)

This contract is a modification of the standard cosmwasm `counter` contract.
Namely, it tracks a counter, _by sender_.
This is a better way to test wasmhooks.

This contract tracks any funds sent to it by adding it to the state under the `sender` key.

This way we can verify that, independently of the sender, the funds will end up under the
`WasmHooksModuleAccount` address when the contract is executed via an IBC send that goes
through the wasmhooks module.
1 change: 1 addition & 0 deletions scripts/tests/ibc-hooks/counter/artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c0e7a3b40d9710f6f72322293ba5cd871714008d9accd9a91c0fb08272609054 counter.wasm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bffb3256d4fd5668e497ae5671844ef3dcdf1a5f2594747b894dfc02e243ab0e ./target/wasm32-unknown-unknown/release/counter.wasm
Binary file not shown.
Loading

0 comments on commit df50119

Please sign in to comment.