Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance testibc #610

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 38 additions & 9 deletions ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,44 @@ const IBC_TEST_CONTRACT = "./testdata/ibc_reflect.wasm"
func TestIBC(t *testing.T) {
vm := withVM(t)

wasm, err := os.ReadFile(IBC_TEST_CONTRACT)
require.NoError(t, err)

checksum, _, err := vm.StoreCode(wasm, TESTING_GAS_LIMIT)
require.NoError(t, err)

code, err := vm.GetCode(checksum)
require.NoError(t, err)
require.Equal(t, WasmCode(wasm), code)
t.Run("Store and retrieve IBC contract", func(t *testing.T) {
wasm, err := os.ReadFile(IBC_TEST_CONTRACT)
require.NoError(t, err)

checksum, _, err := vm.StoreCode(wasm, TESTING_GAS_LIMIT)
require.NoError(t, err)

code, err := vm.GetCode(checksum)
require.NoError(t, err)
require.Equal(t, WasmCode(wasm), code)
})

t.Run("Analyze stored IBC contract", func(t *testing.T) {
// Re-read the same wasm file and store it again, or retrieve the same checksum from above
wasm, err := os.ReadFile(IBC_TEST_CONTRACT)
require.NoError(t, err)

checksum, _, err := vm.StoreCode(wasm, TESTING_GAS_LIMIT)
require.NoError(t, err)

// Now run the analyzer
report, err := vm.AnalyzeCode(checksum)
require.NoError(t, err)

// We expect IBC entry points to be present in this contract
require.True(t, report.HasIBCEntryPoints, "IBC contract should have IBC entry points")

// You can also assert/update checks regarding capabilities or migration versions:
require.Contains(t, report.RequiredCapabilities, "iterator", "Expected 'iterator' capability for this contract")
require.Contains(t, report.RequiredCapabilities, "stargate", "Expected 'stargate' capability for this contract")

// Optionally check if the contract has a migrate version or not
if report.ContractMigrateVersion != nil {
t.Logf("Contract declares a migration version: %d", *report.ContractMigrateVersion)
} else {
t.Log("Contract does not declare a migration version")
}
})
}

// IBCInstantiateMsg is the Go version of
Expand Down
Loading