2020-09-08 22:25:16 +00:00
#!/bin/bash
KEY = "mykey"
2022-04-05 15:30:20 +00:00
CHAINID = "chibaclonk_9000-1"
2020-09-08 22:25:16 +00:00
MONIKER = "localtestnet"
# stop and remove existing daemon and client data and process(es)
2022-04-05 15:30:20 +00:00
rm -rf ~/.chibaclonk*
pkill -f "chibaclonk*"
2020-09-08 22:25:16 +00:00
2022-04-05 15:30:20 +00:00
make build
2020-09-08 22:25:16 +00:00
2021-04-17 10:00:07 +00:00
# if $KEY exists it should be override
2022-04-05 15:30:20 +00:00
" $PWD " /build/chibaclonkd keys add $KEY --keyring-backend test --algo "eth_secp256k1"
2020-09-08 22:25:16 +00:00
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
2022-04-05 15:30:20 +00:00
" $PWD " /build/chibaclonkd init $MONIKER --chain-id $CHAINID
2020-09-08 22:25:16 +00:00
# Change parameter token denominations to aphoton
2022-04-05 15:30:20 +00:00
cat $HOME /.chibaclonkd/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="stake"' > $HOME /.chibaclonkd/config/tmp_genesis.json && mv $HOME /.chibaclonkd/config/tmp_genesis.json $HOME /.chibaclonkd/config/genesis.json
cat $HOME /.chibaclonkd/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="aphoton"' > $HOME /.chibaclonkd/config/tmp_genesis.json && mv $HOME /.chibaclonkd/config/tmp_genesis.json $HOME /.chibaclonkd/config/genesis.json
cat $HOME /.chibaclonkd/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="aphoton"' > $HOME /.chibaclonkd/config/tmp_genesis.json && mv $HOME /.chibaclonkd/config/tmp_genesis.json $HOME /.chibaclonkd/config/genesis.json
cat $HOME /.chibaclonkd/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="aphoton"' > $HOME /.chibaclonkd/config/tmp_genesis.json && mv $HOME /.chibaclonkd/config/tmp_genesis.json $HOME /.chibaclonkd/config/genesis.json
2020-09-08 22:25:16 +00:00
# Allocate genesis accounts (cosmos formatted addresses)
2022-04-05 15:30:20 +00:00
" $PWD " /build/chibaclonkd add-genesis-account " $( " $PWD " /build/chibaclonkd keys show " $KEY " -a --keyring-backend test ) " 100000000000000000000aphoton,10000000000000000000stake --keyring-backend test
2020-09-08 22:25:16 +00:00
# Sign genesis transaction
2022-04-05 15:30:20 +00:00
" $PWD " /build/chibaclonkd gentx $KEY 10000000000000000000stake --amount= 100000000000000000000aphoton --keyring-backend test --chain-id $CHAINID
2020-09-08 22:25:16 +00:00
# Collect genesis tx
2022-04-05 15:30:20 +00:00
" $PWD " /build/chibaclonkd collect-gentxs
2020-09-08 22:25:16 +00:00
# Run this to ensure everything worked and that the genesis file is setup correctly
2022-04-05 15:30:20 +00:00
" $PWD " /build/chibaclonkd validate-genesis
2020-09-08 22:25:16 +00:00
# Start the node (remove the --pruning=nothing flag if historical queries are not needed) in background and log to file
2022-04-26 14:37:50 +00:00
" $PWD " /build/chibaclonkd start --pruning= nothing --mode validator --rpc.unsafe --json-rpc.address= "0.0.0.0:8545" --keyring-backend test > ethermintd.log 2>& 1 &
2020-09-08 22:25:16 +00:00
2021-04-17 10:00:07 +00:00
# Give ethermintd node enough time to launch
sleep 5
2020-09-08 22:25:16 +00:00
2021-05-11 11:54:55 +00:00
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
2020-09-08 22:25:16 +00:00
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 "
2020-09-08 22:25:16 +00:00
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
2020-09-08 22:25:16 +00:00
2022-04-05 15:30:20 +00:00
#PRIVKEY="$("$PWD"/build/chibaclonkd keys export $KEY)"
2020-09-08 22:25:16 +00:00
## need to get the private key from the account in order to check this functionality.
2021-05-11 11:54:55 +00:00
cd tests/solidity/suites/basic/ && go get && go run main.go $ACCT
2021-04-17 10:00:07 +00:00
# After tests
# kill test ethermintd
echo "going to shutdown ethermintd in 3 seconds..."
sleep 3
pkill -f "ethermint*"