diff --git a/src/Redistribution.sol b/src/Redistribution.sol index 0e17cb71..3efdef56 100644 --- a/src/Redistribution.sol +++ b/src/Redistribution.sol @@ -801,11 +801,17 @@ contract Redistribution is AccessControl, Pausable { * @param _depth The storage depth the applicant intends to report. */ function isParticipatingInUpcomingRound(address _owner, uint8 _depth) public view returns (bool) { + uint256 _lastUpdate = Stakes.lastUpdatedBlockNumberOfAddress(_owner); + if (currentPhaseReveal()) { revert WrongPhase(); } - if (Stakes.lastUpdatedBlockNumberOfAddress(_owner) >= block.number - 2 * ROUND_LENGTH) { + if (_lastUpdate == 0) { + revert NotStaked(); + } + + if (_lastUpdate >= block.number - 2 * ROUND_LENGTH) { revert MustStake2Rounds(); } diff --git a/test/Redistribution.test.ts b/test/Redistribution.test.ts index 5f21c47a..0916695f 100644 --- a/test/Redistribution.test.ts +++ b/test/Redistribution.test.ts @@ -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);