diff --git a/contracts/WakuRlnRegistry.sol b/contracts/WakuRlnRegistry.sol index cfb9aea..6960d2b 100644 --- a/contracts/WakuRlnRegistry.sol +++ b/contracts/WakuRlnRegistry.sol @@ -81,6 +81,7 @@ contract WakuRlnRegistry is Ownable { } function forceProgress() external onlyOwner onlyUsableStorage { + if (storages[usingStorageIndex + 1] == address(0)) revert NoStorageContractAvailable(); usingStorageIndex += 1; } } diff --git a/deploy/003_deploy_rln.ts b/deploy/003_deploy_rln.ts index e3c2f88..b3416cb 100644 --- a/deploy/003_deploy_rln.ts +++ b/deploy/003_deploy_rln.ts @@ -37,7 +37,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { solcInput: extendedArtifact.solcInput, devdoc: extendedArtifact.devdoc, }; - console.log(d); deployments.save(`WakuRlnStorage_${indexOfStorageToBeDeployed}`, d); }; diff --git a/test/WakuRlnRegistry.t.sol b/test/WakuRlnRegistry.t.sol index 4b3cb09..86e76b8 100644 --- a/test/WakuRlnRegistry.t.sol +++ b/test/WakuRlnRegistry.t.sol @@ -52,9 +52,11 @@ contract WakuRlnRegistryTest is Test { } function test__forceProgression() public { + wakuRlnRegistry.newStorage(); wakuRlnRegistry.newStorage(); wakuRlnRegistry.forceProgress(); - require(wakuRlnRegistry.usingStorageIndex() == 1); + assertEq(wakuRlnRegistry.usingStorageIndex(), 1); + assertEq(wakuRlnRegistry.nextStorageIndex(), 2); } function test__SingleRegistration(uint256 commitment) public { @@ -105,4 +107,11 @@ contract WakuRlnRegistryTest is Test { vm.expectRevert(NoStorageContractAvailable.selector); wakuRlnRegistry.register(commitments); } + + function test__forceProgression__NoStorageContract() public { + vm.expectRevert(NoStorageContractAvailable.selector); + wakuRlnRegistry.forceProgress(); + assertEq(wakuRlnRegistry.usingStorageIndex(), 0); + assertEq(wakuRlnRegistry.nextStorageIndex(), 0); + } }