forked from crytic/properties
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathERC721MintableProperties.sol
39 lines (27 loc) · 1.38 KB
/
ERC721MintableProperties.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.13;
import "../util/ERC721TestBase.sol";
abstract contract CryticERC721MintableProperties is CryticERC721TestBase {
////////////////////////////////////////
// Properties
// mint increases the total supply.
function test_ERC721_mintIncreasesSupply(uint256 amount) public virtual {
require(isMintableOrBurnable);
uint256 selfBalance = balanceOf(msg.sender);
uint256 oldTotalSupply = totalSupply();
_customMint(msg.sender, amount);
assertEq(oldTotalSupply + amount, totalSupply(), "Total supply was not correctly increased");
assertEq(selfBalance + amount, balanceOf(msg.sender), "Receiver supply was not correctly increased");
}
// mint creates a fresh token.
function test_ERC721_mintCreatesFreshToken(uint256 amount) public virtual {
require(isMintableOrBurnable);
uint256 selfBalance = balanceOf(msg.sender);
_customMint(msg.sender, amount);
assertEq(selfBalance + amount, balanceOf(msg.sender), "Receiver supply was not correctly increased");
uint256 tokenId = tokenOfOwnerByIndex(msg.sender, selfBalance);
assertWithMsg(ownerOf(tokenId) == msg.sender, "Token ID was not minted to receiver");
}
// Wrappers
function _customMint(address to, uint256 amount) internal virtual;
}