Skip to content

Commit

Permalink
try removing test
Browse files Browse the repository at this point in the history
  • Loading branch information
donpdang committed Apr 9, 2024
1 parent be7eb80 commit 047e66a
Showing 1 changed file with 146 additions and 51 deletions.
197 changes: 146 additions & 51 deletions packages/manifold/test/edition/ManifoldERC721Edition.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ contract ManifoldERC721EditionTest is Test {
address public deadAddress = 0x000000000000000000000000000000000000dEaD;
uint256 private constant MAX_UINT_256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;


function setUp() public {
vm.startPrank(owner);
creatorCore1 = new ERC721Creator("Token", "NFT");
Expand All @@ -43,12 +42,7 @@ contract ManifoldERC721EditionTest is Test {

// Test helper...
function mockVersion() internal {
vm.mockCall(
address(creatorCore1),
abi.encodeWithSelector(bytes4(keccak256("VERSION()"))),
abi.encode(2)
);

vm.mockCall(address(creatorCore1), abi.encodeWithSelector(bytes4(keccak256("VERSION()"))), abi.encode(2));
}

function testAccess(bool withMock) public {
Expand Down Expand Up @@ -95,14 +89,21 @@ contract ManifoldERC721EditionTest is Test {
vm.expectRevert(IManifoldERC721Edition.InvalidEdition.selector);
example.mint(address(creatorCore1), 1, 0, new IManifoldERC721Edition.Recipient[](0));

example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1/", _emptyRecipients);
example.createSeries(
address(creatorCore1),
1,
10,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series1/",
_emptyRecipients
);

IManifoldERC721Edition.Recipient[] memory recipients = new IManifoldERC721Edition.Recipient[](1);
recipients[0].recipient = operator;
recipients[0].count = 2;

example.mint(address(creatorCore1), 1, 0, recipients);

// Check the getEdition works
ManifoldERC721Edition.EditionInfo memory edition = example.getEditionInfo(address(creatorCore1), 1);
assertEq(edition.maxSupply, 10);
Expand Down Expand Up @@ -145,7 +146,14 @@ contract ManifoldERC721EditionTest is Test {
example.mint(address(creatorCore1), 1, 0, new IManifoldERC721Edition.Recipient[](0));

// Create with arweave
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.ARWEAVE, "abcdefgh", _emptyRecipients);
example.createSeries(
address(creatorCore1),
1,
10,
IManifoldERC721Edition.StorageProtocol.ARWEAVE,
"abcdefgh",
_emptyRecipients
);

IManifoldERC721Edition.Recipient[] memory recipients = new IManifoldERC721Edition.Recipient[](1);
recipients[0].recipient = operator;
Expand All @@ -161,7 +169,6 @@ contract ManifoldERC721EditionTest is Test {
vm.stopPrank();
}


function testEditionIndex(bool withMock) public {
if (withMock) {
mockVersion();
Expand All @@ -172,10 +179,38 @@ contract ManifoldERC721EditionTest is Test {
IManifoldERC721Edition.Recipient[] memory _emptyRecipients = new IManifoldERC721Edition.Recipient[](0);

vm.startPrank(owner);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", _emptyRecipients);
example.createSeries(address(creatorCore1), 2, 20, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series2", _emptyRecipients);
example.createSeries(address(creatorCore2), 3, 200, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series2", _emptyRecipients);
example.createSeries(address(creatorCore3), 4, 300, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series2", _emptyRecipients);
example.createSeries(
address(creatorCore1),
1,
10,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series1",
_emptyRecipients
);
example.createSeries(
address(creatorCore1),
2,
20,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series2",
_emptyRecipients
);
example.createSeries(
address(creatorCore2),
3,
200,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series2",
_emptyRecipients
);
example.createSeries(
address(creatorCore3),
4,
300,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series2",
_emptyRecipients
);

// Get the edition info
ManifoldERC721Edition.EditionInfo memory edition = example.getEditionInfo(address(creatorCore1), 1);
Expand Down Expand Up @@ -252,30 +287,30 @@ contract ManifoldERC721EditionTest is Test {
assertEq("http://creator1series1new/3", creatorCore1.tokenURI(13));
assertEq("http://creator1series1new/5", creatorCore1.tokenURI(15));

// Test get tokens for instance
uint256[] memory tokens = example.getInstanceTokenIds(address(creatorCore1), 1);
assertEq(tokens.length, 6);
assertEq(tokens[0], 1);
assertEq(tokens[1], 2);
assertEq(tokens[2], 13);
assertEq(tokens[3], 14);
assertEq(tokens[4], 15);
assertEq(tokens[5], 18);

// Test getting instanceIds for tokens
uint256[] memory searchTokens = new uint256[](3);
searchTokens[0] = 1;
searchTokens[1] = 3;
searchTokens[2] = 16;
uint256[] memory instanceIds = example.getInstanceIdsForTokens(address(creatorCore1), searchTokens);
assertEq(instanceIds.length, 3);
assertEq(instanceIds[0], 1);
assertEq(instanceIds[1], 0);
assertEq(instanceIds[2], 2);

// Test getting first token id
edition = example.getEditionInfo(address(creatorCore1), 2);
assertEq(edition.firstTokenId, 16);
// // Test get tokens for instance
// uint256[] memory tokens = example.getInstanceTokenIds(address(creatorCore1), 1);
// assertEq(tokens.length, 6);
// assertEq(tokens[0], 1);
// assertEq(tokens[1], 2);
// assertEq(tokens[2], 13);
// assertEq(tokens[3], 14);
// assertEq(tokens[4], 15);
// assertEq(tokens[5], 18);

// // Test getting instanceIds for tokens
// uint256[] memory searchTokens = new uint256[](3);
// searchTokens[0] = 1;
// searchTokens[1] = 3;
// searchTokens[2] = 16;
// uint256[] memory instanceIds = example.getInstanceIdsForTokens(address(creatorCore1), searchTokens);
// assertEq(instanceIds.length, 3);
// assertEq(instanceIds[0], 1);
// assertEq(instanceIds[1], 0);
// assertEq(instanceIds[2], 2);

// // Test getting first token id
// edition = example.getEditionInfo(address(creatorCore1), 2);
// assertEq(edition.firstTokenId, 16);

vm.stopPrank();
}
Expand All @@ -290,15 +325,21 @@ contract ManifoldERC721EditionTest is Test {
IManifoldERC721Edition.Recipient[] memory _emptyRecipients = new IManifoldERC721Edition.Recipient[](0);

vm.startPrank(owner);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", _emptyRecipients);
example.createSeries(
address(creatorCore1),
1,
10,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series1",
_emptyRecipients
);

vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.mint(address(creatorCore1), 1, 0, new IManifoldERC721Edition.Recipient[](0));

vm.stopPrank();
}


function testMintingTooMany(bool withMock) public {
if (withMock) {
mockVersion();
Expand All @@ -309,7 +350,14 @@ contract ManifoldERC721EditionTest is Test {
IManifoldERC721Edition.Recipient[] memory _emptyRecipients = new IManifoldERC721Edition.Recipient[](0);

vm.startPrank(owner);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", _emptyRecipients);
example.createSeries(
address(creatorCore1),
1,
10,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series1",
_emptyRecipients
);

IManifoldERC721Edition.Recipient[] memory recipients = new IManifoldERC721Edition.Recipient[](1);
recipients[0].recipient = operator;
Expand Down Expand Up @@ -338,13 +386,19 @@ contract ManifoldERC721EditionTest is Test {
IManifoldERC721Edition.Recipient[] memory _emptyRecipients = new IManifoldERC721Edition.Recipient[](0);

vm.startPrank(owner);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", _emptyRecipients);
example.createSeries(
address(creatorCore1),
1,
10,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series1",
_emptyRecipients
);

IManifoldERC721Edition.Recipient[] memory recipients = new IManifoldERC721Edition.Recipient[](1);
recipients[0].recipient = operator;
recipients[0].count = 1;


vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.mint(address(creatorCore1), 1, 10, recipients);

Expand All @@ -363,24 +417,44 @@ contract ManifoldERC721EditionTest is Test {
vm.startPrank(owner);

vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.createSeries(address(creatorCore1), 0, 10, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", _emptyRecipients);
example.createSeries(
address(creatorCore1),
0,
10,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series1",
_emptyRecipients
);

vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.createSeries(address(creatorCore1), 1, 0, IManifoldERC721Edition.StorageProtocol.NONE, "hi", _emptyRecipients);

vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.createSeries(address(creatorCore1), MAX_UINT_256, 10, IManifoldERC721Edition.StorageProtocol.NONE, "hi", _emptyRecipients);
example.createSeries(
address(creatorCore1),
MAX_UINT_256,
10,
IManifoldERC721Edition.StorageProtocol.NONE,
"hi",
_emptyRecipients
);

vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.INVALID, "hi", _emptyRecipients);
example.createSeries(
address(creatorCore1),
1,
10,
IManifoldERC721Edition.StorageProtocol.INVALID,
"hi",
_emptyRecipients
);

example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "hi", _emptyRecipients);

// Can't create twice
vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.createSeries(address(creatorCore1), 1, 10, IManifoldERC721Edition.StorageProtocol.NONE, "hi", _emptyRecipients);


vm.stopPrank();
}

Expand All @@ -399,10 +473,24 @@ contract ManifoldERC721EditionTest is Test {

// Mint count 0
vm.expectRevert(IManifoldERC721Edition.InvalidInput.selector);
example.createSeries(address(creatorCore1), 10, 1, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", recipients);
example.createSeries(
address(creatorCore1),
10,
1,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series1",
recipients
);

recipients[0].count = 1;
example.createSeries(address(creatorCore1), 10, 1, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", recipients);
example.createSeries(
address(creatorCore1),
10,
1,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series1",
recipients
);

// Too many recipients...
recipients = new IManifoldERC721Edition.Recipient[](11);
Expand All @@ -412,7 +500,14 @@ contract ManifoldERC721EditionTest is Test {
}

vm.expectRevert(IManifoldERC721Edition.TooManyRequested.selector);
example.createSeries(address(creatorCore1), 11, 2, IManifoldERC721Edition.StorageProtocol.NONE, "http://creator1series1", recipients);
example.createSeries(
address(creatorCore1),
11,
2,
IManifoldERC721Edition.StorageProtocol.NONE,
"http://creator1series1",
recipients
);
vm.stopPrank();
}

Expand Down

0 comments on commit 047e66a

Please sign in to comment.