laconicd-deprecated/scripts/contract-test.sh

63 lines
3.4 KiB
Bash
Raw Normal View History

#!/bin/bash
KEY="mykey"
2022-10-10 10:38:33 +00:00
CHAINID="ethermint_9000-1"
MONIKER="localtestnet"
# stop and remove existing daemon and client data and process(es)
2022-10-12 11:54:07 +00:00
rm -rf ~/.laconic*
pkill -f "laconic*"
2022-10-12 11:54:07 +00:00
make build-laconic
2021-04-17 10:00:07 +00:00
# if $KEY exists it should be override
"$PWD"/build/laconicd keys add $KEY --keyring-backend test --algo "eth_secp256k1"
2022-10-12 11:54:07 +00:00
# Set moniker and chain-id for laconic (Moniker can be anything, chain-id must be an integer)
"$PWD"/build/laconicd init $MONIKER --chain-id $CHAINID
# Change parameter token denominations to aphoton
2022-10-12 11:54:07 +00:00
cat $HOME/.laconic/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="stake"' > $HOME/.laconic/config/tmp_genesis.json && mv $HOME/.laconic/config/tmp_genesis.json $HOME/.laconic/config/genesis.json
cat $HOME/.laconic/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="aphoton"' > $HOME/.laconic/config/tmp_genesis.json && mv $HOME/.laconic/config/tmp_genesis.json $HOME/.laconic/config/genesis.json
cat $HOME/.laconic/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="aphoton"' > $HOME/.laconic/config/tmp_genesis.json && mv $HOME/.laconic/config/tmp_genesis.json $HOME/.laconic/config/genesis.json
cat $HOME/.laconic/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="aphoton"' > $HOME/.laconic/config/tmp_genesis.json && mv $HOME/.laconic/config/tmp_genesis.json $HOME/.laconic/config/genesis.json
# Allocate genesis accounts (cosmos formatted addresses)
"$PWD"/build/laconicd add-genesis-account "$("$PWD"/build/laconicd keys show "$KEY" -a --keyring-backend test)" 100000000000000000000aphoton,10000000000000000000stake --keyring-backend test
# Sign genesis transaction
"$PWD"/build/laconicd gentx $KEY 10000000000000000000stake --amount=100000000000000000000aphoton --keyring-backend test --chain-id $CHAINID
# Collect genesis tx
"$PWD"/build/laconicd collect-gentxs
# Run this to ensure everything worked and that the genesis file is setup correctly
"$PWD"/build/laconicd validate-genesis
# Start the node (remove the --pruning=nothing flag if historical queries are not needed) in background and log to file
2022-10-10 10:38:33 +00:00
"$PWD"/build/laconicd start --pruning=nothing --rpc.unsafe --json-rpc.address="0.0.0.0:8545" --keyring-backend test > laconicd.log 2>&1 &
2022-10-10 10:38:33 +00:00
# Give laconicd node enough time to launch
2021-04-17 10:00:07 +00:00
sleep 5
solcjs --abi "$PWD"/tests/solidity/suites/basic/contracts/Counter.sol --bin -o "$PWD"/tests/solidity/suites/basic/counter
mv "$PWD"/tests/solidity/suites/basic/counter/*.abi "$PWD"/tests/solidity/suites/basic/counter/counter_sol.abi 2> /dev/null
mv "$PWD"/tests/solidity/suites/basic/counter/*.bin "$PWD"/tests/solidity/suites/basic/counter/counter_sol.bin 2> /dev/null
2021-04-17 10:00:07 +00:00
# Query for the account
ACCT=$(curl --fail --silent -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545 | grep -o '\0x[^"]*')
echo "$ACCT"
2021-05-25 08:46:10 +00:00
# Start testcases (not supported)
# curl -X POST --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["'$ACCT'", ""],"id":1}' -H "Content-Type: application/json" http://localhost:8545
#PRIVKEY="$("$PWD"/build/laconicd keys export $KEY)"
## need to get the private key from the account in order to check this functionality.
cd tests/solidity/suites/basic/ && go get && go run main.go $ACCT
2021-04-17 10:00:07 +00:00
# After tests
2022-10-10 10:38:33 +00:00
# kill test laconicd
echo "going to shutdown laconicd in 3 seconds..."
2021-04-17 10:00:07 +00:00
sleep 3
2022-10-12 11:54:07 +00:00
pkill -f "laconic*"