Skip to content

Commit

Permalink
Update contract's submodule and e2e tests (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
patitonar committed Apr 24, 2020
1 parent c8c5895 commit 64c5a56
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 312 deletions.
2 changes: 1 addition & 1 deletion contracts
2 changes: 1 addition & 1 deletion e2e-commons/contracts-envs/erc-to-native.env
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ FOREIGN_GAS_PRICE=10000000000
FOREIGN_REWARDABLE=false

BLOCK_REWARD_ADDRESS=0xF9698Eb93702dfdd0e2d802088d4c21822a8A977
ERC20_TOKEN_ADDRESS=0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359
ERC20_TOKEN_ADDRESS=0x7cc4b1851c35959d34e635a470f6b5c43ba3c9c9

REQUIRED_NUMBER_OF_VALIDATORS=1
VALIDATORS="0xaaB52d66283F7A1D5978bcFcB55721ACB467384b 0xdCC784657C78054aa61FbcFFd2605F32374816A4 0xDcef88209a20D52165230104B245803C3269454d"
55 changes: 10 additions & 45 deletions monitor-e2e/test/ercToNative.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ const {
addValidator,
initializeChaiToken,
convertDaiToChai,
setMinDaiTokenBalance,
migrateToMCD
setMinDaiTokenBalance
} = require('../utils')

const baseUrl = ercToNativeBridge.monitor
Expand All @@ -34,43 +33,12 @@ describe('ERC TO NATIVE with changing state of contracts', () => {

it('should change balanceDiff', async function() {
this.timeout(60000)
await sendTokens(foreignRPC.URL, user, ercToNativeBridge.halfDuplexToken, ercToNativeBridge.foreign)

await waitUntil(async () => {
;({ data } = await axios.get(`${baseUrl}`))
const { erc20Balance, halfDuplexErc20Balance, investedErc20Balance } = data.foreign
return (
data.balanceDiff === 0.01 &&
erc20Balance === '0.01' &&
halfDuplexErc20Balance === undefined &&
investedErc20Balance === undefined
)
})

await migrateToMCD(foreignRPC.URL, ercToNativeBridge.foreign)

await waitUntil(async () => {
;({ data } = await axios.get(`${baseUrl}`))
const { erc20Balance, halfDuplexErc20Balance, investedErc20Balance } = data.foreign
return (
data.balanceDiff === 0.01 &&
erc20Balance === '0.01' &&
halfDuplexErc20Balance === '0' &&
investedErc20Balance === undefined
)
})

await sendTokens(foreignRPC.URL, user, ercToNativeBridge.halfDuplexToken, ercToNativeBridge.foreign)
await sendTokens(foreignRPC.URL, user, ercToNativeBridge.foreignToken, ercToNativeBridge.foreign)

await waitUntil(async () => {
;({ data } = await axios.get(`${baseUrl}`))
const { erc20Balance, halfDuplexErc20Balance, investedErc20Balance } = data.foreign
return (
data.balanceDiff === 0.02 &&
erc20Balance === '0.01' &&
halfDuplexErc20Balance === '0.01' &&
investedErc20Balance === undefined
)
const { erc20Balance, investedErc20Balance } = data.foreign
return data.balanceDiff === 0.01 && erc20Balance === '0.01' && investedErc20Balance === undefined
})
})

Expand All @@ -89,11 +57,10 @@ describe('ERC TO NATIVE with changing state of contracts', () => {

await waitUntil(async () => {
;({ data } = await axios.get(`${baseUrl}`))
const { erc20Balance, halfDuplexErc20Balance, investedErc20Balance, accumulatedInterest } = data.foreign
const { erc20Balance, investedErc20Balance, accumulatedInterest } = data.foreign
return (
data.balanceDiff === 0.03 &&
data.balanceDiff === 0.02 &&
erc20Balance === '0.02' &&
halfDuplexErc20Balance === '0.01' &&
investedErc20Balance === '0' &&
accumulatedInterest === '0.001' // value of dsrBalance() is initially defined in genesis block as 0.001
)
Expand All @@ -104,11 +71,10 @@ describe('ERC TO NATIVE with changing state of contracts', () => {

await waitUntil(async () => {
;({ data } = await axios.get(`${baseUrl}`))
const { erc20Balance, halfDuplexErc20Balance, investedErc20Balance, accumulatedInterest } = data.foreign
const { erc20Balance, investedErc20Balance, accumulatedInterest } = data.foreign
return (
data.balanceDiff === 0.03 &&
data.balanceDiff === 0.02 &&
erc20Balance === '0.01' &&
halfDuplexErc20Balance === '0.01' &&
investedErc20Balance === '0.01' &&
accumulatedInterest === '0.001'
)
Expand All @@ -119,11 +85,10 @@ describe('ERC TO NATIVE with changing state of contracts', () => {

await waitUntil(async () => {
;({ data } = await axios.get(`${baseUrl}`))
const { erc20Balance, halfDuplexErc20Balance, investedErc20Balance, accumulatedInterest } = data.foreign
const { erc20Balance, investedErc20Balance, accumulatedInterest } = data.foreign
return (
data.balanceDiff === 0.03 &&
data.balanceDiff === 0.02 &&
erc20Balance === '0.005' &&
halfDuplexErc20Balance === '0.01' &&
investedErc20Balance === '0.015' &&
accumulatedInterest === '0.001'
)
Expand Down
11 changes: 0 additions & 11 deletions monitor-e2e/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ const addValidator = async (rpcUrl, account, bridgeAddress) => {
})
}

const migrateToMCD = async (rpcUrl, bridgeAddress) => {
const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl))
web3.eth.accounts.wallet.add(validator.privateKey)
const bridgeContract = new web3.eth.Contract(FOREIGN_ERC_TO_NATIVE_ABI, bridgeAddress)
await bridgeContract.methods.migrateToMCD().send({
from: validator.address,
gas: '4000000'
})
}

const initializeChaiToken = async (rpcUrl, bridgeAddress) => {
const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl))
web3.eth.accounts.wallet.add(validator.privateKey)
Expand Down Expand Up @@ -116,7 +106,6 @@ module.exports = {
sendTokens,
addValidator,
sendAMBMessage,
migrateToMCD,
initializeChaiToken,
setMinDaiTokenBalance,
convertDaiToChai
Expand Down
Loading

0 comments on commit 64c5a56

Please sign in to comment.