@@ -1068,130 +1068,6 @@ contract PackTest is BaseTest {
1068
1068
assertEq (packUri, pack.uri (packId));
1069
1069
}
1070
1070
1071
- function test_fuzz_state_openPack (
1072
- uint256 x ,
1073
- uint128 y ,
1074
- uint256 z
1075
- ) public {
1076
- // vm.assume(x == 1574 && y == 22 && z == 392);
1077
- (ITokenBundle.Token[] memory tokensToPack , uint256 [] memory rewardUnits ) = getTokensToPack (x);
1078
- if (tokensToPack.length == 0 ) {
1079
- return ;
1080
- }
1081
-
1082
- uint256 packId = pack.nextTokenIdToMint ();
1083
- address recipient = address (0x123 );
1084
- uint256 totalRewardUnits;
1085
- uint256 nativeTokenPacked;
1086
-
1087
- for (uint256 i = 0 ; i < tokensToPack.length ; i += 1 ) {
1088
- totalRewardUnits += rewardUnits[i];
1089
- if (tokensToPack[i].assetContract == address (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE )) {
1090
- nativeTokenPacked += tokensToPack[i].totalAmount;
1091
- }
1092
- }
1093
- vm.assume (y > 0 && totalRewardUnits % y == 0 );
1094
- vm.deal (address (tokenOwner), nativeTokenPacked);
1095
-
1096
- vm.prank (address (tokenOwner));
1097
- (, uint256 totalSupply ) = pack.createPack { value: nativeTokenPacked }(
1098
- tokensToPack,
1099
- rewardUnits,
1100
- packUri,
1101
- 0 ,
1102
- y,
1103
- recipient
1104
- );
1105
- console2.log ("total supply: " , totalSupply);
1106
- console2.log ("total reward units: " , totalRewardUnits);
1107
-
1108
- vm.assume (z <= totalSupply);
1109
- vm.prank (recipient, recipient);
1110
- ITokenBundle.Token[] memory rewardsReceived = pack.openPack (packId, z);
1111
- console2.log ("received reward units: " , rewardsReceived.length );
1112
-
1113
- assertEq (packUri, pack.uri (packId));
1114
-
1115
- (
1116
- uint256 nativeTokenAmount ,
1117
- uint256 erc20Amount ,
1118
- uint256 [] memory erc1155Amounts ,
1119
- uint256 erc721Amount
1120
- ) = checkBalances (rewardsReceived, recipient);
1121
-
1122
- assertEq (address (recipient).balance, nativeTokenAmount);
1123
- assertEq (erc20.balanceOf (address (recipient)), erc20Amount);
1124
- assertEq (erc721.balanceOf (address (recipient)), erc721Amount);
1125
-
1126
- for (uint256 i = 0 ; i < erc1155Amounts.length ; i += 1 ) {
1127
- assertEq (erc1155.balanceOf (address (recipient), i), erc1155Amounts[i]);
1128
- }
1129
- }
1130
-
1131
- function test_fuzz_failing_state_openPack () public {
1132
- // x: 446, y: 22, z: 890 (gas: 8937393460518282035), total supply: 10203, total reward units: 224466
1133
- // x: 335, y: 3, z: 1570 (gas: 8937393460517864076), total supply: 54915, total reward units: 164745
1134
- // x: 1962, y: 282, z: 219 (gas: 8937393460523355524), total supply: 3239, total reward units: 913398
1135
- // x: 570, y: 497, z: 435 (gas: 8937393460523355524), total supply: 3239, total reward units: 913398
1136
-
1137
- uint256 x = 115 ;
1138
- uint128 y = 191 ;
1139
- uint256 z = 253 ;
1140
-
1141
- (ITokenBundle.Token[] memory tokensToPack , uint256 [] memory rewardUnits ) = getTokensToPack (x);
1142
- if (tokensToPack.length == 0 ) {
1143
- return ;
1144
- }
1145
-
1146
- uint256 packId = pack.nextTokenIdToMint ();
1147
- address recipient = address (0x123 );
1148
- uint256 totalRewardUnits;
1149
- uint256 nativeTokenPacked;
1150
-
1151
- for (uint256 i = 0 ; i < tokensToPack.length ; i += 1 ) {
1152
- totalRewardUnits += rewardUnits[i];
1153
- if (tokensToPack[i].assetContract == address (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE )) {
1154
- nativeTokenPacked += tokensToPack[i].totalAmount;
1155
- }
1156
- }
1157
- vm.assume (y > 0 && totalRewardUnits % y == 0 );
1158
- vm.deal (address (tokenOwner), nativeTokenPacked);
1159
-
1160
- vm.prank (address (tokenOwner));
1161
- (, uint256 totalSupply ) = pack.createPack { value: nativeTokenPacked }(
1162
- tokensToPack,
1163
- rewardUnits,
1164
- packUri,
1165
- 0 ,
1166
- y,
1167
- recipient
1168
- );
1169
- console2.log ("total supply: " , totalSupply);
1170
- console2.log ("total reward units: " , totalRewardUnits);
1171
-
1172
- vm.assume (z <= totalSupply);
1173
- vm.prank (recipient, recipient);
1174
- ITokenBundle.Token[] memory rewardsReceived = pack.openPack (packId, z);
1175
- console2.log ("received reward units: " , rewardsReceived.length );
1176
-
1177
- // assertEq(packUri, pack.uri(packId));
1178
-
1179
- // (
1180
- // uint256 nativeTokenAmount,
1181
- // uint256 erc20Amount,
1182
- // uint256[] memory erc1155Amounts,
1183
- // uint256 erc721Amount
1184
- // ) = checkBalances(rewardsReceived, recipient);
1185
-
1186
- // assertEq(address(recipient).balance, nativeTokenAmount);
1187
- // assertEq(erc20.balanceOf(address(recipient)), erc20Amount);
1188
- // assertEq(erc721.balanceOf(address(recipient)), erc721Amount);
1189
-
1190
- // for (uint256 i = 0; i < erc1155Amounts.length; i += 1) {
1191
- // assertEq(erc1155.balanceOf(address(recipient), i), erc1155Amounts[i]);
1192
- // }
1193
- }
1194
-
1195
1071
/*///////////////////////////////////////////////////////////////
1196
1072
Scenario/Exploit tests
1197
1073
//////////////////////////////////////////////////////////////*/
0 commit comments