Merge master into e2e-commons

This commit is contained in:
rzadp 2019-06-10 11:58:16 +02:00
commit 4cb2df32e3
26 changed files with 38 additions and 61 deletions

@ -58,9 +58,6 @@ jobs:
test:
docker:
- image: circleci/node:10.15
environment:
HOME_RPC_URL: http://example.com
FOREIGN_RPC_URL: http://example.com
steps:
- restore_cache:
key: initialize-{{ .Environment.CIRCLE_SHA1 }}

@ -1,4 +1,3 @@
require('dotenv').config()
const baseConfig = require('./base.config')
const erc20Abi = require('../../contracts/build/contracts/ERC20').abi
const { ERC_TYPES } = require('../src/utils/constants')

@ -1,4 +1,4 @@
require('dotenv').config()
require('../env')
const { toBN } = require('web3').utils
const { web3Home, web3Foreign } = require('../src/services/web3')

@ -1,4 +1,3 @@
require('dotenv').config()
const baseConfig = require('./base.config')
const { web3Foreign } = require('../src/services/web3')

@ -1,4 +1,3 @@
require('dotenv').config()
const baseConfig = require('./base.config')
const { web3Home } = require('../src/services/web3')

4
oracle/env.js Normal file

@ -0,0 +1,4 @@
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, process.env.NODE_ENV === 'test' ? './test/test.env' : './.env')
})

@ -1,7 +1,4 @@
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, '../../.env')
})
require('../../env')
const Web3 = require('web3')
const Web3Utils = require('web3-utils')
const rpcUrlsManager = require('../../src/services/getRpcUrlsManager')

@ -1,7 +1,4 @@
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, '../../.env')
})
require('../../env')
const Web3 = require('web3')
const Web3Utils = require('web3-utils')
const rpcUrlsManager = require('../../src/services/getRpcUrlsManager')

@ -1,7 +1,4 @@
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, '../../.env')
})
require('../../env')
const Web3 = require('web3')
const Web3Utils = require('web3-utils')
const rpcUrlsManager = require('../../src/services/getRpcUrlsManager')

@ -1,7 +1,4 @@
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, '../../.env')
})
require('../../env')
const Web3Utils = require('web3-utils')
const { web3Home } = require('../../src/services/web3')
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')

@ -1,7 +1,4 @@
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, '../.env')
})
require('../env')
const Web3 = require('web3')
const bridgeValidatorsABI = require('../../contracts/build/contracts/BridgeValidators').abi

@ -1,7 +1,4 @@
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, '../.env')
})
require('../env')
const Web3 = require('web3')
const ERC677BridgeTokenABI = require('../../contracts/build/contracts/ERC677BridgeToken').abi
const { ERC_TYPES } = require('../src/utils/constants')

@ -1,7 +1,4 @@
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, '../../.env')
})
require('../../env')
const Web3Utils = require('web3-utils')
const { web3Foreign } = require('../../src/services/web3')
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')

@ -1,7 +1,4 @@
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, '../../.env')
})
require('../../env')
const Web3Utils = require('web3-utils')
const { web3Home } = require('../../src/services/web3')
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')

@ -1,7 +1,4 @@
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, '..', '.env')
})
require('../env')
const { privateKeyToAddress } = require('../src/utils/utils')
const { EXIT_CODES } = require('../src/utils/constants')

@ -1,8 +1,5 @@
require('../env')
const Redis = require('ioredis')
const path = require('path')
require('dotenv').config({
path: path.join(__dirname, '../.env')
})
const { id } = require('../config/base.config')
const { EXIT_CODES } = require('../src/utils/constants')

@ -1,4 +1,4 @@
require('dotenv').config()
require('../../../env')
const promiseLimit = require('promise-limit')
const { HttpListProviderError } = require('http-list-provider')
const rootLogger = require('../../services/logger')

@ -1,4 +1,4 @@
require('dotenv').config()
require('../../../env')
const promiseLimit = require('promise-limit')
const { HttpListProviderError } = require('http-list-provider')
const bridgeValidatorsABI = require('../../../../contracts/build/contracts/BridgeValidators').abi

@ -1,4 +1,4 @@
require('dotenv').config()
require('../../../env')
const promiseLimit = require('promise-limit')
const { HttpListProviderError } = require('http-list-provider')
const bridgeValidatorsABI = require('../../../../contracts/build/contracts/BridgeValidators').abi

@ -1,4 +1,4 @@
require('dotenv').config()
require('../../../env')
const promiseLimit = require('promise-limit')
const { HttpListProviderError } = require('http-list-provider')
const bridgeValidatorsABI = require('../../../../contracts/build/contracts/BridgeValidators').abi

@ -1,4 +1,4 @@
require('dotenv').config()
require('../env')
const path = require('path')
const { connectSenderToQueue } = require('./services/amqpClient')
const { redis, redlock } = require('./services/redisClient')
@ -13,7 +13,8 @@ const {
privateKeyToAddress,
syncForEach,
waitForFunds,
watchdog
watchdog,
nonceError
} = require('./utils/utils')
const { EXIT_CODES, EXTRA_GAS_PERCENTAGE } = require('./utils/constants')
@ -152,10 +153,7 @@ async function main({ msg, ackMsg, nackMsg, sendToQueue, channel }) {
logger.error(
`Insufficient funds: ${currentBalance}. Stop processing messages until the balance is at least ${minimumBalance}.`
)
} else if (
e.message.includes('Transaction nonce is too low') ||
e.message.includes('transaction with same nonce in the queue')
) {
} else if (nonceError(e)) {
nonce = await readNonce(true)
}
}

@ -1,4 +1,4 @@
require('dotenv').config()
require('../../env')
const connection = require('amqp-connection-manager').connect(process.env.QUEUE_URL)
const logger = require('./logger')

@ -1,4 +1,4 @@
require('dotenv').config()
require('../../env')
const fetch = require('node-fetch')
const Web3Utils = require('web3-utils')
const { web3Home, web3Foreign } = require('../services/web3')

@ -96,6 +96,14 @@ function privateKeyToAddress(privateKey) {
: null
}
function nonceError(e) {
return (
e.message.includes('Transaction nonce is too low') ||
e.message.includes('nonce too low') ||
e.message.includes('transaction with same nonce in the queue')
)
}
module.exports = {
syncForEach,
checkHTTPS,
@ -103,5 +111,6 @@ module.exports = {
addExtraGas,
setIntervalAndRun,
watchdog,
privateKeyToAddress
privateKeyToAddress,
nonceError
}

@ -1,4 +1,4 @@
require('dotenv').config()
require('../env')
const path = require('path')
const { BN, toBN } = require('web3').utils
const { connectWatcherToQueue, connection } = require('./services/amqpClient')

2
oracle/test/test.env Normal file

@ -0,0 +1,2 @@
HOME_RPC_URL=http://example.com
FOREIGN_RPC_URL=http://example.com