Skip to content

Commit def0d87

Browse files
author
Rahul Maganti
committed
evm: change the inputs to the circular backflow tests to uint256
1 parent 99aa075 commit def0d87

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

evm/test/RateLimit.t.sol

+40-3
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,8 @@ contract TestRateLimit is Test, IRateLimiterEvents {
733733
// send tokens from user_A to user_B
734734
// this should consume capacity on the outbound side
735735
// and backfill the inbound side
736-
function testFuzz_CircularFlowBackFilling(uint64 mintAmt, uint64 transferAmt) public {
737-
mintAmt = uint64(bound(mintAmt, 2, type(uint64).max));
736+
function testFuzz_CircularFlowBackFilling(uint64 mintAmt, uint256 transferAmt) public {
737+
mintAmt = uint64(bound(mintAmt, 2, type(uint256).max));
738738
transferAmt = uint64(bound(transferAmt, 1, mintAmt - 1));
739739

740740
(address user_A, address user_B, DummyToken token, uint8 decimals) = setupToken();
@@ -746,8 +746,45 @@ contract TestRateLimit is Test, IRateLimiterEvents {
746746
// transfer 10 tokens
747747
vm.startPrank(user_A);
748748

749-
TrimmedAmount memory transferAmount = TrimmedAmount(transferAmt, 8);
749+
// TrimmedAmount memory transferAmount = TrimmedAmount(transferAmt, 8);
750750
token.approve(address(nttManager), type(uint256).max);
751+
752+
// TODO: also fuzz the fromDecimals?
753+
754+
// allow for amounts greater than uint64 to check if [`transfer`] reverts
755+
// on amounts greater than u64 MAX.
756+
TrimmedAmount memory transferAmount = transferAmt.trim(decimals, 8);
757+
758+
// check error conditions
759+
if (transferAmount.amount == 0) {
760+
vm.expectRevert();
761+
// transfer tokens from user_A -> user_B via the nttManager
762+
nttManager.transfer(
763+
transferAmount.untrim(decimals),
764+
chainId,
765+
toWormholeFormat(user_B),
766+
false,
767+
new bytes(1)
768+
);
769+
770+
return;
771+
}
772+
773+
if (transferAmount.amount > type(uint64).max) {
774+
bytes4 selector = bytes4(keccak256("AmountTooLarge(uint256)"));
775+
vm.expectRevert(abi.encodeWithSelector(selector, transferAmt));
776+
777+
nttManager.transfer(
778+
transferAmount.untrim(decimals),
779+
chainId,
780+
toWormholeFormat(user_B),
781+
false,
782+
new bytes(1)
783+
);
784+
785+
return;
786+
}
787+
751788
// transfer tokens from user_A -> user_B via the nttManager
752789
nttManager.transfer(
753790
transferAmount.untrim(decimals), chainId, toWormholeFormat(user_B), false, new bytes(1)

0 commit comments

Comments
 (0)