Skip to content

Commit

Permalink
added test and also more precise error reason for isParticipating
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCardinalError committed Sep 9, 2024
1 parent 4227c13 commit 70407e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Redistribution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,11 @@ contract Redistribution is AccessControl, Pausable {
revert WrongPhase();
}

if (_lastUpdate >= block.number - 2 * ROUND_LENGTH || _lastUpdate == 0) {
if (_lastUpdate == 0) {
revert NotStaked();
}

if (_lastUpdate >= block.number - 2 * ROUND_LENGTH) {
revert MustStake2Rounds();
}

Expand Down
10 changes: 10 additions & 0 deletions test/Redistribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ describe('Redistribution', function () {
await expect(r_node_0.commit(obfuscatedHash_0, currentRound)).to.be.revertedWith(errors.commit.notStaked);
});

it('should not participation with unstaked node', async function () {
expect(await redistribution.currentPhaseCommit()).to.be.true;

const r_node_0 = await ethers.getContract('Redistribution', node_0);
const currentRound = await r_node_0.currentRound();
await expect(r_node_0['isParticipatingInUpcomingRound(address,uint8)'](node_0, depth_0)).to.be.revertedWith(
errors.commit.notStaked
);
});

it('should not create a commit with recently staked node', async function () {
const sr_node_0 = await ethers.getContract('StakeRegistry', node_0);
await mintAndApprove(deployer, node_0, sr_node_0.address, stakeAmount_0);
Expand Down

0 comments on commit 70407e6

Please sign in to comment.