Skip to content

Commit

Permalink
test: getRoyaltiesEIP2981 function
Browse files Browse the repository at this point in the history
  • Loading branch information
capedcrusader21 committed Oct 3, 2023
1 parent 4b9be89 commit a04145c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ contract TestERC721WithRoyaltyV2981Multi is

bytes4 internal constant INTERFACE_ID_IROYALTYUGC = 0xa30b4db9;

bytes4 internal constant INTERFACE_ID_GET_RECIPIENTS = 0xfd90e897;

struct Recipient {
address payable recipient;
uint16 bps;
Expand All @@ -39,6 +41,7 @@ contract TestERC721WithRoyaltyV2981Multi is
bytes4 interfaceId
) public view virtual override(ERC721Upgradeable, Royalties2981TestImpl) returns (bool) {
return
interfaceId == INTERFACE_ID_GET_RECIPIENTS ||
interfaceId == LibRoyalties2981._INTERFACE_ID_ROYALTIES ||
interfaceId == INTERFACE_ID_IROYALTYUGC ||
ERC721Upgradeable.supportsInterface(interfaceId) ||
Expand All @@ -58,7 +61,7 @@ contract TestERC721WithRoyaltyV2981Multi is
require(totalBPS == BASIS_POINTS, "Total bps must be 10000");
}

function getRecipients() external view returns (Recipient[] memory) {
function getRecipients(uint256 /* tokenId */) external view returns (Recipient[] memory) {
return _recipients;
}

Expand Down
18 changes: 12 additions & 6 deletions packages/marketplace/test/exchange/Exchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,10 +743,13 @@ describe('Exchange.sol', function () {
deployer: royaltyReceiver,
user1: maker,
user2: taker,
admin: receiver1,
user: receiver2,
} = await loadFixture(deployFixtures);

await ERC721WithRoyaltyV2981.mint(maker.address, 1, [
await FeeRecipientsData(maker.address, 10000),
await FeeRecipientsData(receiver1.address, 3000),
await FeeRecipientsData(receiver2.address, 7000),
]);

await ERC721WithRoyaltyV2981.connect(maker).approve(
Expand Down Expand Up @@ -828,12 +831,15 @@ describe('Exchange.sol', function () {
// check primary market protocol fee
expect(
await ERC20Contract.balanceOf(defaultFeeReceiver.address)
).to.be.equal(2500000000); // 250 * 10000000000 / 10000 = 250000000
).to.be.equal(2500000000); // 250 * 100000000000 / 10000 = 2500000000

// check paid royalty
expect(await ERC20Contract.balanceOf(royaltyReceiver.address)).to.be.equal(
50000000000
); // 50% of the amount
expect(await ERC20Contract.balanceOf(receiver1.address)).to.be.equal(
15000000000 // 1500 * 100000000000 / 10000 = 15000000000
);

expect(await ERC20Contract.balanceOf(receiver2.address)).to.be.equal(
35000000000 // 3500 * 100000000000 / 10000 = 35000000000
);

expect(await ERC20Contract.balanceOf(maker.address)).to.be.equal(
47500000000 // 100000000000 - royalty - protocolFee
Expand Down

1 comment on commit a04145c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

75.79%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/marketplace/contracts/exchange
   AssetMatcher.sol100%100%100%100%
   Exchange.sol86.79%85%85.71%89.47%152, 54, 79, 79–80
   ExchangeCore.sol78.76%59.09%100%89.66%116, 139–140, 140, 140, 140, 140, 143, 143, 204–205, 207–208, 245, 247–249, 255–257, 280–281, 298, 76
   OrderValidator.sol69.81%53.85%100%81.82%38, 54, 61–62, 62, 62, 72, 82–83, 88, 90, 90, 90, 90–91, 93
   WhiteList.sol97.73%93.75%100%100%57
packages/marketplace/contracts/exchange/libraries
   LibFill.sol55%33.33%66.67%63.64%48–49, 61, 71–72, 72, 72–73
   LibOrderDataGeneric.sol22.81%22.22%40%20.59%16–23, 25–26, 28, 41, 43, 43, 43–44, 46–47, 50, 50, 50–51, 53, 56, 56, 56–57, 59, 62, 66, 68, 68, 68–70, 73, 82, 82, 82–84
packages/marketplace/contracts/interfaces
   IAssetMatcher.sol100%100%100%100%
   IOrderValidator.sol100%100%100%100%
   IRoyaltiesProvider.sol100%100%100%100%
   IWhiteList.sol100%100%100%100%
packages/marketplace/contracts/lib-asset
   LibAsset.sol100%100%100%100%
packages/marketplace/contracts/lib-bp
   BpLibrary.sol100%100%100%100%
packages/marketplace/contracts/lib-order
   LibMath.sol27.50%18.75%50%30%100–103, 17–18, 33–34, 50, 50, 50–51, 72, 72, 72–73, 75, 88, 88, 88–89, 93, 93, 93, 93, 93, 97
   LibOrder.sol66.67%50%100%72.73%105, 105, 107, 107, 41–43, 54, 66
   LibOrderData.sol100%100%100%100%
packages/marketplace/contracts/lib-part
   LibPart.sol0%100%0%0%21
packages/marketplace/contracts/royalties
   IERC2981.sol100%100%100%100%
   LibRoyalties2981.sol0%0%0%0%18–19, 19, 19–20, 22–23, 23, 23–27
packages/marketplace/contracts/royalties-registry
   IMultiRoyaltyRecipients.sol100%100%100%100%
   RoyaltiesRegistry.sol88.80%82.35%100%89.47%166–167, 170–171, 212, 216, 232, 247, 250, 253, 256, 259, 276, 60
packages/marketplace/contracts/transfer-manager
   TransferExecutor.sol75.76%64.29%100%81.25%49–51, 58–59, 63, 66–67
   TransferManager.sol82.58%71.43%100%87.36%110, 114–115, 195, 202–203, 203, 203–204, 208, 248, 265, 269–271, 271, 271–273, 278–279, 302, 306–307, 62, 82–83
packages/marketplace/contracts/transfer-manager/interfaces
   IRoyaltyUGC.sol100%100%100%100%
   ITransferExecutor.sol100%100%100%100%
   ITransferManager.sol100%100%100%100%
packages/marketplace/contracts/transfer-manager/lib
   LibDeal.sol100%100%100%100%
   LibFeeSide.sol44.44%37.50%100%44.44%21, 24, 24, 24–25, 27, 27, 27–28, 30
   LibTransfer.sol0%0%0%0%7–8, 8, 8

Please sign in to comment.