@@ -342,8 +342,11 @@ contract TestRateLimit is Test, IRateLimiterEvents {
342
342
uint256 transferAmount = 3 * 10 ** decimals;
343
343
token.approve (address (nttManager), transferAmount);
344
344
345
- bytes4 selector = bytes4 (keccak256 ("NotEnoughCapacity(uint256,uint256) " ));
346
- vm.expectRevert (abi.encodeWithSelector (selector, outboundLimit, transferAmount));
345
+ vm.expectRevert (
346
+ abi.encodeWithSelector (
347
+ IRateLimiter.NotEnoughCapacity.selector , outboundLimit, transferAmount
348
+ )
349
+ );
347
350
nttManager.transfer (transferAmount, chainId, toWormholeFormat (user_B), false , new bytes (1 ));
348
351
}
349
352
@@ -377,9 +380,12 @@ contract TestRateLimit is Test, IRateLimiterEvents {
377
380
uint256 badTransferAmount = 2 * 10 ** decimals;
378
381
token.approve (address (nttManager), badTransferAmount);
379
382
380
- bytes4 selector = bytes4 (keccak256 ("NotEnoughCapacity(uint256,uint256) " ));
381
383
vm.expectRevert (
382
- abi.encodeWithSelector (selector, newCapacity.untrim (decimals), badTransferAmount)
384
+ abi.encodeWithSelector (
385
+ IRateLimiter.NotEnoughCapacity.selector ,
386
+ newCapacity.untrim (decimals),
387
+ badTransferAmount
388
+ )
383
389
);
384
390
nttManager.transfer (
385
391
badTransferAmount, chainId, toWormholeFormat (user_B), false , new bytes (1 )
@@ -430,9 +436,11 @@ contract TestRateLimit is Test, IRateLimiterEvents {
430
436
vm.warp (durationElapsedTime - 1 );
431
437
432
438
// assert that transfer still can't be completed
433
- bytes4 stillQueuedSelector =
434
- bytes4 (keccak256 ("OutboundQueuedTransferStillQueued(uint64,uint256) " ));
435
- vm.expectRevert (abi.encodeWithSelector (stillQueuedSelector, 0 , initialBlockTimestamp));
439
+ vm.expectRevert (
440
+ abi.encodeWithSelector (
441
+ IRateLimiter.OutboundQueuedTransferStillQueued.selector , 0 , initialBlockTimestamp
442
+ )
443
+ );
436
444
nttManager.completeOutboundQueuedTransfer (0 );
437
445
438
446
// now complete transfer
@@ -441,8 +449,9 @@ contract TestRateLimit is Test, IRateLimiterEvents {
441
449
assertEq (seq, 0 );
442
450
443
451
// now ensure transfer was removed from queue
444
- bytes4 notFoundSelector = bytes4 (keccak256 ("OutboundQueuedTransferNotFound(uint64) " ));
445
- vm.expectRevert (abi.encodeWithSelector (notFoundSelector, 0 ));
452
+ vm.expectRevert (
453
+ abi.encodeWithSelector (IRateLimiter.OutboundQueuedTransferNotFound.selector , 0 )
454
+ );
446
455
nttManager.completeOutboundQueuedTransfer (0 );
447
456
}
448
457
@@ -544,10 +553,12 @@ contract TestRateLimit is Test, IRateLimiterEvents {
544
553
545
554
{
546
555
// assert that transfer still can't be completed
547
- bytes4 stillQueuedSelector =
548
- bytes4 (keccak256 ("InboundQueuedTransferStillQueued(bytes32,uint256) " ));
549
556
vm.expectRevert (
550
- abi.encodeWithSelector (stillQueuedSelector, digest, initialBlockTimestamp)
557
+ abi.encodeWithSelector (
558
+ IRateLimiter.InboundQueuedTransferStillQueued.selector ,
559
+ digest,
560
+ initialBlockTimestamp
561
+ )
551
562
);
552
563
nttManager.completeInboundQueuedTransfer (digest);
553
564
}
@@ -558,8 +569,9 @@ contract TestRateLimit is Test, IRateLimiterEvents {
558
569
559
570
{
560
571
// assert transfer no longer in queue
561
- bytes4 notQueuedSelector = bytes4 (keccak256 ("InboundQueuedTransferNotFound(bytes32) " ));
562
- vm.expectRevert (abi.encodeWithSelector (notQueuedSelector, digest));
572
+ vm.expectRevert (
573
+ abi.encodeWithSelector (IRateLimiter.InboundQueuedTransferNotFound.selector , digest)
574
+ );
563
575
nttManager.completeInboundQueuedTransfer (digest);
564
576
}
565
577
@@ -738,20 +750,15 @@ contract TestRateLimit is Test, IRateLimiterEvents {
738
750
bytes memory encodedSignature ,
739
751
string memory expectedRevert
740
752
) internal {
741
- (bool success , bytes memory result ) = contractAddress.call (
742
- encodedSignature
743
- );
753
+ (bool success , bytes memory result ) = contractAddress.call (encodedSignature);
744
754
require (! success, "call did not revert " );
745
755
746
756
console.log ("result: %s " , result.length );
747
757
// // compare revert strings
748
758
bytes32 expectedRevertHash = keccak256 (abi.encode (expectedRevert));
749
759
(bytes memory res ,) = result.slice (4 , result.length - 4 );
750
760
bytes32 actualRevertHash = keccak256 (abi.encodePacked (res));
751
- require (
752
- expectedRevertHash == actualRevertHash,
753
- "call did not revert as expected "
754
- );
761
+ require (expectedRevertHash == actualRevertHash, "call did not revert as expected " );
755
762
}
756
763
757
764
// transfer tokens from user_A to user_B
@@ -948,9 +955,11 @@ contract TestRateLimit is Test, IRateLimiterEvents {
948
955
vm.warp (durationElapsedTime - 1 );
949
956
950
957
// assert that transfer still can't be completed
951
- bytes4 stillQueuedSelector =
952
- bytes4 (keccak256 ("OutboundQueuedTransferStillQueued(uint64,uint256) " ));
953
- vm.expectRevert (abi.encodeWithSelector (stillQueuedSelector, 0 , initialBlockTimestamp));
958
+ vm.expectRevert (
959
+ abi.encodeWithSelector (
960
+ IRateLimiter.OutboundQueuedTransferStillQueued.selector , 0 , initialBlockTimestamp
961
+ )
962
+ );
954
963
nttManager.completeOutboundQueuedTransfer (0 );
955
964
956
965
// now complete transfer
@@ -959,8 +968,9 @@ contract TestRateLimit is Test, IRateLimiterEvents {
959
968
assertEq (seq, 0 );
960
969
961
970
// now ensure transfer was removed from queue
962
- bytes4 notFoundSelector = bytes4 (keccak256 ("OutboundQueuedTransferNotFound(uint64) " ));
963
- vm.expectRevert (abi.encodeWithSelector (notFoundSelector, 0 ));
971
+ vm.expectRevert (
972
+ abi.encodeWithSelector (IRateLimiter.OutboundQueuedTransferNotFound.selector , 0 )
973
+ );
964
974
nttManager.completeOutboundQueuedTransfer (0 );
965
975
}
966
976
@@ -1027,10 +1037,12 @@ contract TestRateLimit is Test, IRateLimiterEvents {
1027
1037
1028
1038
{
1029
1039
// assert that transfer still can't be completed
1030
- bytes4 stillQueuedSelector =
1031
- bytes4 (keccak256 ("InboundQueuedTransferStillQueued(bytes32,uint256) " ));
1032
1040
vm.expectRevert (
1033
- abi.encodeWithSelector (stillQueuedSelector, digest, initialBlockTimestamp)
1041
+ abi.encodeWithSelector (
1042
+ IRateLimiter.InboundQueuedTransferStillQueued.selector ,
1043
+ digest,
1044
+ initialBlockTimestamp
1045
+ )
1034
1046
);
1035
1047
nttManager.completeInboundQueuedTransfer (digest);
1036
1048
}
@@ -1041,8 +1053,9 @@ contract TestRateLimit is Test, IRateLimiterEvents {
1041
1053
1042
1054
{
1043
1055
// assert transfer no longer in queue
1044
- bytes4 notQueuedSelector = bytes4 (keccak256 ("InboundQueuedTransferNotFound(bytes32) " ));
1045
- vm.expectRevert (abi.encodeWithSelector (notQueuedSelector, digest));
1056
+ vm.expectRevert (
1057
+ abi.encodeWithSelector (IRateLimiter.InboundQueuedTransferNotFound.selector , digest)
1058
+ );
1046
1059
nttManager.completeInboundQueuedTransfer (digest);
1047
1060
}
1048
1061
0 commit comments