tokenbridge/monitor/eventsStats.js
Gerardo Nardelli 1564ccc580 Support alternative receiver feature in Monitor (#223)
* Update monitor to support changes from alternative receiver
* Add monitor event processing unit tests
* update chrome version used en e2e tests
* update chromedriver version
2019-10-29 22:22:02 +03:00

53 lines
1.8 KiB
JavaScript

require('dotenv').config()
const eventsInfo = require('./utils/events')
const { processedMsgNotDelivered, deliveredMsgNotProcessed, eventWithoutReference } = require('./utils/message')
const { BRIDGE_MODES } = require('../commons')
async function main() {
const {
homeToForeignRequests,
homeToForeignConfirmations,
foreignToHomeConfirmations,
foreignToHomeRequests,
bridgeMode
} = await eventsInfo()
if (bridgeMode === BRIDGE_MODES.ARBITRARY_MESSAGE) {
return {
home: {
deliveredMsgNotProcessedInForeign: homeToForeignRequests.filter(
deliveredMsgNotProcessed(homeToForeignConfirmations)
),
processedMsgNotDeliveredInForeign: foreignToHomeConfirmations.filter(
processedMsgNotDelivered(foreignToHomeRequests)
)
},
foreign: {
deliveredMsgNotProcessedInHome: foreignToHomeRequests.filter(
deliveredMsgNotProcessed(foreignToHomeConfirmations)
),
processedMsgNotDeliveredInHome: homeToForeignConfirmations.filter(
processedMsgNotDelivered(homeToForeignRequests)
)
},
lastChecked: Math.floor(Date.now() / 1000)
}
} else {
const onlyInHomeDeposits = homeToForeignRequests.filter(eventWithoutReference(homeToForeignConfirmations))
const onlyInForeignDeposits = homeToForeignConfirmations.filter(eventWithoutReference(homeToForeignRequests))
const onlyInHomeWithdrawals = foreignToHomeConfirmations.filter(eventWithoutReference(foreignToHomeRequests))
const onlyInForeignWithdrawals = foreignToHomeRequests.filter(eventWithoutReference(foreignToHomeConfirmations))
return {
onlyInHomeDeposits,
onlyInForeignDeposits,
onlyInHomeWithdrawals,
onlyInForeignWithdrawals,
lastChecked: Math.floor(Date.now() / 1000)
}
}
}
module.exports = main