Skip to content

Commit

Permalink
Add two bare-minimum test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
duncancmt committed Jan 12, 2024
1 parent 116b3a1 commit f1f7d85
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/deployer/Deployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ contract DeployerTest is Test {
deployer.deploy(1, hex"60015ff3"); // PUSH1 1 PUSH0 RETURN; returns hex"00" (STOP; succeeds with empty returnData)
}

function testDeployThenEmpty() public {
deployer.setDescription(1, "nothing to see here");
deployer.authorize(1, address(this), uint96(block.timestamp + 1 days));
assertEq(deployer.feeCollector(1), address(0));
// PUSH4 60205ff3 PUSH0 MSTORE PUSH1 4 PUSH1 1c RETURN; returns hex"60205ff3"
// PUSH1 20 PUSH0 RETURN; reverts with zero address (technically the whole word is zero)
address deployed = deployer.deploy(1, hex"6360205ff35f526004601cf3");
assertNotEq(deployed, address(0));
assertEq(IFeeCollector(deployed).feeCollector(), address(0)); // technically all selectors return zero
}

function testDeployThenRevert() public {
deployer.setDescription(1, "nothing to see here");
deployer.authorize(1, address(this), uint96(block.timestamp + 1 days));
assertEq(deployer.feeCollector(1), address(0));
vm.expectRevert(abi.encodeWithSignature("DeployFailed()"));
// PUSH4 60205ffd PUSH0 MSTORE PUSH1 4 PUSH1 1c RETURN; returns hex"60205ffd"
// PUSH1 20 PUSH0 REVERT; reverts with zero word
deployer.deploy(1, hex"6360205ffd5f526004601cf3");
}

event Unsafe(uint128 indexed, uint64 indexed, address indexed);

function testSafeDeployment() public {
Expand Down

0 comments on commit f1f7d85

Please sign in to comment.