Skip to content

Commit

Permalink
feat: more tests this time 2 for 1 burn
Browse files Browse the repository at this point in the history
Signed-off-by: Campion Fellin <[email protected]>
  • Loading branch information
campionfellin committed Oct 18, 2023
1 parent df28331 commit 1a9f73c
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions packages/manifold/test/physicalclaim/PhysicalClaim.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,96 @@ contract PhysicalClaimTest is Test {
vm.stopPrank();
}

function testTwoForOneBurn() public {
vm.startPrank(owner);

// Mint 2 tokens to other
creatorCore721.mintBase(other, "");
creatorCore721.mintBase(other, "");

IPhysicalClaimCore.BurnItem[] memory burnItems = new IPhysicalClaimCore.BurnItem[](2);
burnItems[0] = IPhysicalClaimCore.BurnItem({
validationType: IPhysicalClaimCore.ValidationType.CONTRACT,
contractAddress: address(creatorCore721),
tokenSpec: IPhysicalClaimCore.TokenSpec.ERC721,
burnSpec: IPhysicalClaimCore.BurnSpec.MANIFOLD,
amount: 1,
minTokenId: 1,
maxTokenId: 1,
merkleRoot: ""
});
burnItems[1] = IPhysicalClaimCore.BurnItem({
validationType: IPhysicalClaimCore.ValidationType.CONTRACT,
contractAddress: address(creatorCore721),
tokenSpec: IPhysicalClaimCore.TokenSpec.ERC721,
burnSpec: IPhysicalClaimCore.BurnSpec.MANIFOLD,
amount: 1,
minTokenId: 2,
maxTokenId: 2,
merkleRoot: ""
});

IPhysicalClaimCore.BurnGroup[] memory burnSet = new IPhysicalClaimCore.BurnGroup[](1);
burnSet[0] = IPhysicalClaimCore.BurnGroup({
requiredCount: 2,
items: burnItems
});

IPhysicalClaimCore.Variation[] memory variations = new IPhysicalClaimCore.Variation[](1);
variations[0] = IPhysicalClaimCore.Variation({
id: 1,
max: 1
});

// Create claim initialization parameters. Total supply is 1 so they will use the whole supply
IPhysicalClaimCore.PhysicalClaimParameters memory claimPs = IPhysicalClaimCore.PhysicalClaimParameters({
paymentReceiver: payable(owner),
totalSupply: 1,
startDate: 0,
endDate: 0,
cost: 0,
burnSet: burnSet,
variations: variations,
signer: signerForCost
});

// Initialize the physical claim
example.initializePhysicalClaim(instanceId, claimPs);

vm.stopPrank();
vm.startPrank(other);

// Approve token for burning
creatorCore721.approve(address(example), 1);
creatorCore721.approve(address(example), 2);

IPhysicalClaimCore.BurnToken[] memory burnTokens = new IPhysicalClaimCore.BurnToken[](2);
burnTokens[0] = IPhysicalClaimCore.BurnToken({
groupIndex: 0,
itemIndex: 0,
contractAddress: address(creatorCore721),
id: 1,
merkleProof: new bytes32[](0)
});
burnTokens[1] = IPhysicalClaimCore.BurnToken({
groupIndex: 0,
itemIndex: 1,
contractAddress: address(creatorCore721),
id: 2,
merkleProof: new bytes32[](0)
});

IPhysicalClaimCore.PhysicalClaimSubmission[] memory submissions = new IPhysicalClaimCore.PhysicalClaimSubmission[](1);
submissions[0].instanceId = instanceId;
submissions[0].physicalClaimCount = 1;
submissions[0].currentClaimCount = 0;
submissions[0].burnTokens = burnTokens;
submissions[0].variation = 0;
submissions[0].data = "";

example.burnRedeem(submissions);

vm.stopPrank();
}

}

0 comments on commit 1a9f73c

Please sign in to comment.