@@ -61,10 +61,11 @@ contract TestNonFungibleNttManager is Test {
61
61
address nft ,
62
62
IManagerBase.Mode _mode ,
63
63
uint16 _chainId ,
64
- bool shouldInitialize
64
+ bool shouldInitialize ,
65
+ uint8 _tokenIdWidth
65
66
) internal returns (INonFungibleNttManager) {
66
67
NonFungibleNttManager implementation =
67
- new NonFungibleNttManager (address (nft), tokenIdWidth , _mode, _chainId);
68
+ new NonFungibleNttManager (address (nft), _tokenIdWidth , _mode, _chainId);
68
69
69
70
NonFungibleNttManager proxy =
70
71
NonFungibleNttManager (address (new ERC1967Proxy (address (implementation), "" )));
@@ -112,12 +113,15 @@ contract TestNonFungibleNttManager is Test {
112
113
nftTwo = new DummyNftMintAndBurn (bytes ("https://metadata.dn420.com/y/ " ));
113
114
114
115
// Managers.
115
- managerOne =
116
- deployNonFungibleManager (address (nftOne), IManagerBase.Mode.LOCKING, chainIdOne, true );
117
- managerTwo =
118
- deployNonFungibleManager (address (nftTwo), IManagerBase.Mode.BURNING, chainIdTwo, true );
119
- managerThree =
120
- deployNonFungibleManager (address (nftOne), IManagerBase.Mode.BURNING, chainIdThree, true );
116
+ managerOne = deployNonFungibleManager (
117
+ address (nftOne), IManagerBase.Mode.LOCKING, chainIdOne, true , tokenIdWidth
118
+ );
119
+ managerTwo = deployNonFungibleManager (
120
+ address (nftTwo), IManagerBase.Mode.BURNING, chainIdTwo, true , tokenIdWidth
121
+ );
122
+ managerThree = deployNonFungibleManager (
123
+ address (nftOne), IManagerBase.Mode.BURNING, chainIdThree, true , tokenIdWidth
124
+ );
121
125
122
126
// Wormhole Transceivers.
123
127
transceiverOne = deployWormholeTranceiver (address (managerOne));
@@ -215,7 +219,7 @@ contract TestNonFungibleNttManager is Test {
215
219
// Don't initialize.
216
220
vm.prank (owner);
217
221
INonFungibleNttManager dummyManager =
218
- deployNonFungibleManager (address (nftOne), IManagerBase.Mode.LOCKING, chainIdOne, false );
222
+ deployNonFungibleManager (address (nftOne), IManagerBase.Mode.LOCKING, chainIdOne, false , tokenIdWidth );
219
223
220
224
vm.prank (makeAddr ("notOwner " ));
221
225
vm.expectRevert (
@@ -630,6 +634,40 @@ contract TestNonFungibleNttManager is Test {
630
634
);
631
635
}
632
636
637
+ function test_cannotTransferPayloadSizeExceeded () public {
638
+ // Deploy manager with 32 byte tokenIdWidth.
639
+
640
+ INonFungibleNttManager manager = deployNonFungibleManager (
641
+ address (nftOne), IManagerBase.Mode.BURNING, chainIdThree, true , 32
642
+ );
643
+ WormholeTransceiver transceiver = deployWormholeTranceiver (address (manager));
644
+ transceiver.setWormholePeer (chainIdTwo, toWormholeFormat (makeAddr ("random " )));
645
+ manager.setTransceiver (address (transceiver));
646
+ manager.setPeer (chainIdTwo, toWormholeFormat (makeAddr ("random " )));
647
+
648
+
649
+ // Since the NonFungibleNtt payload is currently 178 bytes (without the tokenIds),
650
+ // we should be able to cause the error by transferring with 21 tokenIds.
651
+ // floor((850 - 180) / 33) + 1 (32 bytes per tokenId, 1 byte for length).
652
+ uint256 nftCount = 21 ;
653
+ uint256 startId = 0 ;
654
+
655
+ address recipient = makeAddr ("recipient " );
656
+ uint256 [] memory tokenIds = _mintNftBatch (nftOne, recipient, nftCount, startId);
657
+
658
+ vm.startPrank (recipient);
659
+ nftOne.setApprovalForAll (address (managerOne), true );
660
+
661
+ vm.expectRevert (
662
+ abi.encodeWithSelector (
663
+ IWormholeTransceiver.ExceedsMaxPayloadSize.selector ,
664
+ 873 ,
665
+ transceiver.MAX_PAYLOAD_SIZE ()
666
+ )
667
+ );
668
+ manager.transfer (tokenIds, chainIdTwo, toWormholeFormat (recipient), new bytes (1 ));
669
+ }
670
+
633
671
function test_cannotTransferDuplicateNfts () public {
634
672
uint256 nftCount = 2 ;
635
673
uint256 startId = 0 ;
@@ -1067,4 +1105,3 @@ contract TestNonFungibleNttManager is Test {
1067
1105
1068
1106
// TODO:
1069
1107
// 1) Relayer test
1070
- // 2) Add max payload size and associated tests
0 commit comments