Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kulkarohan committed Aug 17, 2023
1 parent 8b2c8be commit e133c8e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
10 changes: 6 additions & 4 deletions test/unit/ERC1155Rewards.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ contract ERC1155RewardsTest is ProtocolRewardsTest {
RewardsSettings memory settings = mockERC1155.computeFreeMintRewards(numTokens);

assertEq(protocolRewards.totalSupply(), totalReward);
assertEq(protocolRewards.balanceOf(creator), settings.creatorReward + settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(creator), settings.creatorReward);
assertEq(protocolRewards.balanceOf(createReferral), settings.createReferralReward);
assertEq(protocolRewards.balanceOf(mintReferral), settings.mintReferralReward);
assertEq(protocolRewards.balanceOf(collector), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward);
}

Expand All @@ -52,9 +53,9 @@ contract ERC1155RewardsTest is ProtocolRewardsTest {
RewardsSettings memory settings = mockERC1155.computePaidMintRewards(numTokens);

assertEq(protocolRewards.totalSupply(), totalReward);
assertEq(protocolRewards.balanceOf(creator), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(createReferral), settings.createReferralReward);
assertEq(protocolRewards.balanceOf(mintReferral), settings.mintReferralReward);
assertEq(protocolRewards.balanceOf(collector), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward);
}

Expand All @@ -73,7 +74,8 @@ contract ERC1155RewardsTest is ProtocolRewardsTest {
RewardsSettings memory settings = mockERC1155.computeFreeMintRewards(numTokens);

assertEq(protocolRewards.totalSupply(), totalReward);
assertEq(protocolRewards.balanceOf(creator), settings.creatorReward + settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(creator), settings.creatorReward);
assertEq(protocolRewards.balanceOf(collector), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.mintReferralReward + settings.createReferralReward);
}

Expand All @@ -97,7 +99,7 @@ contract ERC1155RewardsTest is ProtocolRewardsTest {
RewardsSettings memory settings = mockERC1155.computePaidMintRewards(numTokens);

assertEq(protocolRewards.totalSupply(), totalReward);
assertEq(protocolRewards.balanceOf(creator), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(collector), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.mintReferralReward + settings.createReferralReward);
}

Expand Down
13 changes: 8 additions & 5 deletions test/unit/ERC721Rewards.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ contract ERC721RewardsTest is ProtocolRewardsTest {
RewardsSettings memory settings = mockERC721.computeFreeMintRewards(numTokens);

assertEq(protocolRewards.totalSupply(), totalReward);
assertEq(protocolRewards.balanceOf(creator), settings.creatorReward + settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(creator), settings.creatorReward);
assertEq(protocolRewards.balanceOf(createReferral), settings.createReferralReward);
assertEq(protocolRewards.balanceOf(mintReferral), settings.mintReferralReward);
assertEq(protocolRewards.balanceOf(collector), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward);
}

Expand All @@ -76,9 +77,9 @@ contract ERC721RewardsTest is ProtocolRewardsTest {
RewardsSettings memory settings = mockERC721.computePaidMintRewards(numTokens);

assertEq(protocolRewards.totalSupply(), totalReward);
assertEq(protocolRewards.balanceOf(creator), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(createReferral), settings.createReferralReward);
assertEq(protocolRewards.balanceOf(mintReferral), settings.mintReferralReward);
assertEq(protocolRewards.balanceOf(collector), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward);
}

Expand All @@ -97,7 +98,8 @@ contract ERC721RewardsTest is ProtocolRewardsTest {
RewardsSettings memory settings = mockERC721.computeFreeMintRewards(numTokens);

assertEq(protocolRewards.totalSupply(), totalReward);
assertEq(protocolRewards.balanceOf(creator), settings.creatorReward + settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(creator), settings.creatorReward);
assertEq(protocolRewards.balanceOf(collector), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.mintReferralReward + settings.createReferralReward);
}

Expand All @@ -121,7 +123,7 @@ contract ERC721RewardsTest is ProtocolRewardsTest {
RewardsSettings memory settings = mockERC721.computePaidMintRewards(numTokens);

assertEq(protocolRewards.totalSupply(), totalReward);
assertEq(protocolRewards.balanceOf(creator), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(collector), settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(zora), settings.zoraReward + settings.mintReferralReward + settings.createReferralReward);
}

Expand All @@ -136,7 +138,8 @@ contract ERC721RewardsTest is ProtocolRewardsTest {

mockERC721.mintWithRewards{value: totalValue}(collector, numTokens, mintReferral);

assertEq(protocolRewards.balanceOf(address(mockERC721)), settings.creatorReward + settings.firstMinterReward);
assertEq(protocolRewards.balanceOf(address(mockERC721)), settings.creatorReward);
assertEq(protocolRewards.balanceOf(collector), settings.firstMinterReward);
}

function testRevert721FreeMintInvalidEth(uint16 numTokens) public {
Expand Down
8 changes: 6 additions & 2 deletions test/utils/MockNFTs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ contract MockERC721 is ERC721, ERC721Rewards, ERC721RewardsStorageV1 {
}

function mintWithRewards(address to, uint256 numTokens, address mintReferral) external payable {
_handleRewards(msg.value, numTokens, salePrice, creator != address(0) ? creator : address(this), createReferral, mintReferral);
if (firstMinter == address(0)) firstMinter = to;

_handleRewards(msg.value, numTokens, salePrice, creator != address(0) ? creator : address(this), createReferral, mintReferral, firstMinter);

for (uint256 i; i < numTokens; ++i) {
_mint(to, currentTokenId++);
Expand Down Expand Up @@ -58,7 +60,9 @@ contract MockERC1155 is ERC1155, ERC1155Rewards, ERC1155RewardsStorageV1 {
}

function mintWithRewards(address to, uint256 tokenId, uint256 numTokens, address mintReferral) external payable {
uint256 remainingValue = _handleRewardsAndGetValueSent(msg.value, numTokens, creator, createReferrals[tokenId], mintReferral);
if (firstMinters[tokenId] == address(0)) firstMinters[tokenId] = to;

uint256 remainingValue = _handleRewardsAndGetValueSent(msg.value, numTokens, creator, createReferrals[tokenId], mintReferral, firstMinters[tokenId]);

uint256 expectedRemainingValue = salePrice * numTokens;

Expand Down

0 comments on commit e133c8e

Please sign in to comment.