diff --git a/demo/start-binance-environment.sh b/demo/start-binance-environment.sh index 783b179..5d56c69 100755 --- a/demo/start-binance-environment.sh +++ b/demo/start-binance-environment.sh @@ -35,7 +35,7 @@ sleep 2 if [[ -n "$need_to_deploy" ]]; then echo "Issuing test asset" - ISSUED_LOG=$(tbnbcli token issue --symbol DEV --total-supply 1000000000000 --token-name "DEV Token" | jq .Response.log) + ISSUED_LOG=$(tbnbcli token issue --symbol DEV --total-supply 10000000000000000 --token-name "DEV Token" | jq .Response.log) TOKEN_SYMBOL=${ISSUED_LOG:(-8):7} echo "Issued $TOKEN_SYMBOL" @@ -49,7 +49,8 @@ if [[ -n "$need_to_deploy" ]]; then sleep 2 echo "Sending tokens to controlled address" - tbnbcli token multi-send --transfers '[{"to":"tbnb1z7u9f8mcuwxanns9xa6qgjtlka0d392epc0m9x","amount":"1000000000000:BNB,1000000000000:'"$TOKEN_SYMBOL"'"}]' + tbnbcli token multi-send \ + --transfers '[{"to":"tbnb1z7u9f8mcuwxanns9xa6qgjtlka0d392epc0m9x","amount":"10000000000000000:BNB,10000000000000000:'"$TOKEN_SYMBOL"'"}]' sleep 2 else diff --git a/tests/init.sh b/tests/init.sh index 62d3a64..0261b56 100755 --- a/tests/init.sh +++ b/tests/init.sh @@ -2,14 +2,6 @@ set -e -echo "Killing all remaining docker containers" -docker kill $(docker ps | grep validator[1-3]_ | awk '{print $1}') > /dev/null 2>&1 || true -docker rm $(docker ps -a | grep validator[1-3]_ | awk '{print $1}') > /dev/null 2>&1 || true -docker kill ganache_home ganache_side > /dev/null 2>&1 || true -docker rm ganache_home ganache_side > /dev/null 2>&1 || true -docker kill $(docker ps | grep binance-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true -docker rm $(docker ps -a | grep binance-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true - echo "Cleaning previous demo environment" ./demo/clean.sh @@ -21,11 +13,6 @@ BLOCK_TIME=3 ./demo/start-ethereum-environment.sh echo "Starting binance test network" ./demo/start-binance-environment.sh -echo "Prefunding ethereum user accounts" -cat ./tests/config.json | jq .users[].ethAddress | xargs -I {} ./src/test-services/ethereumSend/run.sh {} 1000 -echo "Prefunding binance user accounts" -cat ./tests/config.json | jq .users[].bncAddress | xargs -I {} ./src/test-services/binanceSend/run.sh {} 300 0.1 - echo "Starting validator daemons" N=1 ./demo/validator-demo.sh -d N=2 ./demo/validator-demo.sh -d diff --git a/tests/test/index.js b/tests/test/index.js index a120c7c..b5bb877 100644 --- a/tests/test/index.js +++ b/tests/test/index.js @@ -13,50 +13,30 @@ const testChangeThreshold = require('./changeThreshold') const usersConfig = require('../config').users const validatorsConfig = require('../config').validators -const { - HOME_PRIVATE_KEY, FOREIGN_PRIVATE_KEY, HOME_BRIDGE_ADDRESS, FOREIGN_ASSET -} = process.env +const { HOME_PRIVATE_KEY, FOREIGN_PRIVATE_KEY, HOME_BRIDGE_ADDRESS } = process.env const { controller1 } = require('./utils/proxyController') describe('bridge tests', function () { let users let bncPrefundedUser + let ethPrefundedUser before(async function () { + ethPrefundedUser = await createUser(HOME_PRIVATE_KEY, 'eth') + bncPrefundedUser = await createUser(FOREIGN_PRIVATE_KEY, 'bnc') + + for (let i = 0; i < 3; i += 1) { + // user eth balance is already prefunded with 100 eth in genesis block + await ethPrefundedUser.transferErc(usersConfig[i].ethAddress, 10000) + await bncPrefundedUser.transferBepBnb(usersConfig[i].bncAddress, 10000, 100) + } + users = await seqMap(usersConfig, (user) => createUser(user.privateKey)) }) describe('generation of initial epoch keys', function () { let info - let ethPrefundedUser - - before(async function () { - ethPrefundedUser = await createUser(HOME_PRIVATE_KEY, 'eth') - bncPrefundedUser = await createUser(FOREIGN_PRIVATE_KEY, 'bnc') - - const bnbBalance = await bncPrefundedUser.getBnbBalance() - assert.ok(bnbBalance >= 10, `Insufficient BNB balance on ${bncPrefundedUser.ethAddress} in Binance network, expected 10 BNB, got ${bnbBalance}`) - const bepBalance = await bncPrefundedUser.getBepBalance() - assert.ok(bepBalance >= 2000, `Insufficient BEP2 balance on ${bncPrefundedUser.ethAddress} in Binance network, expected 2000 ${FOREIGN_ASSET}, got ${bepBalance}`) - - const ethBalance = await ethPrefundedUser.getEthBalance() - assert.ok(ethBalance >= 1, `Insufficient ETH balance on ${ethPrefundedUser.ethAddress} in Ethereum network, expected 1 ETH, got ${ethBalance}`) - const ercBalance = await ethPrefundedUser.getErcBalance() - assert.ok(ercBalance >= 2000, `Insufficient ERC20 balance on ${ethPrefundedUser.ethAddress} in Ethereum network, expected 2000 ERC20, got ${ercBalance}`) - - - for (let i = 0; i < 3; i += 1) { - const userEthBalance = await users[i].getEthBalance() - assert.ok(userEthBalance >= 0.1, `Insufficient ETH balance on ${users[i].ethAddress} in Ethereum network, expected 0.1 ETH, got ${userEthBalance}`) - const userErcBalance = await users[i].getErcBalance() - assert.ok(userErcBalance >= 1000, `Insufficient ERC20 balance on ${users[i].ethAddress} in Ethereum network, expected 1000 ERC20, got ${userErcBalance}`) - const userBnbBalance = await users[i].getBepBalance() - assert.ok(userBnbBalance >= 0.1, `Insufficient BNB balance on ${users[i].bncAddress} in Binance network, expected 0.1 BNB, got ${userBnbBalance}`) - const userBepBalance = await users[i].getBepBalance() - assert.ok(userErcBalance >= 200, `Insufficient BEP2 balance on ${users[i].bncAddress} in Binance network, expected 200 ${FOREIGN_ASSET}, got ${userBepBalance}`) - } - }) it('should generate keys', async function () { this.timeout(120000) @@ -73,7 +53,7 @@ describe('bridge tests', function () { }) after(async function () { - await bncPrefundedUser.transferBepBnb(info.foreignBridgeAddress, 1000, 5) + await bncPrefundedUser.transferBepBnb(info.foreignBridgeAddress, 1000, 50) await ethPrefundedUser.transferErc(HOME_BRIDGE_ADDRESS, 1000) }) })