Skip to content

Commit

Permalink
chore: coverage of the getPhysicalClaim function
Browse files Browse the repository at this point in the history
Signed-off-by: Campion Fellin <[email protected]>
  • Loading branch information
campionfellin committed Oct 10, 2023
1 parent e0fce74 commit 5bc9717
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
* Burn Redeem Core interface
*/
interface IPhysicalClaimCore is IERC165, IERC721Receiver, IERC1155Receiver {
error InvalidInstance();
error UnsupportedContractVersion();
error InvalidToken(uint256);
error InvalidInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ abstract contract PhysicalClaimCore is ERC165, AdminControl, ReentrancyGuard, IP
*/
function _getPhysicalClaim(uint256 instanceId) internal view returns(PhysicalClaim storage physicalClaimInstance) {
physicalClaimInstance = _physicalClaims[instanceId];
if (physicalClaimInstance.paymentReceiver == address(0)) {
revert InvalidInstance();
}
}

/**
Expand Down
35 changes: 35 additions & 0 deletions packages/manifold/test/physicalclaim/PhysicalClaim.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,33 @@ contract PhysicalClaimTest is Test {
vm.stopPrank();
}

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

IPhysicalClaimCore.PhysicalClaimParameters memory claimPs = IPhysicalClaimCore.PhysicalClaimParameters({
paymentReceiver: payable(owner),
redeemAmount: 1,
redeemedCount: 0,
totalSupply: 0,
startDate: 0,
endDate: 0,
cost: 0,
location: "",
burnSet: new IPhysicalClaimCore.BurnGroup[](0)
});

// Cannot do instanceId of 0
vm.expectRevert();
example.initializePhysicalClaim(0, claimPs);

// Cannot do largest instanceID
vm.expectRevert();
example.initializePhysicalClaim(2**56, claimPs);


vm.stopPrank();
}

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

Expand Down Expand Up @@ -100,6 +127,14 @@ contract PhysicalClaimTest is Test {
// Initialize the physical claim
example.initializePhysicalClaim(instanceId, claimPs);

// Can get the claim
IPhysicalClaimCore.PhysicalClaim memory claim = example.getPhysicalClaim(instanceId);
assertEq(claim.paymentReceiver, owner);

// Cannot get claim that doesn't exist
vm.expectRevert();
example.getPhysicalClaim(2);

// Can update
claimPs.redeemAmount = 2;
example.updatePhysicalClaim(instanceId, claimPs);
Expand Down

0 comments on commit 5bc9717

Please sign in to comment.