Skip to content

Commit

Permalink
test: bring back e2e wasm (#1781)
Browse files Browse the repository at this point in the history
* bring back e2e wasm

* Fix validator gentx command in localnet.sh script

This commit corrects the gentx command syntax within the localnet.sh script. The prefix "genesis" is added to the gentx command to ensure proper execution. This change addresses an issue where the script failed to add a gentx validator due to incorrect command usage.

* ```text
Fix gentx collection command in e2e localnet script

This commit updates the gentx collection command used in the
e2e localnet setup script. The binary invocation is changed from
$BINARY collect-gentxs to $BINARY genesis collect-gentxs, aligning
with the correct usage for collecting genesis transactions. This change
ensures successful preparation of genesis.json with the collected
transactions during environment setup.
```

* `Enhance error handling and correct gentx command in localnet setup script`

* `Change shebang from sh to bash in localnet.sh for better compatibility`

* Remove macOS specific sed option handling from localnet script

```plaintext
This commit removes the conditional handling for the `sed` command specific to macOS within the `localnet.sh` script. This change simplifies the script by eliminating the previously necessary `SEDOPTION` variable configuration based on the operating system type.
```

* Update localnet.sh to use genesis command for gentx validator

This commit modifies the localnet.sh script to correctly invoke the genesis command for generating a gentx for the validator. This adjustment ensures the script aligns with the required command structure, potentially addressing issues related to gentx creation failures.

- Update gentx command syntax to include 'genesis'
- Confirm success or failure of gentx addition with appropriate messaging

* Update `deploy-wasm.sh` to use async broadcast mode for transactions

* Add shebang and error handling to deploy-wasm.sh script

* Add deploy wasm debug code for getting the tx.

* Remove quotes on params variable

* Add query tx.

* Fixed typo in deploy-wasm.sh script for storing wasm contracts

* Add jq after query hash tx.

* Add option to get the contract code number.

* Get contract code from transaction response.

* Extract hash from instantiate tx.

* add another sleep when registering the domain
  • Loading branch information
jgimeno authored Jan 29, 2024
1 parent 77caa49 commit 2ee5c9f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 11 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/e2e-wasm.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 11 additions & 3 deletions contrib/scripts/e2e/deploy-wasm.sh
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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"
Expand All @@ -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"}}'
Expand Down
12 changes: 4 additions & 8 deletions contrib/scripts/e2e/localnet.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e

# Console log text colour
Expand Down Expand Up @@ -26,6 +26,7 @@ echo_error() {
echo "${red}"
echo "$1"
echo "${reset}"
exit 1
}

echo_success() {
Expand All @@ -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..."
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 2ee5c9f

Please sign in to comment.