imp(tests): integration tests setup (#1196)

* first pass

* latest

* working tests

* github actions

* remove unnecessary change

* remove unnecessary steps

* remove unnecessary import

* remove unnecessary change

* Update .github/workflows/test.yml

Co-authored-by: yihuang <huang@crypto.com>

* update .gitignore

* update github actions

* change evm denomination

* change evm denomination

* send tests to tests folder

* Delete result

* update go version

Co-authored-by: yihuang <huang@crypto.com>
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
crypto-facs
2022-07-27 13:27:07 +00:00
committed by GitHub
co-authored by yihuang Federico Kunze Küllmer
parent 3460cba07c
commit fd0e62a067
35 changed files with 29987 additions and 1 deletions
Executable
+6
View File
@@ -0,0 +1,6 @@
export PASSWORD='123456'
export VALIDATOR1_MNEMONIC="visit craft resemble online window solution west chuckle music diesel vital settle comic tribe project blame bulb armed flower region sausage mercy arrive release"
export VALIDATOR2_MNEMONIC="direct travel shrug hand twice agent sail sell jump phone velvet pilot mango charge usual multiply orient garment bleak virtual action mention panda vast"
export COMMUNITY_MNEMONIC="notable error gospel wave pair ugly measure elite toddler cost various fly make eye ketchup despair slab throw tribe swarm word fruit into inmate"
export SIGNER1_MNEMONIC="shed crumble dismiss loyal latin million oblige gesture shrug still oxygen custom remove ribbon disorder palace addict again blanket sad flock consider obey popular"
export SIGNER2_MNEMONIC="night renew tonight dinner shaft scheme domain oppose echo summer broccoli agent face guitar surface belt veteran siren poem alcohol menu custom crunch index"
Regular → Executable
View File
+56
View File
@@ -0,0 +1,56 @@
dotenv: .env
ethermint_9000-1:
cmd: ethermintd
start-flags: "--trace"
app-config:
minimum-gas-prices: 0aphoton
index-events:
- ethereum_tx.ethereumTxHash
json-rpc:
address: "0.0.0.0:{EVMRPC_PORT}"
ws-address: "0.0.0.0:{EVMRPC_PORT_WS}"
api: "eth,net,web3,debug"
validators:
- coins: 1000000000000000000stake,10000000000000000000000aphoton
staked: 1000000000000000000stake
mnemonic: ${VALIDATOR1_MNEMONIC}
- coins: 1000000000000000000stake,10000000000000000000000aphoton
staked: 1000000000000000000stake
mnemonic: ${VALIDATOR2_MNEMONIC}
accounts:
- name: community
coins: 10000000000000000000000aphoton
mnemonic: ${COMMUNITY_MNEMONIC}
- name: signer1
coins: 20000000000000000000000aphoton
mnemonic: ${SIGNER1_MNEMONIC}
- name: signer2
coins: 30000000000000000000000aphoton
mnemonic: ${SIGNER2_MNEMONIC}
genesis:
consensus_params:
block:
max_bytes: "1048576"
max_gas: "81500000"
app_state:
evm:
params:
evm_denom: aphoton
gov:
voting_params:
voting_period: "10s"
deposit_params:
max_deposit_period: "10s"
min_deposit:
- denom: "aphoton"
amount: "1"
transfer:
params:
receive_enabled: true
send_enabled: true
feemarket:
params:
no_base_fee: false
base_fee: "100000000000"
min_gas_multiplier: "0"
+41
View File
@@ -0,0 +1,41 @@
{
"config": {
"chainId": 9000,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"yoloV3Block": 0,
"londonBlock": 0,
"clique": {
"period": 2,
"epoch": 30000
}
},
"nonce": "0x0",
"timestamp": "0x60ed6d23",
"extraData": "0x000000000000000000000000000000000000000000000000000000000000000057f96e6b86cdefdb3d412547816a82e3e0ebf9d20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x4db9760",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"57f96e6b86cdefdb3d412547816a82e3e0ebf9d2": {
"balance": "0x21e19e0c9bab2400000"
},
"378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec": {
"balance": "0x21e19e0c9bab2400000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas": "100000000000"
}
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
set -e
cd "$(dirname "$0")"
# explicitly set a short TMPDIR to prevent path too long issue on macosx
export TMPDIR=/tmp
echo "build test contracts"
cd ../tests/integration_tests/contracts
HUSKY_SKIP_INSTALL=1 npm install
npm run typechain
cd ..
nix-shell --run "pytest -vv -s"
+31
View File
@@ -0,0 +1,31 @@
#!/bin/sh
set -e
CONFIG=$1
if [ -z "$CONFIG" ]; then
echo "No config file supplied"
exit 1
fi
shift
DOTENV=$1
if [ -z "$DOTENV" ]; then
echo "No dotenv file supplied"
exit 1
fi
shift
DATA=$1
if [ -z "$DATA" ]; then
echo "No data directory supplied"
exit 1
fi
shift
echo 'pystarport:'
echo ' config: '$CONFIG
echo ' dotenv: '$DOTENV
echo ' data: '$DATA
pystarport init --config $CONFIG --dotenv $DOTENV --data $DATA $@
supervisord -c $DATA/tasks.ini
+58
View File
@@ -0,0 +1,58 @@
#!/bin/sh
set -e
CONFIG=$1
if [ -z $CONFIG ]; then
echo "No config file supplied"
exit 1
fi
shift
DATA=$1
if [ -z $DATA ]; then
echo "No data directory supplied"
exit 1
fi
shift
geth --datadir $DATA init $CONFIG
pwdfile=$(mktemp /tmp/password.XXXXXX)
tmpfile=$(mktemp /tmp/validator-key.XXXXXX)
cat > $pwdfile << EOF
$PASSWORD
EOF
# import validator key
validator_key=$(python -c """
from eth_account import Account
Account.enable_unaudited_hdwallet_features()
print(Account.from_mnemonic('$VALIDATOR1_MNEMONIC').key.hex().replace('0x',''))
""")
cat > $tmpfile << EOF
$validator_key
EOF
geth --datadir $DATA account import $tmpfile --password $pwdfile
# import community key
community_key=$(python -c """
from eth_account import Account
Account.enable_unaudited_hdwallet_features()
print(Account.from_mnemonic('$COMMUNITY_MNEMONIC').key.hex().replace('0x',''))
""")
cat > $tmpfile << EOF
$community_key
EOF
geth --datadir $DATA account import $tmpfile --password $pwdfile
rm $tmpfile
# start up
geth --networkid 9000 --datadir $DATA --http --http.addr localhost --http.api 'personal,eth,net,web3,txpool,miner' \
-unlock '0x57f96e6b86cdefdb3d412547816a82e3e0ebf9d2' --password $pwdfile \
--mine --allow-insecure-unlock \
$@
rm $pwdfile