From b88dd66cac44e75e7c30d5d075c5c0e75bc4a55c Mon Sep 17 00:00:00 2001 From: Przemyslaw Rzad Date: Fri, 12 Jul 2019 10:53:16 +0200 Subject: [PATCH] Oracle-e2e using Commons (#146) --- oracle-e2e/config.json | 3 --- oracle-e2e/test/ercToErc.js | 13 ++++++------- oracle-e2e/test/ercToNative.js | 11 +++++------ oracle-e2e/test/nativeToErc.js | 7 ++----- 4 files changed, 13 insertions(+), 21 deletions(-) delete mode 100644 oracle-e2e/config.json diff --git a/oracle-e2e/config.json b/oracle-e2e/config.json deleted file mode 100644 index 4ba99e88..00000000 --- a/oracle-e2e/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "abiPath": "../contracts/build/contracts" -} diff --git a/oracle-e2e/test/ercToErc.js b/oracle-e2e/test/ercToErc.js index 1d2f2790..619aebe1 100644 --- a/oracle-e2e/test/ercToErc.js +++ b/oracle-e2e/test/ercToErc.js @@ -1,13 +1,10 @@ -const path = require('path') const Web3 = require('web3') const assert = require('assert') const promiseRetry = require('promise-retry') const { user, ercToErcBridge, homeRPC, foreignRPC } = require('../../e2e-commons/constants.json') -const { abiPath } = require('../config.json') +const { ERC677_BRIDGE_TOKEN_ABI } = require('../../commons') const { generateNewBlock } = require('../../e2e-commons/utils') -const abisDir = path.join(__dirname, '..', abiPath) - const homeWeb3 = new Web3(new Web3.providers.HttpProvider(homeRPC.URL)) const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(foreignRPC.URL)) @@ -19,9 +16,11 @@ const { toBN } = foreignWeb3.utils homeWeb3.eth.accounts.wallet.add(user.privateKey) foreignWeb3.eth.accounts.wallet.add(user.privateKey) -const tokenAbi = require(path.join(abisDir, 'ERC677BridgeToken.json')).abi -const erc20Token = new foreignWeb3.eth.Contract(tokenAbi, ercToErcBridge.foreignToken) -const erc677Token = new homeWeb3.eth.Contract(tokenAbi, ercToErcBridge.homeToken) +const erc20Token = new foreignWeb3.eth.Contract( + ERC677_BRIDGE_TOKEN_ABI, + ercToErcBridge.foreignToken +) +const erc677Token = new homeWeb3.eth.Contract(ERC677_BRIDGE_TOKEN_ABI, ercToErcBridge.homeToken) describe('erc to erc', () => { it('should convert tokens in foreign to tokens in home', async () => { diff --git a/oracle-e2e/test/ercToNative.js b/oracle-e2e/test/ercToNative.js index 8176518b..638d2716 100644 --- a/oracle-e2e/test/ercToNative.js +++ b/oracle-e2e/test/ercToNative.js @@ -1,13 +1,10 @@ -const path = require('path') const Web3 = require('web3') const assert = require('assert') const promiseRetry = require('promise-retry') const { user, ercToNativeBridge, homeRPC, foreignRPC } = require('../../e2e-commons/constants.json') -const { abiPath } = require('../config.json') +const { ERC677_BRIDGE_TOKEN_ABI } = require('../../commons') const { generateNewBlock } = require('../../e2e-commons/utils') -const abisDir = path.join(__dirname, '..', abiPath) - const homeWeb3 = new Web3(new Web3.providers.HttpProvider(homeRPC.URL)) const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(foreignRPC.URL)) @@ -19,8 +16,10 @@ const { toBN } = foreignWeb3.utils homeWeb3.eth.accounts.wallet.add(user.privateKey) foreignWeb3.eth.accounts.wallet.add(user.privateKey) -const tokenAbi = require(path.join(abisDir, 'ERC677BridgeToken.json')).abi -const erc20Token = new foreignWeb3.eth.Contract(tokenAbi, ercToNativeBridge.foreignToken) +const erc20Token = new foreignWeb3.eth.Contract( + ERC677_BRIDGE_TOKEN_ABI, + ercToNativeBridge.foreignToken +) describe('erc to native', () => { it('should convert tokens in foreign to coins in home', async () => { diff --git a/oracle-e2e/test/nativeToErc.js b/oracle-e2e/test/nativeToErc.js index b3007045..28f167d6 100644 --- a/oracle-e2e/test/nativeToErc.js +++ b/oracle-e2e/test/nativeToErc.js @@ -1,4 +1,3 @@ -const path = require('path') const Web3 = require('web3') const assert = require('assert') const promiseRetry = require('promise-retry') @@ -10,10 +9,9 @@ const { homeRPC, foreignRPC } = require('../../e2e-commons/constants.json') -const { abiPath } = require('../config.json') +const { ERC677_BRIDGE_TOKEN_ABI } = require('../../commons') const { generateNewBlock } = require('../../e2e-commons/utils') -const abisDir = path.join(__dirname, '..', abiPath) const homeWeb3 = new Web3(new Web3.providers.HttpProvider(homeRPC.URL)) const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(foreignRPC.URL)) const { toBN } = foreignWeb3.utils @@ -28,8 +26,7 @@ foreignWeb3.eth.accounts.wallet.add(user.privateKey) foreignWeb3.eth.accounts.wallet.add(validator.privateKey) foreignWeb3.eth.accounts.wallet.add(secondUser.privateKey) -const tokenAbi = require(path.join(abisDir, 'ERC677BridgeToken.json')).abi -const token = new foreignWeb3.eth.Contract(tokenAbi, nativeToErcBridge.foreignToken) +const token = new foreignWeb3.eth.Contract(ERC677_BRIDGE_TOKEN_ABI, nativeToErcBridge.foreignToken) const sleep = timeout => new Promise(res => setTimeout(res, timeout))