Fixed waiting for funds in sendTx, fixed correspondent tests.
This commit is contained in:
parent
17cb9e760d
commit
73f7dc1612
|
@ -125,6 +125,14 @@ orbs:
|
||||||
docker logs ganache_home > ./artifacts/logs/ganache/home.log
|
docker logs ganache_home > ./artifacts/logs/ganache/home.log
|
||||||
docker logs ganache_side > ./artifacts/logs/ganache/side.log
|
docker logs ganache_side > ./artifacts/logs/ganache/side.log
|
||||||
when: always
|
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:
|
- store_artifacts:
|
||||||
path: ./artifacts
|
path: ./artifacts
|
||||||
when: always
|
when: always
|
||||||
|
@ -151,7 +159,7 @@ jobs:
|
||||||
name: "Run dev environment, deploy contracts, prefund accounts"
|
name: "Run dev environment, deploy contracts, prefund accounts"
|
||||||
command: |
|
command: |
|
||||||
BLOCK_TIME=3 ./demo/start-ethereum-environment.sh
|
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:
|
- run:
|
||||||
name: "Stop dev environment"
|
name: "Stop dev environment"
|
||||||
command: docker kill ganache_side ganache_home
|
command: docker kill ganache_side ganache_home
|
||||||
|
|
|
@ -126,7 +126,25 @@ async function handleBroadcast(req, res) {
|
||||||
tx: `0x${req.rawBody}`
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ VALIDATOR_ADDRESS_3=0x6352e3e6038e05b9da00c84ae851308f9774f883
|
||||||
THRESHOLD=2
|
THRESHOLD=2
|
||||||
|
|
||||||
MIN_TX_LIMIT=10000000000000000
|
MIN_TX_LIMIT=10000000000000000
|
||||||
MAX_TX_LIMIT=100000000000000000000
|
MAX_TX_LIMIT=1000000000000000000000
|
||||||
|
|
||||||
BLOCKS_RANGE_SIZE=10
|
BLOCKS_RANGE_SIZE=10
|
||||||
|
|
||||||
|
|
|
@ -119,19 +119,19 @@ async function waitForAccountNonce(address, nonce) {
|
||||||
async function sendTx(tx) {
|
async function sendTx(tx) {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
return await httpClient
|
return await httpClient.post('/api/v1/broadcast?sync=true', tx, {
|
||||||
.post('/api/v1/broadcast?sync=true', tx, {
|
headers: {
|
||||||
headers: {
|
'Content-Type': 'text/plain'
|
||||||
'Content-Type': 'text/plain'
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
logger.trace('Error, response data %o', err.response.data)
|
||||||
if (err.response.data.message.includes('Tx already exists in cache')) {
|
if (err.response.data.message.includes('Tx already exists in cache')) {
|
||||||
logger.debug('Tx already exists in cache')
|
logger.debug('Tx already exists in cache')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (err.response.data.message.includes(' < ')) {
|
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)
|
await delay(60000)
|
||||||
} else {
|
} else {
|
||||||
logger.info('Something failed, restarting: %o', err.response)
|
logger.info('Something failed, restarting: %o', err.response)
|
||||||
|
|
|
@ -22,7 +22,7 @@ echo "Starting binance test network"
|
||||||
./demo/start-binance-environment.sh
|
./demo/start-binance-environment.sh
|
||||||
|
|
||||||
echo "Prefunding ethereum user accounts"
|
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"
|
echo "Prefunding binance user accounts"
|
||||||
cat ./tests/config.json | jq .users[].bncAddress | xargs -I {} ./src/test-services/binanceSend/run.sh {} 300 0.1
|
cat ./tests/config.json | jq .users[].bncAddress | xargs -I {} ./src/test-services/binanceSend/run.sh {} 300 0.1
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,10 @@ module.exports = (getUsers, newValidator) => {
|
||||||
initialInfo = await controller1.getInfo()
|
initialInfo = await controller1.getInfo()
|
||||||
// eslint-disable-next-line prefer-destructuring
|
// eslint-disable-next-line prefer-destructuring
|
||||||
user = getUsers()[0]
|
user = getUsers()[0]
|
||||||
bncBridgeSequence = await getBncSequence(info.foreignBridgeAddress)
|
|
||||||
bncBalance = await user.getBepBalance()
|
bncBalance = await user.getBepBalance()
|
||||||
info = initialInfo
|
info = initialInfo
|
||||||
nextValidators = [...initialInfo.validators, newValidator]
|
bncBridgeSequence = await getBncSequence(info.foreignBridgeAddress)
|
||||||
|
nextValidators = [...info.validators, newValidator]
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should start closing epoch process', async function () {
|
it('should start closing epoch process', async function () {
|
||||||
|
|
|
@ -36,8 +36,8 @@ module.exports = (getUsers, amount = 5, getBncPrefundedUser = null) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (bncPrefundedUser) {
|
if (getBncPrefundedUser) {
|
||||||
it('should make exchange transaction on bnc side with waiting for enough funds on bnc side', async function () {
|
it('should make exchange transaction on bnc side after already enough funds', async function () {
|
||||||
this.timeout(300000)
|
this.timeout(300000)
|
||||||
await delay(120000)
|
await delay(120000)
|
||||||
await bncPrefundedUser.transferBepBnb(info.foreignBridgeAddress, amount * 3 + 10, 0)
|
await bncPrefundedUser.transferBepBnb(info.foreignBridgeAddress, amount * 3 + 10, 0)
|
||||||
|
|
|
@ -50,7 +50,7 @@ describe('bridge tests', function () {
|
||||||
const userEthBalance = await users[i].getEthBalance()
|
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}`)
|
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()
|
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()
|
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}`)
|
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()
|
const userBepBalance = await users[i].getBepBalance()
|
||||||
|
@ -84,7 +84,7 @@ describe('bridge tests', function () {
|
||||||
|
|
||||||
testRemoveValidator(validatorsConfig[1])
|
testRemoveValidator(validatorsConfig[1])
|
||||||
|
|
||||||
testEthToBnc(() => users)
|
testEthToBnc(() => users, 500, () => bncPrefundedUser)
|
||||||
testBncToEth(() => users)
|
testBncToEth(() => users)
|
||||||
testEthToBnc(() => users)
|
testEthToBnc(() => users)
|
||||||
|
|
||||||
|
@ -99,5 +99,5 @@ describe('bridge tests', function () {
|
||||||
testEthToBnc(() => users)
|
testEthToBnc(() => users)
|
||||||
testBncToEth(() => users)
|
testBncToEth(() => users)
|
||||||
testEthToBncWithRestart(() => users, 2)
|
testEthToBncWithRestart(() => users, 2)
|
||||||
testEthToBnc(() => users, 500, bncPrefundedUser)
|
testEthToBnc(() => users)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue