Skip to content

Commit 50aebe4

Browse files
author
Julien Heller
committed
Remove isReplay requirement to turn off Cyan Audit and process actions inside database transaction
1 parent f59eb4c commit 50aebe4

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

src/MassiveActionHandler.test.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -193,31 +193,14 @@ describe('TestMassiveActionHandler', () => {
193193
actionReader.getLastIrreversibleBlockNumber = jest.fn().mockReturnValue(2)
194194
const nextBlock = await actionReader.getNextBlock()
195195
expect(nextBlock.lastIrreversibleBlockNumber).toEqual(2)
196-
await actionHandler.handleBlock(nextBlock, true)
196+
await actionHandler.handleBlock(nextBlock, false)
197197

198198
const nextBlock2 = await actionReader.getNextBlock()
199-
await actionHandler.handleBlock(nextBlock2, true)
199+
await actionHandler.handleBlock(nextBlock2, false)
200200
let result = await massiveInstance.query('select cyanaudit.fn_get_is_enabled();')
201201
expect(result[0].fn_get_is_enabled).toBe(false)
202202
expect(actionHandler._getCyanAuditStatus()).toEqual(false)
203203

204-
const nextBlock3 = await actionReader.getNextBlock()
205-
await actionHandler.handleBlock(nextBlock3, true)
206-
result = await massiveInstance.query('select cyanaudit.fn_get_is_enabled();')
207-
expect(result[0].fn_get_is_enabled).toBe(true)
208-
expect(actionHandler._getCyanAuditStatus()).toEqual(true)
209-
})
210-
211-
it('with Cyan Audit on if isReplay is false', async () => {
212-
actionReader.getLastIrreversibleBlockNumber = jest.fn().mockReturnValue(2)
213-
const nextBlock = await actionReader.getNextBlock()
214-
await actionHandler.handleBlock(nextBlock, false)
215-
const nextBlock2 = await actionReader.getNextBlock()
216-
await actionHandler.handleBlock(nextBlock2, false)
217-
let result = await massiveInstance.query('select cyanaudit.fn_get_is_enabled();')
218-
expect(result[0].fn_get_is_enabled).toBe(true)
219-
expect(actionHandler._getCyanAuditStatus()).toEqual(true)
220-
221204
const nextBlock3 = await actionReader.getNextBlock()
222205
await actionHandler.handleBlock(nextBlock3, false)
223206
result = await massiveInstance.query('select cyanaudit.fn_get_is_enabled();')
@@ -229,11 +212,11 @@ describe('TestMassiveActionHandler', () => {
229212
actionReader.getLastIrreversibleBlockNumber = jest.fn().mockReturnValue(2)
230213
const nextBlock = await actionReader.getNextBlock()
231214
expect(nextBlock.lastIrreversibleBlockNumber).toEqual(2)
232-
await actionHandler.handleBlock(nextBlock, true)
215+
await actionHandler.handleBlock(nextBlock, false)
233216
const nextBlock2 = await actionReader.getNextBlock()
234-
await actionHandler.handleBlock(nextBlock2, true)
217+
await actionHandler.handleBlock(nextBlock2, false)
235218
const nextBlock3 = await actionReader.getNextBlock()
236-
await actionHandler.handleBlock(nextBlock3, true)
219+
await actionHandler.handleBlock(nextBlock3, false)
237220
const result = await massiveInstance.query('select cyanaudit.fn_get_is_enabled();')
238221
expect(result[0].fn_get_is_enabled).toBe(true)
239222
expect(actionHandler._getCyanAuditStatus()).toEqual(true)

src/MassiveActionHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ export class MassiveActionHandler extends AbstractActionHandler {
118118

119119
protected async handleWithState(handle: (state: any, context?: any) => void): Promise<void> {
120120
const indexState = await this.loadIndexState()
121-
const { isReplay, lastIrreversibleBlockNumber, blockNumber } = indexState
122-
if (isReplay && blockNumber < lastIrreversibleBlockNumber) {
121+
const { lastIrreversibleBlockNumber, blockNumber } = indexState
122+
if ( blockNumber < lastIrreversibleBlockNumber) {
123123
await this.turnOffCyanAudit()
124124
try {
125125
const db = this.schemaInstance

0 commit comments

Comments
 (0)