Skip to content

Commit

Permalink
localnet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Feb 14, 2025
1 parent 668bef5 commit d882d1b
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 2 deletions.
99 changes: 98 additions & 1 deletion examples/call/scripts/localnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ set -e
set -x
set -o pipefail

if [ "$1" = "start" ]; then npx hardhat localnet --exit-on-error & sleep 25; fi
if [ "$1" = "start" ]; then npx hardhat localnet & sleep 15; fi

echo -e "\n🚀 Compiling contracts..."
npx hardhat compile --force --quiet

ZRC20_ETHEREUM=$(jq -r '.addresses[] | select(.type=="ZRC-20 ETH on 5") | .address' localnet.json)
ERC20_ETHEREUM=$(jq -r '.addresses[] | select(.type=="ERC-20 USDC" and .chain=="ethereum") | .address' localnet.json)
ZRC20_BNB=$(jq -r '.addresses[] | select(.type=="ZRC-20 BNB on 97") | .address' localnet.json)
ZRC20_SOL=$(jq -r '.addresses[] | select(.type=="ZRC-20 SOL on 901") | .address' localnet.json)
GATEWAY_ETHEREUM=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="ethereum") | .address' localnet.json)
GATEWAY_ZETACHAIN=$(jq -r '.addresses[] | select(.type=="gatewayZEVM" and .chain=="zetachain") | .address' localnet.json)
SENDER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Expand Down Expand Up @@ -107,4 +108,100 @@ npx hardhat universal-withdraw-and-call \

npx hardhat localnet-check

# Testing toolkit methods

npx hardhat evm-deposit \
--receiver "$CONTRACT_ZETACHAIN" \
--gateway-evm "$GATEWAY_ETHEREUM" \
--network localhost \
--amount 1

npx hardhat localnet-check

npx hardhat evm-deposit \
--receiver "$CONTRACT_ZETACHAIN" \
--gateway-evm "$GATEWAY_ETHEREUM" \
--network localhost \
--erc20 "$ERC20_ETHEREUM" \
--amount 1

npx hardhat localnet-check

npx hardhat evm-call \
--receiver "$CONTRACT_ZETACHAIN" \
--gateway-evm "$GATEWAY_ETHEREUM" \
--network localhost \
--types '["string"]' alice

npx hardhat localnet-check

npx hardhat evm-deposit-and-call \
--receiver "$CONTRACT_ZETACHAIN" \
--gateway-evm "$GATEWAY_ETHEREUM" \
--network localhost \
--amount 1 \
--types '["string"]' alice

npx hardhat localnet-check

npx hardhat evm-deposit-and-call \
--receiver "$CONTRACT_ZETACHAIN" \
--gateway-evm "$GATEWAY_ETHEREUM" \
--network localhost \
--amount 1 \
--erc20 "$ERC20_ETHEREUM" \
--types '["string"]' alice

npx hardhat localnet-check

npx hardhat zetachain-withdraw \
--receiver "$CONTRACT_ETHEREUM" \
--gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
--zrc20 "$ZRC20_ETHEREUM" \
--network localhost \
--amount 1

npx hardhat localnet-check

npx hardhat zetachain-withdraw \
--receiver "DrexsvCMH9WWjgnjVbx1iFf3YZcKadupFmxnZLfSyotd" \
--gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
--zrc20 "$ZRC20_SOL" \
--network localhost \
--amount 1

npx hardhat localnet-check

npx hardhat zetachain-call \
--receiver "$CONTRACT_ETHEREUM" \
--gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
--zrc20 "$ZRC20_ETHEREUM" \
--function "hello(string)" \
--network localhost \
--types '["string"]' alice

npx hardhat localnet-check

npx hardhat zetachain-withdraw-and-call \
--receiver "$CONTRACT_ETHEREUM" \
--gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
--zrc20 "$ZRC20_ETHEREUM" \
--function "hello(string)" \
--amount 1 \
--network localhost \
--call-options-is-arbitrary-call \
--types '["string"]' hello

npx hardhat localnet-check

npx hardhat zetachain-withdraw-and-call \
--receiver "$CONTRACT_ETHEREUM" \
--gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
--zrc20 "$ZRC20_ETHEREUM" \
--amount 1 \
--network localhost \
--types '["string"]' hello

npx hardhat localnet-check

if [ "$1" = "start" ]; then npx hardhat localnet-stop; fi
2 changes: 1 addition & 1 deletion examples/swap/scripts/localnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
set -x
set -o pipefail

if [ "$1" = "start" ]; then npx hardhat localnet --exit-on-error & sleep 20; fi
if [ "$1" = "start" ]; then npx hardhat localnet --exit-on-error & sleep 10; fi

echo -e "\n🚀 Compiling contracts..."
npx hardhat compile --force --quiet
Expand Down

0 comments on commit d882d1b

Please sign in to comment.