Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add oracle e2e test for requestMessageReconfirm #574

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts
15 changes: 15 additions & 0 deletions monitor/utils/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ async function main(mode) {
chain: 'home'
})).map(normalizeEvent)
homeToForeignRequests = [...homeToForeignRequests, ...homeToForeignRequestsNew]
if (bridgeMode === BRIDGE_MODES.ARBITRARY_MESSAGE) {
const used = {}
const total = homeToForeignRequests.length
const onlyFirstUniqueFilter = e => {
const msgId = e.returnValues.messageId || e.transactionHash
if (used[msgId]) {
return false
}
used[msgId] = true
return true
}
homeToForeignRequests = homeToForeignRequests.filter(onlyFirstUniqueFilter)
const dropped = total - homeToForeignRequests.length
logger.debug(`Dropped ${dropped}/${total} UserRequestForSignature events with same message id`)
}

logger.debug("calling foreignBridge.getPastEvents('RelayedMessage')")
const homeToForeignConfirmations = (await getPastEvents(foreignBridge, {
Expand Down
67 changes: 67 additions & 0 deletions oracle-e2e/test/amb.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,73 @@ describe('arbitrary message bridging', () => {
const value = await foreignBox.methods.value().call()
assert(!toBN(value).eq(toBN(newValue)), 'Message should not be relayed by oracle automatically')
})

it('should reconfirm message in case of validators change', async () => {
const newValue = 15

const initialValue = await foreignBox.methods.value().call()
assert(!toBN(initialValue).eq(toBN(newValue)), 'initial value should be different from new value')

const signatures = await homeBridge.getPastEvents('SignedForUserRequest', {
fromBlock: 0,
toBlock: 'latest'
})

const { events } = await homeBox.methods
.setValueOnOtherNetworkUsingManualLane(newValue, amb.home, amb.foreignBox)
.send()
.catch(e => {
console.error(e)
})
const message = homeWeb3.eth.abi.decodeParameter('bytes', events['0'].raw.data)

await delay(10000)

await setRequiredSignatures({
bridgeContract: homeBridge,
web3: homeWeb3,
requiredSignatures: 3,
options: {
from: validator.address,
gas: '4000000'
}
})

const signatures2 = await homeBridge.getPastEvents('SignedForUserRequest', {
fromBlock: 0,
toBlock: 'latest'
})

assert(
signatures2.length === signatures.length + requiredSignatures,
`Incorrect amount of signatures submitted, got ${signatures2.length}, expected ${signatures.length +
requiredSignatures}`
)

await homeBridge.methods.requestMessageReconfirm(message).send()

await delay(10000)

const signatures3 = await homeBridge.getPastEvents('SignedForUserRequest', {
fromBlock: 0,
toBlock: 'latest'
})

assert(
signatures3.length === signatures.length + 3,
`Incorrect amount of signatures submitted, got ${signatures3.length}, expected ${signatures.length + 3}`
)

await setRequiredSignatures({
bridgeContract: homeBridge,
web3: homeWeb3,
requiredSignatures: 2,
options: {
from: validator.address,
gas: '4000000'
}
})
})
}

it('should confirm but not relay message from manual lane', async () => {
Expand Down