-
Notifications
You must be signed in to change notification settings - Fork 4
/
CompareERC721.t.sol
167 lines (131 loc) · 4.34 KB
/
CompareERC721.t.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import {Test} from "forge-std/Test.sol";
import {HuffDeployer} from "foundry-huff/HuffDeployer.sol";
import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import {IMockERC721H} from "../src/refs/IMockERC721H.sol";
import {ERC721Azuki} from "../src/refs/ERC721Azuki.sol";
import {ERC721OZ} from "../src/refs/ERC721OZ.sol";
contract ERC721Receiver is ERC721Holder {}
/// @author Philippe Dumonet <[email protected]>
contract CompareERC721Test is Test {
IMockERC721H internal erc721h;
ERC721Azuki internal erc721a;
ERC721OZ internal erc721oz;
address internal receiver;
address constant USER1 = address(bytes20(keccak256("user1")));
address constant USER2 = address(bytes20(keccak256("user2")));
address constant USER3 = address(bytes20(keccak256("user3")));
function setUp() public {
vm.deal(USER1, 3 ether);
erc721h = IMockERC721H(HuffDeployer.config().deploy("MockERC721H"));
erc721h.mint(USER1, 20);
vm.prank(USER1);
erc721h.transferFrom(USER1, USER1, 1);
erc721a = new ERC721Azuki();
erc721a.mint(USER1, 20);
vm.prank(USER1);
erc721a.transferFrom(USER1, USER1, 1);
erc721oz = new ERC721OZ();
erc721oz.mint(USER1, 20);
vm.prank(USER1);
erc721oz.transferFrom(USER1, USER1, 1);
receiver = address(new ERC721Receiver());
}
function testMint50OZ() public {
erc721oz.mint(USER1, 50);
}
function testMint50Azuki() public {
erc721a.mint(USER1, 50);
}
function testMint50Huff() public {
erc721h.mint(USER1, 50);
}
function testMint200OZ() public {
erc721oz.mint(USER1, 200);
}
function testMint200Azuki() public {
erc721a.mint(USER1, 200);
}
function testMint200Huff() public {
erc721h.mint(USER1, 200);
}
function testSimpleTransfer20InOZ() public {
vm.prank(USER1);
erc721oz.transferFrom(USER1, USER2, 20);
}
function testSimpleTransfer20InAzuki() public {
vm.prank(USER1);
erc721a.transferFrom(USER1, USER2, 20);
}
function testSimpleTransfer20InHuff() public {
vm.prank(USER1);
erc721h.transferFrom(USER1, USER2, 20);
}
function testSimpleTransfer1InOZ() public {
vm.prank(USER1);
erc721oz.transferFrom(USER1, USER2, 2);
}
function testSimpleTransfer1InAzuki() public {
vm.prank(USER1);
erc721a.transferFrom(USER1, USER2, 2);
}
function testSimpleTransfer1InHuff() public {
vm.prank(USER1);
erc721h.transferFrom(USER1, USER2, 2);
}
function testSimpleTransferOZ() public {
vm.prank(USER1);
erc721oz.transferFrom(USER1, USER2, 1);
}
function testSimpleTransferAzuki() public {
vm.prank(USER1);
erc721a.transferFrom(USER1, USER2, 1);
}
function testSimpleTransferHuff() public {
vm.prank(USER1);
erc721h.transferFrom(USER1, USER2, 1);
}
function testSimpleBurnOZ() public {
erc721oz.burn(1);
}
function testSimpleBurnAzuki() public {
erc721a.burn(1);
}
function testSimpleBurnHuff() public {
erc721h.burn(1);
}
function testSimpleBurn1InOZ() public {
erc721oz.burn(2);
}
function testSimpleBurn1InAzuki() public {
erc721a.burn(2);
}
function testSimpleBurn1InHuff() public {
erc721h.burn(2);
}
function testSimpleSafeTransferToEoaOZ() public {
vm.prank(USER1);
erc721oz.safeTransferFrom(USER1, USER2, 1);
}
function testSimpleSafeTransferToEoaAzuki() public {
vm.prank(USER1);
erc721a.safeTransferFrom(USER1, USER2, 1);
}
function testSimpleSafeTransferToEoaHuff() public {
vm.prank(USER1);
erc721h.safeTransferFrom(USER1, USER2, 1);
}
function testSafeTransferToReceiverOZ() public {
vm.prank(USER1);
erc721oz.safeTransferFrom(USER1, receiver, 1, hex"010203");
}
function testSafeTransferToReceiverAzuki() public {
vm.prank(USER1);
erc721a.safeTransferFrom(USER1, receiver, 1, hex"010203");
}
function testSafeTransferToReceiverHuff() public {
vm.prank(USER1);
erc721h.safeTransferFrom(USER1, receiver, 1, hex"010203");
}
}