Compare commits

...

2 Commits

Author SHA1 Message Date
Kirill Fedoseev
5490b8b029 Drop duplicated UserRequestForSignature events in monitor 2021-05-19 14:48:42 +03:00
Kirill Fedoseev
3f93fef016 Add oracle e2e test for requestMessageReconfirm 2021-05-17 19:46:29 +03:00
3 changed files with 83 additions and 1 deletions

@ -1 +1 @@
Subproject commit 004d466a3d593e6304e52c74e6c3e801b6a33b32 Subproject commit c2575aa268734ab6bd03955c6545bd634516e262

@ -101,6 +101,21 @@ async function main(mode) {
chain: 'home' chain: 'home'
})).map(normalizeEvent) })).map(normalizeEvent)
homeToForeignRequests = [...homeToForeignRequests, ...homeToForeignRequestsNew] 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')") logger.debug("calling foreignBridge.getPastEvents('RelayedMessage')")
const homeToForeignConfirmations = (await getPastEvents(foreignBridge, { const homeToForeignConfirmations = (await getPastEvents(foreignBridge, {

@ -140,6 +140,73 @@ describe('arbitrary message bridging', () => {
const value = await foreignBox.methods.value().call() const value = await foreignBox.methods.value().call()
assert(!toBN(value).eq(toBN(newValue)), 'Message should not be relayed by oracle automatically') 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 () => { it('should confirm but not relay message from manual lane', async () => {