From 95a175b8a83836ea5f3e64176b2501e583e6084a Mon Sep 17 00:00:00 2001 From: stubbsta Date: Tue, 29 Jul 2025 09:00:25 +0200 Subject: [PATCH] Add tests for TestStableToken --- test/WakuRlnV2.t.sol | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/WakuRlnV2.t.sol b/test/WakuRlnV2.t.sol index ce02e79..9cf56be 100644 --- a/test/WakuRlnV2.t.sol +++ b/test/WakuRlnV2.t.sol @@ -763,6 +763,39 @@ contract WakuRlnV2Test is Test { } } + function test__TestStableToken__OnlyOwnerCanMint() external { + address nonOwner = vm.addr(1); + uint256 mintAmount = 1000 ether; + + vm.prank(nonOwner); + vm.expectRevert("Only owner can mint"); + token.mint(nonOwner, mintAmount); + } + + function test__TestStableToken__OwnerMintsTransfersAndRegisters() external { + address recipient = vm.addr(2); + uint256 idCommitment = 3; + uint32 membershipRateLimit = w.minMembershipRateLimit(); + (, uint256 price) = w.priceCalculator().calculate(membershipRateLimit); + + // Owner (test contract) mints tokens to recipient + token.mint(recipient, price); + assertEq(token.balanceOf(recipient), price); + + // Recipient uses tokens to register + vm.startPrank(recipient); + token.approve(address(w), price); + w.register(idCommitment, membershipRateLimit, noIdCommitmentsToErase); + vm.stopPrank(); + + // Verify registration succeeded + assertTrue(w.isInMembershipSet(idCommitment)); + (,,,, uint32 fetchedMembershipRateLimit, uint32 index, address holder,) = w.memberships(idCommitment); + assertEq(fetchedMembershipRateLimit, membershipRateLimit); + assertEq(holder, recipient); + assertEq(index, 0); + } + function test__Upgrade() external { address testImpl = address(new WakuRlnV2()); bytes memory data = abi.encodeCall(WakuRlnV2.initialize, (address(0), 100, 1, 10, 10 minutes, 4 minutes));