Skip to content

Commit

Permalink
wormchain: refresh interchaintest (#3991)
Browse files Browse the repository at this point in the history
* Add interchaintest tests to wormchain

* chore: refreshed icts

* chore: updated wasm binaries for ict

---------

Co-authored-by: Steve Miskovetz <steve.miskovetz@gmail.com>
  • Loading branch information
kakucodes and misko9 authored Jul 30, 2024
1 parent 1018463 commit 1c06d70
Show file tree
Hide file tree
Showing 33 changed files with 5,037 additions and 0 deletions.
59 changes: 59 additions & 0 deletions wormchain/interchaintest/cancel_upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package ictest

import (
"context"
"fmt"
"testing"
"time"

"github.com/strangelove-ventures/interchaintest/v4/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v4/testutil"
"github.com/stretchr/testify/require"

"github.com/wormhole-foundation/wormchain/interchaintest/guardians"
"github.com/wormhole-foundation/wormchain/interchaintest/helpers"
)

// TestCancelUpgrade will start on wormchain v2.18.1.1, schedule an upgrade to v2.23.0, cancel the upgrade,
// and verify that block production does not stop at the cancelled scheduled upgrade height.
func TestCancelUpgrade(t *testing.T) {
// Base setup
numVals := 2
guardians := guardians.CreateValSet(t, numVals)
chains := CreateChains(t, "v2.18.1.1", *guardians)
ctx, _, _, _ := BuildInterchain(t, chains)

// Chains
wormchain := chains[0].(*cosmos.CosmosChain)

// Set up upgrade
blocksAfterUpgrade := uint64(10)
height, err := wormchain.Height(ctx)
require.NoError(t, err, "error fetching height before upgrade")
fmt.Println("Height at sending schedule upgrade: ", height)

haltHeight := height + blocksAfterUpgrade
fmt.Println("Height for scheduled upgrade: ", haltHeight)

// Schedule upgrade
helpers.ScheduleUpgrade(t, ctx, wormchain, "faucet", "v2.23.0", haltHeight, guardians)

// Cancel upgrade
testutil.WaitForBlocks(ctx, 2, wormchain)
helpers.CancelUpgrade(t, ctx, wormchain, "faucet", guardians)

timeoutCtx3, timeoutCtxCancel3 := context.WithTimeout(ctx, time.Second*45)
defer timeoutCtxCancel3()

// Wait for chain to reach/exceed originally scheduled upgrade height
// If it times-out, the cancel upgrade did not work and the chain will have halted at the scheduled upgrade height
// If it does not timeout, it will be one block after the originally scheduled upgrade height
testutil.WaitForBlocks(timeoutCtx3, int(blocksAfterUpgrade), wormchain)

height, err = wormchain.Height(ctx)
require.NoError(t, err, "error fetching height after chain should have halted")

// Ensure that the chain continued making blocks passed the upgrade height
require.NotEqual(t, haltHeight, height, "height is equal to halt height, it shouldn't be")
fmt.Println("***** Cancel upgrade test passed ******")
}
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions wormchain/interchaintest/contracts/ibc_hooks/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib --features backtraces"
integration-test = "test --test integration"
Loading

0 comments on commit 1c06d70

Please sign in to comment.