Add tests for TestStableToken

This commit is contained in:
stubbsta 2025-07-29 09:00:25 +02:00
parent e39e8f4886
commit 95a175b8a8
No known key found for this signature in database

View File

@ -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));