diff --git a/.circleci/config.yml b/.circleci/config.yml index a1e6183..f79f9c3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -125,6 +125,14 @@ orbs: docker logs ganache_home > ./artifacts/logs/ganache/home.log docker logs ganache_side > ./artifacts/logs/ganache/side.log when: always + - run: + name: "Save binance logs" + command: | + mkdir -p ./artifacts/logs/binance + docker logs binance-testnet_node_1 > ./artifacts/logs/binance/node.log + docker logs binance-testnet_api-server_1 > ./artifacts/logs/binance/api-server.log + docker logs binance-testnet_http-api_1 > ./artifacts/logs/binance/http-api.log + when: always - store_artifacts: path: ./artifacts when: always @@ -151,7 +159,7 @@ jobs: name: "Run dev environment, deploy contracts, prefund accounts" command: | BLOCK_TIME=3 ./demo/start-ethereum-environment.sh - cat ./tests/config.json | jq .users[].ethAddress | xargs -I {} ./src/test-services/ethereumSend/run.sh {} 300 + cat ./tests/config.json | jq .users[].ethAddress | xargs -I {} ./src/test-services/ethereumSend/run.sh {} 1000 - run: name: "Stop dev environment" command: docker kill ganache_side ganache_home diff --git a/src/binance-testnet/http-api/index.js b/src/binance-testnet/http-api/index.js index 58d52aa..60feabb 100644 --- a/src/binance-testnet/http-api/index.js +++ b/src/binance-testnet/http-api/index.js @@ -126,7 +126,25 @@ async function handleBroadcast(req, res) { tx: `0x${req.rawBody}` } }) - res.send([response.data.result]) + if (response.data.error) { + res.status(500).send({ + code: 500, + failed_tx_index: 0, + message: 'RPC error -32603 - Internal error: Tx already exists in cache', + success_tx_results: [] + }) + } else if (response.data.result.code === 65546) { + res.status(400).send({ + code: 400, + failed_tx_index: 0, + message: '3417218964BNB < 1000DEV-BA6', + success_tx_results: [] + }) + } else if (response.data.result) { + res.send([response.data.result]) + } else { + res.status(400).end() + } } } diff --git a/src/deploy/deploy-home/.env.development b/src/deploy/deploy-home/.env.development index 7c3f528..b13d306 100644 --- a/src/deploy/deploy-home/.env.development +++ b/src/deploy/deploy-home/.env.development @@ -12,7 +12,7 @@ VALIDATOR_ADDRESS_3=0x6352e3e6038e05b9da00c84ae851308f9774f883 THRESHOLD=2 MIN_TX_LIMIT=10000000000000000 -MAX_TX_LIMIT=100000000000000000000 +MAX_TX_LIMIT=1000000000000000000000 BLOCKS_RANGE_SIZE=10 diff --git a/src/oracle/tss-sign/signer.js b/src/oracle/tss-sign/signer.js index 39d77b4..0e3810d 100644 --- a/src/oracle/tss-sign/signer.js +++ b/src/oracle/tss-sign/signer.js @@ -119,19 +119,19 @@ async function waitForAccountNonce(address, nonce) { async function sendTx(tx) { while (true) { try { - return await httpClient - .post('/api/v1/broadcast?sync=true', tx, { - headers: { - 'Content-Type': 'text/plain' - } - }) + return await httpClient.post('/api/v1/broadcast?sync=true', tx, { + headers: { + 'Content-Type': 'text/plain' + } + }) } catch (err) { + logger.trace('Error, response data %o', err.response.data) if (err.response.data.message.includes('Tx already exists in cache')) { logger.debug('Tx already exists in cache') return true } if (err.response.data.message.includes(' < ')) { - logger.warn('Insufficient funds, waiting for funds to income') + logger.warn('Insufficient funds, waiting for funds') await delay(60000) } else { logger.info('Something failed, restarting: %o', err.response) diff --git a/tests/init.sh b/tests/init.sh index b94a291..d542a16 100755 --- a/tests/init.sh +++ b/tests/init.sh @@ -22,7 +22,7 @@ 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 {} 300 +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 diff --git a/tests/test/addValidator.js b/tests/test/addValidator.js index 61d89ea..da0c1d0 100644 --- a/tests/test/addValidator.js +++ b/tests/test/addValidator.js @@ -18,10 +18,10 @@ module.exports = (getUsers, newValidator) => { initialInfo = await controller1.getInfo() // eslint-disable-next-line prefer-destructuring user = getUsers()[0] - bncBridgeSequence = await getBncSequence(info.foreignBridgeAddress) bncBalance = await user.getBepBalance() info = initialInfo - nextValidators = [...initialInfo.validators, newValidator] + bncBridgeSequence = await getBncSequence(info.foreignBridgeAddress) + nextValidators = [...info.validators, newValidator] }) it('should start closing epoch process', async function () { diff --git a/tests/test/ethToBnc.js b/tests/test/ethToBnc.js index 4ae6ef6..c01a5dc 100644 --- a/tests/test/ethToBnc.js +++ b/tests/test/ethToBnc.js @@ -36,8 +36,8 @@ module.exports = (getUsers, amount = 5, getBncPrefundedUser = null) => { } }) - if (bncPrefundedUser) { - it('should make exchange transaction on bnc side with waiting for enough funds on bnc side', async function () { + if (getBncPrefundedUser) { + it('should make exchange transaction on bnc side after already enough funds', async function () { this.timeout(300000) await delay(120000) await bncPrefundedUser.transferBepBnb(info.foreignBridgeAddress, amount * 3 + 10, 0) diff --git a/tests/test/index.js b/tests/test/index.js index 8ae7840..a120c7c 100644 --- a/tests/test/index.js +++ b/tests/test/index.js @@ -50,7 +50,7 @@ describe('bridge tests', function () { 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 >= 200, `Insufficient ERC20 balance on ${users[i].ethAddress} in Ethereum network, expected 200 ERC20, got ${userErcBalance}`) + 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() @@ -84,7 +84,7 @@ describe('bridge tests', function () { testRemoveValidator(validatorsConfig[1]) - testEthToBnc(() => users) + testEthToBnc(() => users, 500, () => bncPrefundedUser) testBncToEth(() => users) testEthToBnc(() => users) @@ -99,5 +99,5 @@ describe('bridge tests', function () { testEthToBnc(() => users) testBncToEth(() => users) testEthToBncWithRestart(() => users, 2) - testEthToBnc(() => users, 500, bncPrefundedUser) + testEthToBnc(() => users) })