Oracle-e2e using Commons (#146)
This commit is contained in:
parent
054225d348
commit
b88dd66cac
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"abiPath": "../contracts/build/contracts"
|
|
||||||
}
|
|
@ -1,13 +1,10 @@
|
|||||||
const path = require('path')
|
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const promiseRetry = require('promise-retry')
|
const promiseRetry = require('promise-retry')
|
||||||
const { user, ercToErcBridge, homeRPC, foreignRPC } = require('../../e2e-commons/constants.json')
|
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 { generateNewBlock } = require('../../e2e-commons/utils')
|
||||||
|
|
||||||
const abisDir = path.join(__dirname, '..', abiPath)
|
|
||||||
|
|
||||||
const homeWeb3 = new Web3(new Web3.providers.HttpProvider(homeRPC.URL))
|
const homeWeb3 = new Web3(new Web3.providers.HttpProvider(homeRPC.URL))
|
||||||
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(foreignRPC.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)
|
homeWeb3.eth.accounts.wallet.add(user.privateKey)
|
||||||
foreignWeb3.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(
|
||||||
const erc20Token = new foreignWeb3.eth.Contract(tokenAbi, ercToErcBridge.foreignToken)
|
ERC677_BRIDGE_TOKEN_ABI,
|
||||||
const erc677Token = new homeWeb3.eth.Contract(tokenAbi, ercToErcBridge.homeToken)
|
ercToErcBridge.foreignToken
|
||||||
|
)
|
||||||
|
const erc677Token = new homeWeb3.eth.Contract(ERC677_BRIDGE_TOKEN_ABI, ercToErcBridge.homeToken)
|
||||||
|
|
||||||
describe('erc to erc', () => {
|
describe('erc to erc', () => {
|
||||||
it('should convert tokens in foreign to tokens in home', async () => {
|
it('should convert tokens in foreign to tokens in home', async () => {
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
const path = require('path')
|
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const promiseRetry = require('promise-retry')
|
const promiseRetry = require('promise-retry')
|
||||||
const { user, ercToNativeBridge, homeRPC, foreignRPC } = require('../../e2e-commons/constants.json')
|
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 { generateNewBlock } = require('../../e2e-commons/utils')
|
||||||
|
|
||||||
const abisDir = path.join(__dirname, '..', abiPath)
|
|
||||||
|
|
||||||
const homeWeb3 = new Web3(new Web3.providers.HttpProvider(homeRPC.URL))
|
const homeWeb3 = new Web3(new Web3.providers.HttpProvider(homeRPC.URL))
|
||||||
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(foreignRPC.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)
|
homeWeb3.eth.accounts.wallet.add(user.privateKey)
|
||||||
foreignWeb3.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(
|
||||||
const erc20Token = new foreignWeb3.eth.Contract(tokenAbi, ercToNativeBridge.foreignToken)
|
ERC677_BRIDGE_TOKEN_ABI,
|
||||||
|
ercToNativeBridge.foreignToken
|
||||||
|
)
|
||||||
|
|
||||||
describe('erc to native', () => {
|
describe('erc to native', () => {
|
||||||
it('should convert tokens in foreign to coins in home', async () => {
|
it('should convert tokens in foreign to coins in home', async () => {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
const path = require('path')
|
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const promiseRetry = require('promise-retry')
|
const promiseRetry = require('promise-retry')
|
||||||
@ -10,10 +9,9 @@ const {
|
|||||||
homeRPC,
|
homeRPC,
|
||||||
foreignRPC
|
foreignRPC
|
||||||
} = require('../../e2e-commons/constants.json')
|
} = require('../../e2e-commons/constants.json')
|
||||||
const { abiPath } = require('../config.json')
|
const { ERC677_BRIDGE_TOKEN_ABI } = require('../../commons')
|
||||||
const { generateNewBlock } = require('../../e2e-commons/utils')
|
const { generateNewBlock } = require('../../e2e-commons/utils')
|
||||||
|
|
||||||
const abisDir = path.join(__dirname, '..', abiPath)
|
|
||||||
const homeWeb3 = new Web3(new Web3.providers.HttpProvider(homeRPC.URL))
|
const homeWeb3 = new Web3(new Web3.providers.HttpProvider(homeRPC.URL))
|
||||||
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(foreignRPC.URL))
|
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(foreignRPC.URL))
|
||||||
const { toBN } = foreignWeb3.utils
|
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(validator.privateKey)
|
||||||
foreignWeb3.eth.accounts.wallet.add(secondUser.privateKey)
|
foreignWeb3.eth.accounts.wallet.add(secondUser.privateKey)
|
||||||
|
|
||||||
const tokenAbi = require(path.join(abisDir, 'ERC677BridgeToken.json')).abi
|
const token = new foreignWeb3.eth.Contract(ERC677_BRIDGE_TOKEN_ABI, nativeToErcBridge.foreignToken)
|
||||||
const token = new foreignWeb3.eth.Contract(tokenAbi, nativeToErcBridge.foreignToken)
|
|
||||||
|
|
||||||
const sleep = timeout => new Promise(res => setTimeout(res, timeout))
|
const sleep = timeout => new Promise(res => setTimeout(res, timeout))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user