-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from ProjectOpenSea/test-tstorish
add tstorish test script
- Loading branch information
Showing
4 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.17; | ||
|
||
import { Script, console2 } from "forge-std/Script.sol"; | ||
import { ConduitController } from | ||
"seaport-core/src/conduit/ConduitController.sol"; | ||
import { Consideration } from "seaport-core/src/lib/Consideration.sol"; | ||
|
||
contract TstorishDeploy is Script { | ||
function run() public { | ||
vm.broadcast(); | ||
ConduitController controller = new ConduitController(); | ||
vm.label(address(controller), "controller"); | ||
vm.broadcast(); | ||
Consideration seaport = new Consideration(address(controller)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# remove old dump | ||
rm -f seaport.dump | ||
# spin up anvil and prepare to dump state | ||
anvil --hardfork shanghai --dump-state ./seaport.dump & | ||
# save pid to kill later | ||
pid=$! | ||
# execute foundry script to deploy seaport | ||
FOUNDRY_PROFILE=optimized forge script TstorishDeploy --rpc-url http://localhost:8545 --slow --skip-simulation --broadcast --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
# get code of 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 | ||
seaport=$(curl -sX POST --data '{"jsonrpc":"2.0","method":"eth_getCode","params":["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", "latest"],"id":1}' -H "Content-Type: application/json" http://localhost:8545 | jq '.result') | ||
# exit anvil | ||
echo $seaport | ||
kill $pid | ||
anvil --hardfork shanghai & | ||
# save pid to kill later | ||
pid=$! | ||
# wait for anvil to warm up | ||
sleep 5 | ||
# call setCode on the 0xe7f address with the $seaport var | ||
curl -X POST --data '{"jsonrpc":"2.0","method":"anvil_setCode","params":["0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", '"$seaport"'],"id":1}' -H "Content-Type: application/json" http://localhost:8545 | ||
# mine a block | ||
# execute Tstorish test | ||
FOUNDRY_PROFILE=tstorish forge test -vvvv --fork-url http://localhost:8545 | ||
# get exit code of previous | ||
exit_code=$? | ||
# kill anvil | ||
kill $pid | ||
# exit with exit code of previous | ||
exit $exit_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.17; | ||
|
||
import { Test } from "forge-std/Test.sol"; | ||
|
||
import { | ||
ReentrancyGuard, | ||
ReentrancyErrors | ||
} from "seaport-core/src/lib/ReentrancyGuard.sol"; | ||
|
||
contract TstorishTest is Test { | ||
ReentrancyGuard seaport; | ||
|
||
function setUp() public { | ||
seaport = ReentrancyGuard( | ||
payable( | ||
// second contract deployed by first anvil pk | ||
0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 | ||
) | ||
); | ||
} | ||
|
||
function testActivate() public { | ||
vm.etch( | ||
0xCafac3dD18aC6c6e92c921884f9E4176737C052c, | ||
hex"3d5c" | ||
); | ||
|
||
// first call updates storage | ||
vm.record(); | ||
seaport.__activateTstore(); | ||
(bytes32[] memory reads, bytes32[] memory writes) = | ||
vm.accesses(address(seaport)); | ||
assertEq(writes.length, 1); | ||
// second call reverts | ||
vm.expectRevert(ReentrancyErrors.TStoreAlreadyActivated.selector); | ||
seaport.__activateTstore(); | ||
} | ||
} |