-
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.
feat: implement simapp and e2e tests (#2)
- Loading branch information
Showing
30 changed files
with
7,716 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,90 @@ | ||
name: End to End Tests | ||
|
||
on: | ||
pull_request: | ||
|
||
env: | ||
TAR_PATH: docker-image.tar | ||
ARTIFACT_NAME: tar-docker-image | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Build Docker Image | ||
uses: strangelove-ventures/[email protected] | ||
with: | ||
registry: "" # empty registry, image only shared for e2e testing | ||
tag: local # emulate local environment for consistency in interchaintest cases | ||
tar-export-path: ${{ env.TAR_PATH }} # export a tarball that can be uploaded as an artifact for the e2e jobs | ||
platform: linux/amd64 # test runner architecture only | ||
git-ref: ${{ github.head_ref }} # source code ref | ||
|
||
# Heighliner chains.yaml config | ||
chain: noble-authority-simd | ||
dockerfile: cosmos | ||
build-target: make build | ||
build-dir: simapp | ||
binaries: | | ||
- simapp/build/simd | ||
- name: Publish Tarball as Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.ARTIFACT_NAME }} | ||
path: ${{ env.TAR_PATH }} | ||
|
||
prepare: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '>=1.22' | ||
|
||
- name: Generate Matrix | ||
id: set-matrix | ||
run: | | ||
# Run the command and convert its output to a JSON array | ||
TESTS=$(cd e2e && go test -list . | grep -v "^ok " | jq -R -s -c 'split("\n")[:-1]') | ||
echo "matrix=${TESTS}" >> $GITHUB_OUTPUT | ||
test: | ||
needs: | ||
- build | ||
- prepare | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# names of `make` commands to run tests | ||
test: ${{fromJson(needs.prepare.outputs.matrix)}} | ||
fail-fast: false | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '>=1.22' | ||
|
||
- name: Download Tarball Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.ARTIFACT_NAME }} | ||
|
||
- name: Load Docker Image | ||
run: docker image load -i ${{ env.TAR_PATH }} | ||
|
||
- name: Run Tests | ||
run: cd e2e && go test -race -v -timeout 15m -run ^${{ matrix.test }}$ . |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.authority | ||
.idea | ||
build | ||
coverage.out |
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.
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,6 @@ | ||
- name: noble-authority-simd | ||
dockerfile: cosmos | ||
build-dir: simapp | ||
build-target: make build | ||
binaries: | ||
- simapp/build/simd |
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,26 @@ | ||
{ | ||
"body": { | ||
"messages": [ | ||
{ | ||
"@type": "/ibc.core.client.v1.MsgRecoverClient", | ||
"signer": "noble13am065qmk680w86wya4u9refhnssqwcvgs0sfk", | ||
"subject_client_id": "07-tendermint-0", | ||
"substitute_client_id": "07-tendermint-1" | ||
} | ||
], | ||
"memo": "", | ||
"timeout_height": "0", | ||
"extension_options": [], | ||
"non_critical_extension_options": [] | ||
}, | ||
"auth_info": { | ||
"signer_infos": [], | ||
"fee": { | ||
"amount": [], | ||
"gas_limit": "200000", | ||
"payer": "", | ||
"granter": "" | ||
} | ||
}, | ||
"signatures": [] | ||
} |
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,74 @@ | ||
package e2e | ||
|
||
import ( | ||
_ "embed" | ||
"path" | ||
"testing" | ||
|
||
"cosmossdk.io/math" | ||
|
||
"github.com/strangelove-ventures/interchaintest/v8" | ||
"github.com/strangelove-ventures/interchaintest/v8/ibc" | ||
"github.com/strangelove-ventures/interchaintest/v8/testutil" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
//go:embed clients.json | ||
var Clients []byte | ||
|
||
// TestClientSubstitution tests the module's ability to substitute IBC clients. | ||
func TestClientSubstitution(t *testing.T) { | ||
t.Parallel() | ||
|
||
var wrapper Wrapper | ||
ctx, reporter, rly := Suite(t, &wrapper, true) | ||
validator := wrapper.chain.Validators[0] | ||
|
||
nobleChainID, gaiaChainID := wrapper.chain.Config().ChainID, wrapper.gaia.Config().ChainID | ||
pathName := "transfer" | ||
|
||
err := rly.GeneratePath(ctx, reporter, nobleChainID, gaiaChainID, pathName) | ||
require.NoError(t, err) | ||
|
||
err = rly.CreateClient(ctx, reporter, nobleChainID, gaiaChainID, pathName, ibc.CreateClientOptions{ | ||
TrustingPeriod: "30s", | ||
}) | ||
require.NoError(t, err) | ||
err = rly.CreateClient(ctx, reporter, gaiaChainID, nobleChainID, pathName, ibc.CreateClientOptions{}) | ||
require.NoError(t, err) | ||
require.NoError(t, testutil.WaitForBlocks(ctx, 1, wrapper.chain, wrapper.gaia)) | ||
|
||
err = rly.CreateConnections(ctx, reporter, pathName) | ||
require.NoError(t, err) | ||
require.NoError(t, testutil.WaitForBlocks(ctx, 1, wrapper.chain, wrapper.gaia)) | ||
|
||
err = rly.CreateChannel(ctx, reporter, pathName, ibc.DefaultChannelOpts()) | ||
require.NoError(t, err) | ||
|
||
users := interchaintest.GetAndFundTestUsers(t, ctx, "user", math.NewInt(5_000_000), wrapper.chain, wrapper.gaia) | ||
require.NoError(t, testutil.WaitForBlocks(ctx, 10, wrapper.chain, wrapper.gaia)) | ||
|
||
_, err = validator.SendIBCTransfer(ctx, "channel-0", users[0].KeyName(), ibc.WalletAmount{ | ||
Address: users[1].FormattedAddress(), | ||
Denom: "uusdc", | ||
Amount: math.NewInt(1_000_000), | ||
}, ibc.TransferOptions{}) | ||
require.ErrorContains(t, err, "client state is not active") | ||
|
||
res := rly.Exec(ctx, reporter, []string{"rly", "tx", "client", nobleChainID, gaiaChainID, pathName, "--override", "--home", rly.HomeDir()}, nil) | ||
require.NoError(t, res.Err) | ||
|
||
require.NoError(t, validator.WriteFile(ctx, Clients, "clients.json")) | ||
_, err = validator.ExecTx( | ||
ctx, wrapper.owner.KeyName(), | ||
"authority", "execute", path.Join(validator.HomeDir(), "clients.json"), | ||
) | ||
require.NoError(t, err) | ||
|
||
_, err = validator.SendIBCTransfer(ctx, "channel-0", users[0].KeyName(), ibc.WalletAmount{ | ||
Address: users[1].FormattedAddress(), | ||
Denom: "uusdc", | ||
Amount: math.NewInt(1_000_000), | ||
}, ibc.TransferOptions{}) | ||
require.NoError(t, err) | ||
} |
Oops, something went wrong.