Skip to content

Commit fa67310

Browse files
authored
Added changing royalty information perf test (#269)
1 parent fe4735c commit fa67310

File tree

4 files changed

+97
-3
lines changed

4 files changed

+97
-3
lines changed

perfTest/token/erc721/ERC721Perf.t.sol

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,100 @@ abstract contract ERC721PerfTest is ERC721BaseTest {
320320
emit log_named_uint("totalSupply gas", gasStart - gasEnd);
321321
}
322322

323+
324+
function testSetNFTRoyaltyReceiverBatch1() public {
325+
emit log("Scenario: NFTs 10, different receiver and fee");
326+
uint256 scenarioCount = 10;
327+
uint96 newFeeNumerator = 100;
328+
address newRoyaltyReceiver = makeAddr("newRoyaltyReceiver");
329+
330+
// Have a new fee receiver and different feeNumerator
331+
assertNotEq(newFeeNumerator, feeNumerator, "Fee numerator should be different");
332+
assertNotEq(newRoyaltyReceiver, feeReceiver, "newRoyaltyReceiver should be different");
333+
334+
checkSetNFTRoyaltyReceiverBatch(newRoyaltyReceiver, newFeeNumerator, scenarioCount);
335+
}
336+
337+
function testSetNFTRoyaltyReceiverBatch2() public {
338+
emit log("Scenario: NFTs 100, different receiver and fee");
339+
uint256 scenarioCount = 100;
340+
uint96 newFeeNumerator = 100;
341+
address newRoyaltyReceiver = makeAddr("newRoyaltyReceiver");
342+
343+
// Have a new fee receiver and different feeNumerator
344+
assertNotEq(newFeeNumerator, feeNumerator, "Fee numerator should be different");
345+
assertNotEq(newRoyaltyReceiver, feeReceiver, "newRoyaltyReceiver should be different");
346+
347+
checkSetNFTRoyaltyReceiverBatch(newRoyaltyReceiver, newFeeNumerator, scenarioCount);
348+
}
349+
350+
function testSetNFTRoyaltyReceiverBatch3() public {
351+
emit log("Scenario: NFTs 1000, different receiver and fee");
352+
uint256 scenarioCount = 1000;
353+
uint96 newFeeNumerator = 100;
354+
address newRoyaltyReceiver = makeAddr("newRoyaltyReceiver");
355+
356+
// Have a new fee receiver and different feeNumerator
357+
assertNotEq(newFeeNumerator, feeNumerator, "Fee numerator should be different");
358+
assertNotEq(newRoyaltyReceiver, feeReceiver, "newRoyaltyReceiver should be different");
359+
360+
checkSetNFTRoyaltyReceiverBatch(newRoyaltyReceiver, newFeeNumerator, scenarioCount);
361+
}
362+
363+
function testSetNFTRoyaltyReceiverBatch4() public {
364+
emit log("Scenario: NFTs 10000, different receiver and fee");
365+
uint256 scenarioCount = 10000;
366+
uint96 newFeeNumerator = 100;
367+
address newRoyaltyReceiver = makeAddr("newRoyaltyReceiver");
368+
369+
// Have a new fee receiver and different feeNumerator
370+
assertNotEq(newFeeNumerator, feeNumerator, "Fee numerator should be different");
371+
assertNotEq(newRoyaltyReceiver, feeReceiver, "newRoyaltyReceiver should be different");
372+
373+
checkSetNFTRoyaltyReceiverBatch(newRoyaltyReceiver, newFeeNumerator, scenarioCount);
374+
}
375+
376+
function testSetNFTRoyaltyReceiverBatch5() public {
377+
emit log("Scenario: NFTs 1000, different fee");
378+
uint256 scenarioCount = 1000;
379+
uint96 newFeeNumerator = 100;
380+
381+
// Have a new fee receiver and different feeNumerator
382+
assertNotEq(newFeeNumerator, feeNumerator, "Fee numerator should be different");
383+
384+
checkSetNFTRoyaltyReceiverBatch(feeReceiver, newFeeNumerator, scenarioCount);
385+
}
386+
387+
function testSetNFTRoyaltyReceiverBatch6() public {
388+
emit log("Scenario: NFTs 1000, different receiver");
389+
uint256 scenarioCount = 1000;
390+
address newRoyaltyReceiver = makeAddr("newRoyaltyReceiver");
391+
392+
// Have a new fee receiver and different feeNumerator
393+
assertNotEq(newRoyaltyReceiver, feeReceiver, "newRoyaltyReceiver should be different");
394+
395+
checkSetNFTRoyaltyReceiverBatch(newRoyaltyReceiver, feeNumerator, scenarioCount);
396+
}
397+
398+
399+
function checkSetNFTRoyaltyReceiverBatch(address newRoyaltyReceiver, uint96 newFeeNumerator, uint256 scenarioCount) private {
400+
// Mint tokens.
401+
uint256 first = mintLots(user3, 100000, scenarioCount);
402+
403+
uint256[] memory nfts = new uint256[](scenarioCount);
404+
for (uint256 i = 0; i < nfts.length; i++) {
405+
nfts[i] = first + i;
406+
}
407+
408+
uint256 gasStart = gasleft();
409+
vm.prank(minter);
410+
erc721.setNFTRoyaltyReceiverBatch(nfts, newRoyaltyReceiver, newFeeNumerator);
411+
uint256 gasEnd = gasleft();
412+
emit log_named_uint("setNFTRoyaltyReceiverBatch gas", gasStart - gasEnd);
413+
}
414+
415+
416+
323417
function mintLots(address _recipient, uint256 _start, uint256 _quantity) public virtual returns (uint256) {
324418
uint256[] memory ids = new uint256[](_quantity);
325419
for (uint256 i = 0; i < _quantity; i++) {

perfTest/token/erc721/ImmutableERC721ByIdPerf.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ contract ImmutableERC721ByIdPerfTest is ERC721PerfTest {
1818
super.setUpStart();
1919

2020
ImmutableERC721MintByID immutableERC721 = new ImmutableERC721MintByID(
21-
owner, name, symbol, baseURI, contractURI, address(allowlist), feeReceiver, 300
21+
owner, name, symbol, baseURI, contractURI, address(allowlist), feeReceiver, feeNumerator
2222
);
2323

2424
// ImmutableERC721 does not implement the interface, and hence must be cast to the

perfTest/token/erc721/ImmutableERC721ByQuantityPerf.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ contract ImmutableERC721ByQuantityPerfTest is ERC721ByQuantityPerfTest {
1717
super.setUpStart();
1818

1919
ImmutableERC721 immutableERC721 = new ImmutableERC721(
20-
owner, name, symbol, baseURI, contractURI, address(allowlist), feeReceiver, 300
20+
owner, name, symbol, baseURI, contractURI, address(allowlist), feeReceiver, feeNumerator
2121
);
2222

2323
// ImmutableERC721 does not implement the interface, and hence must be cast to the

perfTest/token/erc721/ImmutableERC721V2ByQuantityPerf.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ contract ImmutableERC721V2ByQuantityPerfTest is ERC721ByQuantityPerfTest {
1717
super.setUpStart();
1818

1919
ImmutableERC721V2 immutableERC721 = new ImmutableERC721V2(
20-
owner, name, symbol, baseURI, contractURI, address(allowlist), feeReceiver, 300
20+
owner, name, symbol, baseURI, contractURI, address(allowlist), feeReceiver, feeNumerator
2121
);
2222

2323
// ImmutableERC721 does not implement the interface, and hence must be cast to the

0 commit comments

Comments
 (0)