| 1 | // SPDX-License-Identifier: MIT |
| 2 | pragma solidity >=0.7.0 <0.9.0; |
| 3 | |
| 4 | import {StdConstants} from "../src/StdConstants.sol"; |
| 5 | import {Test} from "../src/Test.sol"; |
| 6 | |
| 7 | contract StdConstantsTest is Test { |
| 8 | function testVm() public view { |
| 9 | assertEq(StdConstants.VM.getBlockNumber(), 1); |
| 10 | } |
| 11 | |
| 12 | function testVmDerivation() public pure { |
| 13 | assertEq(address(StdConstants.VM), address(uint160(uint256(keccak256("hevm cheat code"))))); |
| 14 | } |
| 15 | |
| 16 | function testConsoleDerivation() public pure { |
| 17 | assertEq(StdConstants.CONSOLE, address(uint160(uint88(bytes11("console.log"))))); |
| 18 | } |
| 19 | |
| 20 | function testDefaultSender() public view { |
| 21 | assertEq(StdConstants.DEFAULT_SENDER, msg.sender); |
| 22 | } |
| 23 | |
| 24 | function testDefaultSenderDerivation() public pure { |
| 25 | assertEq(StdConstants.DEFAULT_SENDER, address(uint160(uint256(keccak256("foundry default caller"))))); |
| 26 | } |
| 27 | |
| 28 | function testDefaultTestContract() public { |
| 29 | assertEq(StdConstants.DEFAULT_TEST_CONTRACT, address(new Dummy())); |
| 30 | } |
| 31 | |
| 32 | function testDefaultTestContractDerivation() public view { |
| 33 | assertEq(address(this), StdConstants.VM.computeCreateAddress(StdConstants.DEFAULT_SENDER, 1)); |
| 34 | assertEq(StdConstants.DEFAULT_TEST_CONTRACT, StdConstants.VM.computeCreateAddress(address(this), 1)); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | contract Dummy {} |