Skip to content

Commit 0ac30f0

Browse files
Check token balance changes before checking events
1 parent f951880 commit 0ac30f0

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

test/byContract/IexecPoco/04_finalize.test.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ describe('IexecPoco2#finalize', async () => {
338338
const sponsorFrozenBefore = await iexecPoco.frozenOf(sponsor.address);
339339

340340
await expect(iexecPocoAsScheduler.finalize(taskId, results, '0x'))
341-
.to.emit(iexecPoco, 'TaskFinalize')
342341
.to.changeTokenBalances(
343342
iexecPoco,
344343
[requester, sponsor, appProvider, datasetProvider],
@@ -348,7 +347,8 @@ describe('IexecPoco2#finalize', async () => {
348347
appPrice, // app provider is rewarded
349348
0, // but dataset provider is not rewarded
350349
],
351-
);
350+
)
351+
.to.emit(iexecPoco, 'TaskFinalize');
352352
expect(await iexecPoco.frozenOf(requester.address)).to.be.equal(
353353
requesterFrozenBefore - taskPrice,
354354
);
@@ -517,22 +517,18 @@ describe('IexecPoco2#finalize', async () => {
517517
(await iexecPoco.viewTask(kittyFillingDeal.taskId)).finalDeadline,
518518
);
519519
await expect(iexecPoco.claim(kittyFillingDeal.taskId))
520-
.to.emit(iexecPoco, 'Transfer')
521-
.withArgs(iexecPoco.address, kittyAddress, kittyFillingSchedulerTaskStake)
522-
.to.emit(iexecPoco, 'Reward')
523-
.withArgs(kittyAddress, kittyFillingSchedulerTaskStake, kittyFillingDeal.taskId)
524-
.to.emit(iexecPoco, 'Transfer')
525-
.withArgs(kittyAddress, iexecPoco.address, kittyFillingSchedulerTaskStake)
526-
.to.emit(iexecPoco, 'Lock')
527-
.withArgs(kittyAddress, kittyFillingSchedulerTaskStake)
528520
.to.changeTokenBalances(
529521
iexecPoco,
530522
[iexecPoco, kittyAddress],
531523
[
532524
-workerpoolPriceToFillKitty, // deal payer is refunded
533525
0,
534526
],
535-
);
527+
)
528+
.to.emit(iexecPoco, 'Reward')
529+
.withArgs(kittyAddress, kittyFillingSchedulerTaskStake, kittyFillingDeal.taskId)
530+
.to.emit(iexecPoco, 'Lock')
531+
.withArgs(kittyAddress, kittyFillingSchedulerTaskStake);
536532
const kittyFrozenAfterClaim = (await iexecPoco.frozenOf(kittyAddress)).toNumber();
537533
expect(kittyFrozenAfterClaim).to.equal(
538534
kittyFrozenBeforeClaim + kittyFillingSchedulerTaskStake,
@@ -579,6 +575,11 @@ describe('IexecPoco2#finalize', async () => {
579575
.reveal(taskId, resultDigest)
580576
.then((tx) => tx.wait());
581577
await expect(iexecPocoAsScheduler.finalize(taskId, results, '0x'))
578+
.to.changeTokenBalances(
579+
iexecPoco,
580+
[iexecPoco, scheduler, kittyAddress],
581+
[-expectedSchedulerKittyPartReward, expectedSchedulerKittyPartReward, 0],
582+
)
582583
.to.emit(iexecPoco, 'TaskFinalize')
583584
.to.emit(iexecPoco, 'Seize')
584585
.withArgs(kittyAddress, expectedSchedulerKittyPartReward, taskId)
@@ -589,12 +590,7 @@ describe('IexecPoco2#finalize', async () => {
589590
expectedSchedulerKittyPartReward,
590591
)
591592
.to.emit(iexecPoco, 'Reward')
592-
.withArgs(scheduler.address, expectedSchedulerKittyPartReward, taskId)
593-
.to.changeTokenBalances(
594-
iexecPoco,
595-
[iexecPoco, scheduler, kittyAddress],
596-
[-expectedSchedulerKittyPartReward, expectedSchedulerKittyPartReward, 0],
597-
);
593+
.withArgs(scheduler.address, expectedSchedulerKittyPartReward, taskId);
598594
expect(await iexecPoco.frozenOf(kittyAddress)).to.equal(
599595
kittyFrozenAfterClaim - expectedSchedulerKittyPartReward,
600596
);

0 commit comments

Comments
 (0)