-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "remove duplicated bash tests and added teardown for localnet …
…tests." This reverts commit 4067411.
- Loading branch information
Showing
4 changed files
with
276 additions
and
2 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
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,119 @@ | ||
#!/usr/bin/env bash | ||
|
||
source "./shared.sh" | ||
|
||
testTrivialCommands() { | ||
echo "testTrivialCommands" | ||
${CLI} contract templates | ||
} | ||
|
||
testCreateContracts() { | ||
echo "testCreateContracts" | ||
${CLI} contract new --template adder --path ${SANDBOX} || return 1 | ||
${CLI} contract new --template crypto-zombies --path ${SANDBOX} || return 1 | ||
${CLI} contract new --template empty --path ${SANDBOX} || return 1 | ||
} | ||
|
||
testBuildContracts() { | ||
echo "testBuildContracts" | ||
|
||
# Improve compilation time by reusing build artifacts for Rust projects | ||
export TARGET_DIR=$(pwd)/${SANDBOX}/TARGET | ||
mkdir -p ${TARGET_DIR} | ||
|
||
${CLI} contract build --path=${SANDBOX}/adder --target-dir=${TARGET_DIR} || return 1 | ||
assertFileExists ${SANDBOX}/adder/output/adder.wasm || return 1 | ||
assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 | ||
|
||
${CLI} contract build --path=${SANDBOX}/crypto-zombies --target-dir=${TARGET_DIR} || return 1 | ||
assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 | ||
assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 | ||
|
||
${CLI} contract build --path=${SANDBOX}/empty --target-dir=${TARGET_DIR} || return 1 | ||
assertFileExists ${SANDBOX}/empty/output/empty.wasm || return 1 | ||
assertFileExists ${SANDBOX}/empty/output/empty.abi.json || return 1 | ||
} | ||
|
||
testRunScenarios() { | ||
echo "testRunScenarios" | ||
${CLI} --verbose contract test --path=${SANDBOX}/adder || return 1 | ||
${CLI} --verbose contract test --path=${SANDBOX}/empty || return 1 | ||
} | ||
|
||
testWasmName() { | ||
echo "testWasmName" | ||
|
||
${CLI} contract clean --path ${SANDBOX}/adder | ||
assertFileDoesNotExist ${SANDBOX}/adder/output/adder-2.wasm || return 1 | ||
${CLI} contract build --path=${SANDBOX}/adder --target-dir=${TARGET_DIR} --wasm-name adder-2 || return 1 | ||
assertFileExists ${SANDBOX}/adder/output/adder-2.wasm || return 1 | ||
assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 | ||
} | ||
|
||
testCleanContracts() { | ||
echo "testCleanContracts" | ||
|
||
assertFileExists ${SANDBOX}/adder/output/adder.wasm || return 1 | ||
assertFileExists ${SANDBOX}/adder/output/adder.abi.json || return 1 | ||
${CLI} contract clean --path ${SANDBOX}/adder || return 1 | ||
assertFileDoesNotExist ${SANDBOX}/adder/output/adder.wasm || return 1 | ||
assertFileDoesNotExist ${SANDBOX}/adder/output/adder.abi.json || return 1 | ||
|
||
assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 | ||
assertFileExists ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 | ||
${CLI} contract clean --path ${SANDBOX}/crypto-zombies || return 1 | ||
assertFileDoesNotExist ${SANDBOX}/crypto-zombies/output/crypto-zombies.wasm || return 1 | ||
assertFileDoesNotExist ${SANDBOX}/crypto-zombies/output/crypto-zombies.abi.json || return 1 | ||
|
||
assertFileExists ${SANDBOX}/empty/output/empty.wasm || return 1 | ||
assertFileExists ${SANDBOX}/empty/output/empty.abi.json || return 1 | ||
${CLI} contract clean --path ${SANDBOX}/empty || return 1 | ||
assertFileDoesNotExist ${SANDBOX}/empty/output/empty.wasm || return 1 | ||
assertFileDoesNotExist ${SANDBOX}/empty/output/empty.abi.json || return 1 | ||
} | ||
|
||
testVerifyContract(){ | ||
echo "testVerifyContract" | ||
|
||
nohup python3 local_verify_server.py >/dev/null 2>&1 & | ||
sleep 1 | ||
|
||
query_response=$(curl -s localhost:7777/verify -X POST) | ||
|
||
command_response=$(${CLI} contract verify erd1qqqqqqqqqqqqqpgquzmh78klkqwt0p4rjys0qtp3la07gz4d396qn50nnm \ | ||
--verifier-url=http://localhost:7777 --packaged-src=testdata/dummy.json \ | ||
--pem=testdata/walletKey.pem --docker-image=multiversx/sdk-rust-contract-builder:v4.0.0) | ||
|
||
result_curl=$(echo $query_response | awk -F ": " '{ print $2 }' | awk -F'"' '{print $2}') | ||
result_cli=$(echo $command_response | awk -F ": " '{ print $2 }' | awk -F'"' '{print $2}') | ||
|
||
if [[ $result_curl == $result_cli ]]; | ||
then | ||
echo "Test passed!" | ||
else | ||
return 1 | ||
fi | ||
|
||
pkill -f local_verify_server.py | ||
} | ||
|
||
testReproducibleBuild() { | ||
echo "testReproducibleBuild" | ||
|
||
wget -O ${SANDBOX}/example.zip https://github.com/multiversx/mx-reproducible-contract-build-example-sc/archive/refs/tags/v0.2.1.zip || return 1 | ||
unzip ${SANDBOX}/example.zip -d ${SANDBOX} || return 1 | ||
${CLI} contract reproducible-build ${SANDBOX}/mx-reproducible-contract-build-example-sc-0.2.1 --docker-image=multiversx/sdk-rust-contract-builder:v4.1.2 --no-docker-interactive --no-docker-tty || return 1 | ||
assertFileExists ${SANDBOX}/mx-reproducible-contract-build-example-sc-0.2.1/output-docker/artifacts.json || return 1 | ||
} | ||
|
||
testAll() { | ||
${CLI} config set dependencies.rust.tag ${RUST_VERSION} | ||
|
||
cleanSandbox || return 1 | ||
testTrivialCommands || return 1 | ||
testCreateContracts || return 1 | ||
testBuildContracts || return 1 | ||
testRunScenarios || return 1 | ||
testCleanContracts || return 1 | ||
testWasmName || return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/usr/bin/env bash | ||
|
||
source "./shared.sh" | ||
|
||
REGISTRATION_COST=100 | ||
|
||
testOnline() { | ||
testRegistrationOnline || return 1 | ||
# Wait for nonces to be incremented (at source shards) | ||
sleep 15 | ||
testTransactionsWithUsernamesOnline || return 1 | ||
} | ||
|
||
testRegistrationOnline() { | ||
${CLI} --verbose dns register --name="testuser" --pem=${TestUser} --value=${REGISTRATION_COST} \ | ||
--recall-nonce --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txRegisterUser.txt --send --proxy=${PROXY} || return 1 | ||
|
||
${CLI} --verbose dns register --name="testuser2" --pem=${TestUser2} --value=${REGISTRATION_COST} \ | ||
--recall-nonce --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txRegisterUser2.txt --send --proxy=${PROXY} || return 1 | ||
} | ||
|
||
testTransactionsWithUsernamesOnline() { | ||
${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} \ | ||
--value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txA.txt --send --proxy=${PROXY} || return 1 | ||
|
||
sleep 10 | ||
|
||
${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} --receiver-username="testuser2" \ | ||
--value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txB.txt --send --proxy=${PROXY} || return 1 | ||
|
||
sleep 10 | ||
|
||
${CLI} --verbose tx new --pem=${TestUser} --receiver=${TestUser2} --receiver-username="testuser2foo" \ | ||
--value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txC.txt --send --proxy=${PROXY} || return 1 | ||
|
||
sleep 10 | ||
|
||
${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver=${TestUser2} --receiver-username="testuser2" \ | ||
--value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txD.txt --send --proxy=${PROXY} || return 1 | ||
|
||
sleep 10 | ||
|
||
${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver=${TestUser2} \ | ||
--value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txF.txt --send --proxy=${PROXY} || return 1 | ||
|
||
sleep 10 | ||
|
||
${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuserfoo" --receiver=${TestUser2} \ | ||
--value="1${DENOMINATION}" --recall-nonce --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txG.txt --send --proxy=${PROXY} || return 1 | ||
} | ||
|
||
|
||
testOffline() { | ||
testRegistrationOffline || return 1 | ||
testTransactionsWithUsernamesOffline || return 1 | ||
} | ||
|
||
testRegistrationOffline() { | ||
${CLI} --verbose dns register --name="testuser" --pem=${TestUser} --value=${REGISTRATION_COST} \ | ||
--nonce=7 --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txRegisterUser.txt || return 1 | ||
assertFileExists ${SANDBOX}/txRegisterUser.txt || return 1 | ||
|
||
${CLI} --verbose dns register --name="testuser2" --pem=${TestUser2} --value=${REGISTRATION_COST} \ | ||
--nonce=8 --gas-limit=100000000 --gas-price=1000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txRegisterUser2.txt || return 1 | ||
assertFileExists ${SANDBOX}/txRegisterUser2.txt || return 1 | ||
} | ||
|
||
testTransactionsWithUsernamesOffline() { | ||
${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ | ||
--value="1${DENOMINATION}" --nonce=42 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txA.txt || return 1 | ||
assertFileExists ${SANDBOX}/txA.txt || return 1 | ||
|
||
${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2" \ | ||
--value="1${DENOMINATION}" --nonce=43 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txB.txt || return 1 | ||
assertFileExists ${SANDBOX}/txB.txt || return 1 | ||
|
||
${CLI} --verbose tx new --pem=${TestUser} --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2foo" \ | ||
--value="1${DENOMINATION}" --nonce=44 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txC.txt || return 1 | ||
assertFileExists ${SANDBOX}/txC.txt || return 1 | ||
|
||
${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" --receiver-username="testuser2" \ | ||
--value="1${DENOMINATION}" --nonce=45 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txD.txt || return 1 | ||
assertFileExists ${SANDBOX}/txD.txt || return 1 | ||
|
||
${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuser" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ | ||
--value="1${DENOMINATION}" --nonce=46 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txF.txt || return 1 | ||
assertFileExists ${SANDBOX}/txF.txt || return 1 | ||
|
||
${CLI} --verbose tx new --pem=${TestUser} --sender-username="testuserfoo" --receiver="erd1ssmsc9022udc8pdw7wk3hxw74jr900xg28vwpz3z60gep66fasasl2nkm4" \ | ||
--value="1${DENOMINATION}" --nonce=47 --gas-limit=50000 --gas-price=2000000000 --chain=${CHAIN_ID} \ | ||
--outfile=${SANDBOX}/txG.txt || return 1 | ||
assertFileExists ${SANDBOX}/txG.txt || return 1 | ||
} | ||
|
||
testAll() { | ||
testOnline || return 1 | ||
testOffline || return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
source "./shared.sh" | ||
|
||
testAll() { | ||
BLS_KEY="e7beaa95b3877f47348df4dd1cb578a4f7cabf7a20bfeefe5cdd263878ff132b765e04fef6f40c93512b666c47ed7719b8902f6c922c04247989b7137e837cc81a62e54712471c97a2ddab75aa9c2f58f813ed4c0fa722bde0ab718bff382208" | ||
REWARD_ADDRESS="erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" | ||
|
||
echo "Stake with recall nonce" | ||
${CLI} --verbose validator stake --pem="${USERS}/alice.pem" --value="2500${DENOMINATION}" --validators-file=./testdata/validators.json --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
echo "Stake with provided nonce" | ||
${CLI} --verbose validator stake --pem="${USERS}/bob.pem" --value="2500${DENOMINATION}" --validators-file=./testdata/validators.json --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --nonce=300 || return 1 | ||
|
||
|
||
echo "Stake with topUP" | ||
${CLI} --verbose validator stake --top-up --pem="${USERS}/carol.pem" --value="2711${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
|
||
echo "Unstake" | ||
${CLI} --verbose validator unstake --pem="${USERS}/dan.pem" --nodes-public-keys="${BLS_KEY}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
echo "Unbond" | ||
${CLI} --verbose validator unbond --pem="${USERS}/eve.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
echo "Unjail" | ||
${CLI} --verbose validator unjail --pem="${USERS}/frank.pem" --value="2500${DENOMINATION}" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
echo "Change reward address" | ||
${CLI} --verbose validator change-reward-address --pem="${USERS}/grace.pem" --reward-address=${REWARD_ADDRESS} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
|
||
echo "UnstakeNodes" | ||
${CLI} --verbose validator unstake-nodes --pem="${USERS}/heidi.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
|
||
echo "UnstakeTokens" | ||
${CLI} --verbose validator unstake-tokens --pem="${USERS}/ivan.pem" --unstake-value="11${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
|
||
echo "UnbondNodes" | ||
${CLI} --verbose validator unbond-nodes --pem="${USERS}/judy.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
|
||
echo "UnbondTokens" | ||
${CLI} --verbose validator unbond-tokens --pem="${USERS}/mallory.pem" --unbond-value="20${DENOMINATION}" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
|
||
echo "CleanRegistrationData" | ||
${CLI} --verbose validator clean-registered-data --pem="${USERS}/mike.pem" --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
|
||
echo "ReStakeUnstakedNodes" | ||
${CLI} --verbose validator restake-unstaked-nodes --pem="${USERS}/alice.pem" --nodes-public-keys=${BLS_KEY} --chain=${CHAIN_ID} --proxy=${PROXY} --estimate-gas --recall-nonce || return 1 | ||
} |