Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhe8x committed Nov 1, 2024
1 parent 65fee20 commit a9a5319
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions test/RewardsBooster_migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,8 @@ describe('RewardsBooster Contract', () => {
expect(evts.length).to.eq(2);
// 3 block passed (upgrade, migrateDeploymentBoost, collectAllocationReward) since we queried alReward0,
// and 1 of them counts on old rewards, so we should get 500.5 SQT * 103 (availabe secs) / 1003 (total secs) = 51.397308075772681954
// sometimes the test takes longer than 3 sec for 3 blocks, so result may become 51844
expect(evts[0].amount.div((1e15).toString()).toString()).to.be.oneOf(['51397', '51844']);
// sometimes the test takes longer than 3 sec for 3 blocks, so result may become 52291
expect(evts[0].amount.div((1e15).toString()).toString()).to.be.within(51397, 52291);
// 1 block(collectAllocationReward) passed for new reward pool, so we should get 1.25 SQT more
expect(evts[1].amount).to.lt(etherParse('1.25'));
await blockTravel(999);
Expand Down
10 changes: 6 additions & 4 deletions test/StateChannel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ describe('StateChannel Contract', () => {
// reward distribution should be skipped due to total stake is 0
tx = await rewardsHelper.connect(runner).indexerCatchup(runner.address);
evt = await eventFrom(tx, rewardsDistributor, 'DistributeRewards(address,uint256,uint256,uint256)');
expect(evt).to.be.undefined;
expect(evt.rewards).to.eq(0);
});

/**
Expand Down Expand Up @@ -695,16 +695,18 @@ describe('StateChannel Contract', () => {
await stateChannel.claim(channelId);
balanceAfter = await token.balanceOf(consumer.address);
expect(balanceBefore.sub(balanceAfter)).to.eq(etherParse('0.4'));
let evt = await eventFrom(tx, stateChannel, 'ChannelLabor2(uint256,bytes32,address,uint256)');
const evt = await eventFrom(tx, stateChannel, 'ChannelLabor2(uint256,bytes32,address,uint256)');
expect(evt.amount).to.be.eq(etherParse('0.4'));

// start new era so we can try collect the channel reward
await startNewEra(eraManager);

// reward distribution should be skipped due to total stake is 0
tx = await rewardsHelper.connect(runner).indexerCatchup(runner.address);
evt = await eventFrom(tx, rewardsDistributor, 'DistributeRewards(address,uint256,uint256,uint256)');
expect(evt.rewards).to.eq(etherParse('0.4'));
const evts = await eventsFrom(tx, rewardsDistributor, 'DistributeRewards(address,uint256,uint256,uint256)');
expect(evts.length).to.eq(2);
expect(evts[0].rewards).to.eq(0);
expect(evts[1].rewards).to.eq(etherParse('0.4'));

// delegator
const delegatorRewards = await rewardsDistributor.userRewards(runner.address, delegator.address);
Expand Down

0 comments on commit a9a5319

Please sign in to comment.