diff --git a/.github/workflows/e2e-wasm.yml b/.github/workflows/e2e-wasm.yml new file mode 100644 index 000000000..0daed2ce7 --- /dev/null +++ b/.github/workflows/e2e-wasm.yml @@ -0,0 +1,48 @@ +--- +name: CosmWasm e2e contract tests + +on: + # On normal PRs or when workflow goreleaser finishes, as it gets the last release tag. + pull_request: + +# Allow concurrent runs on main/release branches but isolates other branches +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }} + cancel-in-progress: ${{ ! (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) }} + +jobs: + get-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Download release + id: latest_release + uses: pozetroninc/github-action-get-latest-release@v0.7.0 + with: + repository: ${{ github.repository }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: download release + uses: robinraju/release-downloader@v1.8 + with: + # uses latest (including drafts) + # tag: ${{ steps.latest_release.outputs.release }} + # uses latest (excluding drafts) as tagged by GitHub + latest: true + fileName: "*linux_amd64.tar.gz" + + - name: unpack release + run: | + tar -xzf *linux_amd64.tar.gz + rm nibid*.gz + mv nibid* nibid || true + + - name: launch localnet + run: | + sh ./contrib/scripts/e2e/localnet.sh + + - name: run e2e tests + run: | + sh ./contrib/scripts/e2e/deploy-wasm.sh diff --git a/contrib/scripts/e2e/deploy-wasm.sh b/contrib/scripts/e2e/deploy-wasm.sh index ff67710fd..1daa51590 100644 --- a/contrib/scripts/e2e/deploy-wasm.sh +++ b/contrib/scripts/e2e/deploy-wasm.sh @@ -1,19 +1,25 @@ +#!/bin/bash +set -e + BINARY="./nibid" DENOM="unibi" CHAIN_ID="nibiru-localnet-0" -TXFLAG="--gas-prices 0.1$DENOM --gas auto --gas-adjustment 1.3 -y -b block --chain-id $CHAIN_ID" +TXFLAG="--gas-prices 0.1$DENOM --gas auto --gas-adjustment 1.3 -y -b async --chain-id $CHAIN_ID" # validator addr VALIDATOR_ADDR=$($BINARY keys show validator --address) echo "Validator address:" echo "$VALIDATOR_ADDR" -BALANCE_1=$($BINARY q bank balances $VALIDATOR_ADDR) +BALANCE_1=$($BINARY q bank balances "$VALIDATOR_ADDR") echo "Pre-store balance:" echo "$BALANCE_1" echo "TX Flags: $TXFLAG" -CONTRACT_CODE=$($BINARY tx wasm store "./contrib/scripts/e2e/contracts/cw_nameservice.wasm" --from validator $TXFLAG --output json | jq -r '.logs[0].events[-1].attributes[-1].value') +TX_HASH=$($BINARY tx wasm store "./contrib/scripts/e2e/contracts/cw_nameservice.wasm" --from validator $TXFLAG --output json | jq -r '.txhash' ) +sleep 3 + +CONTRACT_CODE=$($BINARY q tx $TX_HASH --output json | jq -r '.logs[0].events[-1].attributes[-1].value') echo "Stored: $CONTRACT_CODE" BALANCE_2=$($BINARY q bank balances $VALIDATOR_ADDR) @@ -22,6 +28,7 @@ echo "$BALANCE_2" INIT='{"purchase_price":{"amount":"100","denom":"unibi"},"transfer_price":{"amount":"999","denom":"unibi"}}' $BINARY tx wasm instantiate $CONTRACT_CODE "$INIT" --from validator $TXFLAG --label "awesome name service" --no-admin +sleep 3 CONTRACT_ADDRESS=$($BINARY query wasm list-contract-by-code $CONTRACT_CODE --output json | jq -r '.contracts[-1]') echo "Contract Address: $CONTRACT_ADDRESS" @@ -30,6 +37,7 @@ $BINARY query wasm contract $CONTRACT_ADDRESS # purchase a domain name $BINARY tx wasm execute $CONTRACT_ADDRESS '{"register":{"name":"uniques-domain"}}' --amount 100$DENOM --from validator $TXFLAG -y +sleep 3 # query registered name NAME_QUERY='{"resolve_record": {"name": "uniques-domain"}}' diff --git a/contrib/scripts/e2e/localnet.sh b/contrib/scripts/e2e/localnet.sh index 8dcd5a132..0fdb8ead0 100644 --- a/contrib/scripts/e2e/localnet.sh +++ b/contrib/scripts/e2e/localnet.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e # Console log text colour @@ -26,6 +26,7 @@ echo_error() { echo "${red}" echo "$1" echo "${reset}" + exit 1 } echo_success() { @@ -43,11 +44,6 @@ MNEMONIC="guard cream sadness conduct invite crumble clock pudding hole grit lia GENESIS_COINS="1000000000unibi,10000000000000unusd" CHAIN_DIR="$HOME/.nibid" -SEDOPTION="" -if [[ "$OSTYPE" == "darwin"* ]]; then - SEDOPTION="''" -fi - # Stop nibid if it is already running if pgrep -x "$BINARY" >/dev/null; then echo_error "Terminating $BINARY..." @@ -137,14 +133,14 @@ else fi echo_info "Adding gentx validator..." -if $BINARY gentx validator 900000000unibi --chain-id $CHAIN_ID; then +if $BINARY genesis gentx validator 900000000unibi --chain-id $CHAIN_ID; then echo_success "Successfully added gentx" else echo_error "Failed to add gentx" fi echo_info "Collecting gentx..." -if $BINARY collect-gentxs; then +if $BINARY genesis collect-gentxs; then echo_success "Successfully collected genesis txs into genesis.json" else echo_error "Failed to collect genesis txs"