forked from wormhole-foundation/wormhole
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wormchain: add ibc_receiver_test and ict workflow (wormhole-foundatio…
- Loading branch information
Showing
15 changed files
with
878 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Wormchain's end-to-end Interchain Tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
tags: | ||
- "**" | ||
branches: | ||
- "main" | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
env: | ||
GO_VERSION: 1.21 | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
e2e-tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# names of `make` commands to run tests | ||
test: | ||
- "ictest-cancel-upgrade" | ||
- "ictest-upgrade" | ||
- "ictest-wormchain" | ||
- "ictest-ibc-receiver" | ||
fail-fast: false | ||
|
||
steps: | ||
- name: Set up Go ${{ env.GO_VERSION }} | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
cache-dependency-path: interchaintest/go.sum | ||
|
||
- name: checkout chain | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run Test | ||
id: run_test | ||
continue-on-error: true | ||
working-directory: wormchain | ||
run: make ${{ matrix.test }} | ||
|
||
- name: Retry Failed Test | ||
if: steps.run_test.outcome == 'failure' | ||
working-directory: wormchain | ||
run: | | ||
for i in 1 2; do | ||
echo "Retry attempt $i" | ||
if make ${{ matrix.test }}; then | ||
echo "Test passed on retry" | ||
exit 0 | ||
fi | ||
done | ||
echo "Test failed after retries" | ||
exit 1 |
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
Binary file not shown.
Binary file not shown.
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,40 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/strangelove-ventures/interchaintest/v4/chain/cosmos" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// QueryContractInfo queries the information about a contract like the admin and code_id. | ||
func QueryContractInfo(t *testing.T, chain *cosmos.CosmosChain, ctx context.Context, contractAddress string) ContractInfoResponse { | ||
stdout, _, err := chain.GetFullNode().ExecQuery(ctx, | ||
"wasm", "contract", contractAddress, | ||
) | ||
require.NoError(t, err) | ||
|
||
res := new(ContractInfoResponse) | ||
err = json.Unmarshal(stdout, res) | ||
require.NoError(t, err) | ||
|
||
return *res | ||
} | ||
|
||
type ContractInfoResponse struct { | ||
Address string `json:"address"` | ||
ContractInfo struct { | ||
CodeID string `json:"code_id"` | ||
Creator string `json:"creator"` | ||
Admin string `json:"admin"` | ||
Label string `json:"label"` | ||
Created struct { | ||
BlockHeight string `json:"block_height"` | ||
TxIndex string `json:"tx_index"` | ||
} `json:"created"` | ||
IbcPortID string `json:"ibc_port_id"` | ||
Extension any `json:"extension"` | ||
} `json:"contract_info"` | ||
} |
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
61 changes: 61 additions & 0 deletions
61
wormchain/interchaintest/helpers/wormchain_ibc_receiver/helpers.go
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,61 @@ | ||
package wormchain_ibc_receiver | ||
|
||
import ( | ||
"encoding/base64" | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/wormhole-foundation/wormchain/interchaintest/guardians" | ||
"github.com/wormhole-foundation/wormchain/interchaintest/helpers" | ||
"github.com/wormhole-foundation/wormhole/sdk/vaa" | ||
) | ||
|
||
func SubmitIbcReceiverUpdateChannelChainMsg(t *testing.T, | ||
allowlistChainID vaa.ChainID, | ||
allowlistChannel string, | ||
guardians *guardians.ValSet) string { | ||
|
||
paddedChannel, _ := vaa.LeftPadIbcChannelId(allowlistChannel) | ||
|
||
bodyIbcReceiverUpdateChannelChain := vaa.BodyIbcUpdateChannelChain{ | ||
TargetChainId: vaa.ChainIDWormchain, | ||
ChannelId: paddedChannel, | ||
ChainId: allowlistChainID, | ||
} | ||
|
||
payload, err := bodyIbcReceiverUpdateChannelChain.Serialize(vaa.IbcReceiverModuleStr) | ||
require.NoError(t, err) | ||
|
||
v := helpers.GenerateGovernanceVaa(0, guardians, payload) | ||
vBz, err := v.Marshal() | ||
require.NoError(t, err) | ||
vHex := base64.StdEncoding.EncodeToString(vBz) | ||
|
||
var vaas [1]Binary | ||
vaas[0] = Binary(vHex) | ||
|
||
submitVAAMsg := ExecuteMsg{ | ||
SubmitUpdateChannelChain: &ExecuteMsg_SubmitUpdateChannelChain{ | ||
Vaas: vaas[:], | ||
}, | ||
} | ||
|
||
submitVAAMsgBz, err := json.Marshal(submitVAAMsg) | ||
require.NoError(t, err) | ||
|
||
return string(submitVAAMsgBz) | ||
} | ||
|
||
type ReceiverAck struct { | ||
Ok *struct{} `json:"ok,omitempty"` | ||
Error string `json:"error,omitempty"` | ||
} | ||
|
||
func (r ReceiverAck) IsOk() bool { | ||
return len(r.Error) == 0 | ||
} | ||
|
||
func (r ReceiverAck) IsError() bool { | ||
return len(r.Error) > 0 | ||
} |
Oops, something went wrong.