@@ -733,8 +733,8 @@ contract TestRateLimit is Test, IRateLimiterEvents {
733
733
// send tokens from user_A to user_B
734
734
// this should consume capacity on the outbound side
735
735
// 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));
738
738
transferAmt = uint64 (bound (transferAmt, 1 , mintAmt - 1 ));
739
739
740
740
(address user_A , address user_B , DummyToken token , uint8 decimals ) = setupToken ();
@@ -746,8 +746,45 @@ contract TestRateLimit is Test, IRateLimiterEvents {
746
746
// transfer 10 tokens
747
747
vm.startPrank (user_A);
748
748
749
- TrimmedAmount memory transferAmount = TrimmedAmount (transferAmt, 8 );
749
+ // TrimmedAmount memory transferAmount = TrimmedAmount(transferAmt, 8);
750
750
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
+
751
788
// transfer tokens from user_A -> user_B via the nttManager
752
789
nttManager.transfer (
753
790
transferAmount.untrim (decimals), chainId, toWormholeFormat (user_B), false , new bytes (1 )
0 commit comments