diff --git a/testdata/default/cheats/AccessList.t.sol b/testdata/default/cheats/AccessList.t.sol index 4615ab588adba..00025459fe4fb 100644 --- a/testdata/default/cheats/AccessList.t.sol +++ b/testdata/default/cheats/AccessList.t.sol @@ -5,7 +5,7 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract AccessListIsolatedTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function test_access_list() public { Write anotherWrite = new Write(); @@ -19,7 +19,7 @@ contract AccessListIsolatedTest is DSTest { Vm.AccessListItem[] memory accessList = new Vm.AccessListItem[](1); bytes32[] memory readKeys = new bytes32[](0); accessList[0] = Vm.AccessListItem(address(anotherWrite), readKeys); - vm.accessList(accessList); + VM.accessList(accessList); uint256 initial1 = gasleft(); write.setNumber(2); @@ -30,7 +30,7 @@ contract AccessListIsolatedTest is DSTest { assertEq(initial2 - gasleft(), 29162); // reset access list, should take same gas as before setting - vm.noAccessList(); + VM.noAccessList(); uint256 initial4 = gasleft(); write.setNumber(4); assertEq(initial4 - gasleft(), 26762); @@ -39,7 +39,7 @@ contract AccessListIsolatedTest is DSTest { write.setNumber(5); assertEq(initial5 - gasleft(), 26762); - vm.accessList(accessList); + VM.accessList(accessList); uint256 initial6 = gasleft(); write.setNumber(6); assertEq(initial6 - gasleft(), 29162); diff --git a/testdata/default/cheats/AttachDelegation.t.sol b/testdata/default/cheats/AttachDelegation.t.sol index 3efc5f5229d19..84bed45c669ec 100644 --- a/testdata/default/cheats/AttachDelegation.t.sol +++ b/testdata/default/cheats/AttachDelegation.t.sol @@ -7,7 +7,7 @@ import "cheats/Vm.sol"; contract AttachDelegationTest is DSTest { event ExecutedBy(uint256 id); - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); uint256 alice_pk = 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d; address payable alice = payable(0x70997970C51812dc3A010C7d01b50e0d17dc79C8); uint256 bob_pk = 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a; @@ -24,13 +24,13 @@ contract AttachDelegationTest is DSTest { } function testCallSingleAttachDelegation() public { - Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk); + Vm.SignedDelegation memory signedDelegation = VM.signDelegation(address(implementation), alice_pk); SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](1); bytes memory data = abi.encodeCall(ERC20.mint, (100, bob)); calls[0] = SimpleDelegateContract.Call({to: address(token), data: data, value: 0}); // executing as bob to make clear that we don't need to execute the tx as alice - vm.broadcast(bob_pk); - vm.attachDelegation(signedDelegation); + VM.broadcast(bob_pk); + VM.attachDelegation(signedDelegation); bytes memory code = address(alice).code; require(code.length > 0, "no code written to alice"); @@ -40,13 +40,13 @@ contract AttachDelegationTest is DSTest { } function testCallSingleAttachCrossChainDelegation() public { - Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk, true); + Vm.SignedDelegation memory signedDelegation = VM.signDelegation(address(implementation), alice_pk, true); SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](1); bytes memory data = abi.encodeCall(ERC20.mint, (100, bob)); calls[0] = SimpleDelegateContract.Call({to: address(token), data: data, value: 0}); // executing as bob to make clear that we don't need to execute the tx as alice - vm.broadcast(bob_pk); - vm.attachDelegation(signedDelegation, true); + VM.broadcast(bob_pk); + VM.attachDelegation(signedDelegation, true); bytes memory code = address(alice).code; require(code.length > 0, "no code written to alice"); @@ -57,19 +57,19 @@ contract AttachDelegationTest is DSTest { /// forge-config: default.allow_internal_expect_revert = true function testCallSingleAttachDelegationWithNonce() public { - Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk, 11); - vm.broadcast(bob_pk); - vm._expectCheatcodeRevert("vm.attachDelegation: invalid nonce"); - vm.attachDelegation(signedDelegation); + Vm.SignedDelegation memory signedDelegation = VM.signDelegation(address(implementation), alice_pk, 11); + VM.broadcast(bob_pk); + VM._expectCheatcodeRevert("VM.attachDelegation: invalid nonce"); + VM.attachDelegation(signedDelegation); - signedDelegation = vm.signDelegation(address(implementation), alice_pk, 0); - vm.attachDelegation(signedDelegation); + signedDelegation = VM.signDelegation(address(implementation), alice_pk, 0); + VM.attachDelegation(signedDelegation); } function testMultiCallAttachDelegation() public { - Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk); - vm.broadcast(bob_pk); - vm.attachDelegation(signedDelegation); + Vm.SignedDelegation memory signedDelegation = VM.signDelegation(address(implementation), alice_pk); + VM.broadcast(bob_pk); + VM.attachDelegation(signedDelegation); SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](2); calls[0] = @@ -87,9 +87,9 @@ contract AttachDelegationTest is DSTest { } function testMultiCallAttachCrossChainDelegation() public { - Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk, true); - vm.broadcast(bob_pk); - vm.attachDelegation(signedDelegation, true); + Vm.SignedDelegation memory signedDelegation = VM.signDelegation(address(implementation), alice_pk, true); + VM.broadcast(bob_pk); + VM.attachDelegation(signedDelegation, true); SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](2); calls[0] = @@ -107,25 +107,25 @@ contract AttachDelegationTest is DSTest { } function testSwitchAttachDelegation() public { - Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk); + Vm.SignedDelegation memory signedDelegation = VM.signDelegation(address(implementation), alice_pk); SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](1); bytes memory data = abi.encodeCall(ERC20.mint, (100, bob)); calls[0] = SimpleDelegateContract.Call({to: address(token), data: data, value: 0}); - vm.broadcast(bob_pk); - vm.attachDelegation(signedDelegation); + VM.broadcast(bob_pk); + VM.attachDelegation(signedDelegation); - vm.expectEmit(true, true, true, true); + VM.expectEmit(true, true, true, true); emit ExecutedBy(1); SimpleDelegateContract(alice).execute(calls); // switch to implementation2 - Vm.SignedDelegation memory signedDelegation2 = vm.signDelegation(address(implementation2), alice_pk); - vm.broadcast(bob_pk); - vm.attachDelegation(signedDelegation2); + Vm.SignedDelegation memory signedDelegation2 = VM.signDelegation(address(implementation2), alice_pk); + VM.broadcast(bob_pk); + VM.attachDelegation(signedDelegation2); - vm.expectEmit(true, true, true, true); + VM.expectEmit(true, true, true, true); emit ExecutedBy(2); SimpleDelegateContract(alice).execute(calls); @@ -135,40 +135,40 @@ contract AttachDelegationTest is DSTest { /// forge-config: default.allow_internal_expect_revert = true function testAttachDelegationRevertInvalidSignature() public { - Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk); + Vm.SignedDelegation memory signedDelegation = VM.signDelegation(address(implementation), alice_pk); // change v from 1 to 0 signedDelegation.v = (signedDelegation.v + 1) % 2; - vm.attachDelegation(signedDelegation); + VM.attachDelegation(signedDelegation); SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](1); bytes memory data = abi.encodeCall(ERC20.mint, (100, bob)); calls[0] = SimpleDelegateContract.Call({to: address(token), data: data, value: 0}); - vm.broadcast(alice_pk); + VM.broadcast(alice_pk); // empty revert because no bytecode was set to Alice's account - vm.expectRevert(); + VM.expectRevert(); SimpleDelegateContract(alice).execute(calls); } function testAttachDelegationRevertsAfterNonceChange() public { - Vm.SignedDelegation memory signedDelegation = vm.signDelegation(address(implementation), alice_pk); + Vm.SignedDelegation memory signedDelegation = VM.signDelegation(address(implementation), alice_pk); - vm.broadcast(alice_pk); + VM.broadcast(alice_pk); // send tx to increment alice's nonce token.mint(1, bob); - vm._expectCheatcodeRevert("vm.attachDelegation: invalid nonce"); - vm.attachDelegation(signedDelegation); + VM._expectCheatcodeRevert("VM.attachDelegation: invalid nonce"); + VM.attachDelegation(signedDelegation); } function testCallSingleSignAndAttachDelegation() public { SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](1); bytes memory data = abi.encodeCall(ERC20.mint, (100, bob)); calls[0] = SimpleDelegateContract.Call({to: address(token), data: data, value: 0}); - vm.signAndAttachDelegation(address(implementation), alice_pk); + VM.signAndAttachDelegation(address(implementation), alice_pk); bytes memory code = address(alice).code; require(code.length > 0, "no code written to alice"); - vm.broadcast(bob_pk); + VM.broadcast(bob_pk); SimpleDelegateContract(alice).execute(calls); assertEq(token.balanceOf(bob), 100); @@ -178,10 +178,10 @@ contract AttachDelegationTest is DSTest { SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](1); bytes memory data = abi.encodeCall(ERC20.mint, (100, bob)); calls[0] = SimpleDelegateContract.Call({to: address(token), data: data, value: 0}); - vm.signAndAttachDelegation(address(implementation), alice_pk, true); + VM.signAndAttachDelegation(address(implementation), alice_pk, true); bytes memory code = address(alice).code; require(code.length > 0, "no code written to alice"); - vm.broadcast(bob_pk); + VM.broadcast(bob_pk); SimpleDelegateContract(alice).execute(calls); assertEq(token.balanceOf(bob), 100); @@ -189,15 +189,15 @@ contract AttachDelegationTest is DSTest { /// forge-config: default.allow_internal_expect_revert = true function testCallSingleSignAndAttachDelegationWithNonce() public { - vm._expectCheatcodeRevert("vm.signAndAttachDelegation: invalid nonce"); - vm.signAndAttachDelegation(address(implementation), alice_pk, 11); + VM._expectCheatcodeRevert("VM.signAndAttachDelegation: invalid nonce"); + VM.signAndAttachDelegation(address(implementation), alice_pk, 11); - vm.signAndAttachDelegation(address(implementation), alice_pk, 0); + VM.signAndAttachDelegation(address(implementation), alice_pk, 0); } function testMultipleDelegationsOnTransaction() public { - vm.signAndAttachDelegation(address(implementation), alice_pk); - vm.signAndAttachDelegation(address(implementation2), bob_pk); + VM.signAndAttachDelegation(address(implementation), alice_pk); + VM.signAndAttachDelegation(address(implementation2), bob_pk); SimpleDelegateContract.Call[] memory calls = new SimpleDelegateContract.Call[](2); calls[0] = SimpleDelegateContract.Call({ to: address(token), @@ -206,16 +206,16 @@ contract AttachDelegationTest is DSTest { }); calls[1] = SimpleDelegateContract.Call({to: address(token), data: abi.encodeCall(ERC20.mint, (50, alice)), value: 0}); - vm.broadcast(bob_pk); + VM.broadcast(bob_pk); SimpleDelegateContract(alice).execute(calls); assertEq(token.balanceOf(address(this)), 50); assertEq(token.balanceOf(alice), 50); - vm._expectCheatcodeRevert("vm.signAndAttachDelegation: invalid nonce"); - vm.signAndAttachDelegation(address(implementation), alice_pk, 1); - vm.signAndAttachDelegation(address(implementation), alice_pk, 0); - vm.signAndAttachDelegation(address(implementation2), bob_pk, 2); + VM._expectCheatcodeRevert("VM.signAndAttachDelegation: invalid nonce"); + VM.signAndAttachDelegation(address(implementation), alice_pk, 1); + VM.signAndAttachDelegation(address(implementation), alice_pk, 0); + VM.signAndAttachDelegation(address(implementation2), bob_pk, 2); } } diff --git a/testdata/default/cheats/Base64.t.sol b/testdata/default/cheats/Base64.t.sol index fad7bbf4f297c..b8942465bb25a 100644 --- a/testdata/default/cheats/Base64.t.sol +++ b/testdata/default/cheats/Base64.t.sol @@ -6,19 +6,19 @@ import "cheats/Vm.sol"; import "../logs/console.sol"; contract Base64Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function test_toBase64() public { bytes memory input = hex"00112233445566778899aabbccddeeff"; string memory expected = "ABEiM0RVZneImaq7zN3u/w=="; - string memory actual = vm.toBase64(input); + string memory actual = VM.toBase64(input); assertEq(actual, expected); } function test_toBase64URL() public { bytes memory input = hex"00112233445566778899aabbccddeeff"; string memory expected = "ABEiM0RVZneImaq7zN3u_w=="; - string memory actual = vm.toBase64URL(input); + string memory actual = VM.toBase64URL(input); assertEq(actual, expected); } } diff --git a/testdata/default/cheats/Broadcast.t.sol b/testdata/default/cheats/Broadcast.t.sol index 9916ca0efc799..7b4a5c260faf8 100644 --- a/testdata/default/cheats/Broadcast.t.sol +++ b/testdata/default/cheats/Broadcast.t.sol @@ -24,6 +24,7 @@ contract Test is DSTest { function inc() public returns (uint256) { changed += 1; + return changed; } function multiple_arguments(uint256 a, address b, uint256[] memory c) public returns (uint256) {} @@ -34,7 +35,7 @@ contract Test is DSTest { } contract BroadcastTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); // 1st anvil account address public ACCOUNT_A = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; @@ -42,62 +43,61 @@ contract BroadcastTest is DSTest { address public ACCOUNT_B = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; function deploy() public { - vm.broadcast(ACCOUNT_A); + VM.broadcast(ACCOUNT_A); Test test = new Test(); // this wont generate tx to sign - uint256 b = test.t(4); + test.t(4); // this will - vm.broadcast(ACCOUNT_B); + VM.broadcast(ACCOUNT_B); test.t(2); } function deployPrivateKey() public { string memory mnemonic = "test test test test test test test test test test test junk"; - uint256 privateKey = vm.deriveKey(mnemonic, 3); + uint256 privateKey = VM.deriveKey(mnemonic, 3); assertEq(privateKey, 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6); - vm.broadcast(privateKey); - Test test = new Test(); + VM.broadcast(privateKey); + new Test(); - vm.startBroadcast(privateKey); - Test test2 = new Test(); - vm.stopBroadcast(); + VM.startBroadcast(privateKey); + new Test(); + VM.stopBroadcast(); } function deployRememberKey() public { string memory mnemonic = "test test test test test test test test test test test junk"; - uint256 privateKey = vm.deriveKey(mnemonic, 3); + uint256 privateKey = VM.deriveKey(mnemonic, 3); assertEq(privateKey, 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6); - address thisAddress = vm.rememberKey(privateKey); + address thisAddress = VM.rememberKey(privateKey); assertEq(thisAddress, 0x90F79bf6EB2c4f870365E785982E1f101E93b906); - vm.broadcast(thisAddress); - Test test = new Test(); + VM.broadcast(thisAddress); + new Test(); } function deployRememberKeyResume() public { - vm.broadcast(ACCOUNT_A); - Test test = new Test(); + VM.broadcast(ACCOUNT_A); + new Test(); string memory mnemonic = "test test test test test test test test test test test junk"; - uint256 privateKey = vm.deriveKey(mnemonic, 3); - address thisAddress = vm.rememberKey(privateKey); + uint256 privateKey = VM.deriveKey(mnemonic, 3); + address thisAddress = VM.rememberKey(privateKey); - vm.broadcast(thisAddress); - Test test2 = new Test(); + VM.broadcast(thisAddress); + new Test(); } function deployOther() public { - vm.startBroadcast(ACCOUNT_A); - Test tmptest = new Test(); + VM.startBroadcast(ACCOUNT_A); + new Test(); // For original tmptest Test test = new Test(); - // won't trigger a transaction: staticcall test.changed(); @@ -110,20 +110,16 @@ contract BroadcastTest is DSTest { // will trigger a transaction test.inc(); - vm.stopBroadcast(); + VM.stopBroadcast(); - vm.broadcast(ACCOUNT_B); - Test tmptest2 = new Test(); - - vm.broadcast(ACCOUNT_B); - // will trigger a transaction + VM.broadcast(ACCOUNT_B); test.t(2); - vm.broadcast(ACCOUNT_B); + VM.broadcast(ACCOUNT_B); // will trigger a transaction from B payable(ACCOUNT_A).transfer(2); - vm.broadcast(ACCOUNT_B); + VM.broadcast(ACCOUNT_B); // will trigger a transaction test.inc(); @@ -131,32 +127,32 @@ contract BroadcastTest is DSTest { } function deployPanics() public { - vm.broadcast(address(0x1337)); + VM.broadcast(address(0x1337)); Test test = new Test(); // This panics because this would cause an additional relinking that isnt conceptually correct // from a solidity standpoint. Basically, this contract `BroadcastTest`, injects the code of // `Test` *into* its code. So it isn't reasonable to break solidity to our will of having *two* // versions of `Test` based on the sender/linker. - vm.broadcast(address(0x1338)); + VM.broadcast(address(0x1338)); new Test(); - vm.broadcast(address(0x1338)); + VM.broadcast(address(0x1338)); test.t(0); } function deployNoArgs() public { - vm.startBroadcast(); - Test test1 = new Test(); + VM.startBroadcast(); + new Test(); - Test test2 = new Test(); - vm.stopBroadcast(); + new Test(); + VM.stopBroadcast(); } /// forge-config: default.allow_internal_expect_revert = true // function testRevertIfNoBroadcast() public { - // vm.expectRevert(); - // vm.stopBroadcast(); + // VM.expectRevert(); + // VM.stopBroadcast(); // } } @@ -180,7 +176,7 @@ interface INoLink { } contract BroadcastTestNoLinking is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); // ganache-cli -d 1st address public ACCOUNT_A = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; @@ -189,38 +185,38 @@ contract BroadcastTestNoLinking is DSTest { address public ACCOUNT_B = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; function deployDoesntPanic() public { - vm.broadcast(address(ACCOUNT_A)); + VM.broadcast(address(ACCOUNT_A)); NoLink test = new NoLink(); - vm.broadcast(address(ACCOUNT_B)); + VM.broadcast(address(ACCOUNT_B)); new NoLink(); - vm.broadcast(address(ACCOUNT_B)); + VM.broadcast(address(ACCOUNT_B)); test.t(0); } function deployMany() public { - assert(vm.getNonce(msg.sender) == 0); + assert(VM.getNonce(msg.sender) == 0); - vm.startBroadcast(); + VM.startBroadcast(); for (uint256 i; i < 25; i++) { - NoLink test9 = new NoLink(); + new NoLink(); } - vm.stopBroadcast(); + VM.stopBroadcast(); } function deployCreate2() public { - vm.startBroadcast(); + VM.startBroadcast(); NoLink test_c2 = new NoLink{salt: bytes32(uint256(1337))}(); assert(test_c2.view_me() == 1337); - NoLink test2 = new NoLink(); - vm.stopBroadcast(); + new NoLink(); + VM.stopBroadcast(); } function deployCreate2(address deployer) public { - vm.startBroadcast(); + VM.startBroadcast(); bytes32 salt = bytes32(uint256(1338)); NoLink test_c2 = new NoLink{salt: salt}(); assert(test_c2.view_me() == 1337); @@ -241,21 +237,21 @@ contract BroadcastTestNoLinking is DSTest { ); require(address(test_c2) == expectedAddress, "Create2 address mismatch"); - NoLink test2 = new NoLink(); - vm.stopBroadcast(); + new NoLink(); + VM.stopBroadcast(); } function errorStaticCall() public { - vm.broadcast(); + VM.broadcast(); NoLink test11 = new NoLink(); - vm.broadcast(); + VM.broadcast(); test11.view_me(); } } contract BroadcastMix is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); // ganache-cli -d 1st address public ACCOUNT_A = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; @@ -264,89 +260,89 @@ contract BroadcastMix is DSTest { address public ACCOUNT_B = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; function more() internal { - vm.broadcast(); - NoLink test11 = new NoLink(); + VM.broadcast(); + new NoLink(); } function deployMix() public { address user = msg.sender; assert(user == address(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)); - NoLink no = new NoLink(); + new NoLink(); - vm.startBroadcast(); + VM.startBroadcast(); NoLink test1 = new NoLink(); test1.t(2); NoLink test2 = new NoLink(); test2.t(2); - vm.stopBroadcast(); + VM.stopBroadcast(); - vm.startBroadcast(user); - NoLink test3 = new NoLink(); + VM.startBroadcast(user); + new NoLink(); NoLink test4 = new NoLink(); test4.t(2); - vm.stopBroadcast(); + VM.stopBroadcast(); - vm.broadcast(); + VM.broadcast(); test4.t(2); - vm.broadcast(); - NoLink test5 = new NoLink(); + VM.broadcast(); + new NoLink(); - vm.broadcast(); - INoLink test6 = INoLink(address(new NoLink())); + VM.broadcast(); + new NoLink(); - vm.broadcast(); - NoLink test7 = new NoLink(); + VM.broadcast(); + new NoLink(); - vm.broadcast(user); - NoLink test8 = new NoLink(); + VM.broadcast(user); + new NoLink(); - vm.broadcast(); - NoLink test9 = new NoLink(); + VM.broadcast(); + new NoLink(); - vm.broadcast(user); - NoLink test10 = new NoLink(); + VM.broadcast(user); + new NoLink(); more(); } } contract BroadcastTestSetup is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function setUp() public { // It predeployed a library first - assert(vm.getNonce(msg.sender) == 1); + assert(VM.getNonce(msg.sender) == 1); - vm.broadcast(); + VM.broadcast(); Test t = new Test(); - vm.broadcast(); + VM.broadcast(); t.t(2); } function run() public { - vm.broadcast(); + VM.broadcast(); new NoLink(); - vm.broadcast(); + VM.broadcast(); Test t = new Test(); - vm.broadcast(); + VM.broadcast(); t.t(3); } } contract BroadcastTestLog is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function run() public { uint256[] memory arr = new uint256[](2); arr[0] = 3; arr[1] = 4; - vm.startBroadcast(); + VM.startBroadcast(); { Test c1 = new Test(); Test c2 = new Test{salt: bytes32(uint256(1337))}(); @@ -357,12 +353,12 @@ contract BroadcastTestLog is DSTest { payable(address(0x1337)).transfer(0.0001 ether); } - vm.stopBroadcast(); + VM.stopBroadcast(); } } contract TestInitialBalance is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function runCustomSender() public { // Make sure we're testing a different caller than the default one. @@ -371,7 +367,7 @@ contract TestInitialBalance is DSTest { // NodeConfig::test() sets the balance of the address used in this test to 100 ether. assert(msg.sender.balance == 100 ether); - vm.broadcast(); + VM.broadcast(); new NoLink(); } @@ -381,13 +377,13 @@ contract TestInitialBalance is DSTest { assert(msg.sender.balance == type(uint256).max); - vm.broadcast(); + VM.broadcast(); new NoLink(); } } contract MultiChainBroadcastNoLink is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); // ganache-cli -d 1st address public ACCOUNT_A = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; @@ -396,43 +392,43 @@ contract MultiChainBroadcastNoLink is DSTest { address public ACCOUNT_B = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; function deploy(string memory sforkA, string memory sforkB) public { - uint256 forkA = vm.createFork(sforkA); - uint256 forkB = vm.createFork(sforkB); + uint256 forkA = VM.createFork(sforkA); + uint256 forkB = VM.createFork(sforkB); - vm.selectFork(forkA); - vm.broadcast(address(ACCOUNT_A)); + VM.selectFork(forkA); + VM.broadcast(address(ACCOUNT_A)); new NoLink(); - vm.broadcast(address(ACCOUNT_B)); + VM.broadcast(address(ACCOUNT_B)); new NoLink(); - vm.selectFork(forkB); - vm.startBroadcast(address(ACCOUNT_B)); + VM.selectFork(forkB); + VM.startBroadcast(address(ACCOUNT_B)); new NoLink(); new NoLink(); new NoLink(); - vm.stopBroadcast(); - vm.startBroadcast(address(ACCOUNT_A)); + VM.stopBroadcast(); + VM.startBroadcast(address(ACCOUNT_A)); new NoLink(); new NoLink(); } function deployError(string memory sforkA, string memory sforkB) public { - uint256 forkA = vm.createFork(sforkA); - uint256 forkB = vm.createFork(sforkB); + uint256 forkA = VM.createFork(sforkA); + uint256 forkB = VM.createFork(sforkB); - vm.selectFork(forkA); - vm.broadcast(address(ACCOUNT_A)); + VM.selectFork(forkA); + VM.broadcast(address(ACCOUNT_A)); new NoLink(); - vm.startBroadcast(address(ACCOUNT_B)); + VM.startBroadcast(address(ACCOUNT_B)); new NoLink(); - vm.selectFork(forkB); - vm.broadcast(address(ACCOUNT_B)); + VM.selectFork(forkB); + VM.broadcast(address(ACCOUNT_B)); new NoLink(); } } contract MultiChainBroadcastLink is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); // ganache-cli -d 1st address public ACCOUNT_A = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; @@ -441,26 +437,26 @@ contract MultiChainBroadcastLink is DSTest { address public ACCOUNT_B = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; function deploy(string memory sforkA, string memory sforkB) public { - uint256 forkA = vm.createFork(sforkA); - uint256 forkB = vm.createFork(sforkB); + uint256 forkA = VM.createFork(sforkA); + uint256 forkB = VM.createFork(sforkB); - vm.selectFork(forkA); - vm.broadcast(address(ACCOUNT_B)); + VM.selectFork(forkA); + VM.broadcast(address(ACCOUNT_B)); new Test(); - vm.selectFork(forkB); - vm.broadcast(address(ACCOUNT_B)); + VM.selectFork(forkB); + VM.broadcast(address(ACCOUNT_B)); new Test(); } } contract BroadcastEmptySetUp is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function setUp() public {} function run() public { - vm.broadcast(); + VM.broadcast(); new Test(); } } @@ -496,7 +492,7 @@ contract ContractB { } contract CheckOverrides is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function run() external { // `script_caller` can be set by `--private-key ...` or `--sender ...` @@ -506,7 +502,7 @@ contract CheckOverrides is DSTest { require(tx.origin == script_caller); // startBroadcast(script_caller) - vm.startBroadcast(); + VM.startBroadcast(); require(tx.origin == script_caller); require(msg.sender == script_caller); @@ -518,10 +514,10 @@ contract CheckOverrides is DSTest { require(tx.origin == script_caller); require(msg.sender == script_caller); - vm.stopBroadcast(); + VM.stopBroadcast(); // startBroadcast(msg.sender) - vm.startBroadcast(address(0x1337)); + VM.startBroadcast(address(0x1337)); require(tx.origin == script_caller); require(msg.sender == script_caller); require(msg.sender != address(0x1337)); @@ -534,7 +530,7 @@ contract CheckOverrides is DSTest { require(tx.origin == script_caller); require(msg.sender == script_caller); - vm.stopBroadcast(); + VM.stopBroadcast(); } } @@ -547,10 +543,10 @@ contract Parent { } contract ScriptAdditionalContracts is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function run() external { - vm.startBroadcast(); + VM.startBroadcast(); new Parent(); } } @@ -564,28 +560,29 @@ contract SignatureTester { function verifySignature(bytes32 digest, uint8 v, bytes32 r, bytes32 s) public view returns (bool) { require(ecrecover(digest, v, r, s) == owner, "Invalid signature"); + return true; } } contract ScriptSign is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); bytes32 digest = keccak256("something"); function run() external { - vm.startBroadcast(); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(digest); + VM.startBroadcast(); + (uint8 v, bytes32 r, bytes32 s) = VM.sign(digest); SignatureTester tester = new SignatureTester(); - (, address caller,) = vm.readCallers(); + (, address caller,) = VM.readCallers(); assertEq(tester.owner(), caller); tester.verifySignature(digest, v, r, s); } function run(address sender) external { - vm._expectCheatcodeRevert(bytes("could not determine signer")); - vm.sign(digest); + VM._expectCheatcodeRevert(bytes("could not determine signer")); + VM.sign(digest); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(sender, digest); + (uint8 v, bytes32 r, bytes32 s) = VM.sign(sender, digest); address actual = ecrecover(digest, v, r, s); assertEq(actual, sender); diff --git a/testdata/default/cheats/Deal.t.sol b/testdata/default/cheats/Deal.t.sol index a46d9e7140e3e..9d07e2fad7bae 100644 --- a/testdata/default/cheats/Deal.t.sol +++ b/testdata/default/cheats/Deal.t.sol @@ -5,18 +5,18 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract DealTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testDeal(uint256 amount) public { address target = address(10); assertEq(target.balance, 0, "initial balance incorrect"); // Give half the amount - vm.deal(target, amount / 2); + VM.deal(target, amount / 2); assertEq(target.balance, amount / 2, "half balance is incorrect"); // Give the entire amount to check that deal is not additive - vm.deal(target, amount); + VM.deal(target, amount); assertEq(target.balance, amount, "deal did not overwrite balance"); } } diff --git a/testdata/default/cheats/ExpectCall.t.sol b/testdata/default/cheats/ExpectCall.t.sol index 01a95b4277e01..7ba75e838833e 100644 --- a/testdata/default/cheats/ExpectCall.t.sol +++ b/testdata/default/cheats/ExpectCall.t.sol @@ -61,7 +61,7 @@ contract ProxyWithDelegateCall { } contract ExpectCallTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function exposed_callTargetNTimes(Contract target, uint256 a, uint256 b, uint256 times) public { for (uint256 i = 0; i < times; i++) { @@ -75,35 +75,35 @@ contract ExpectCallTest is DSTest { function testExpectCallWithData() public { Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); this.exposed_callTargetNTimes(target, 1, 2, 1); } function testExpectMultipleCallsWithData() public { Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); // Even though we expect one call, we're using additive behavior, so getting more than one call is okay. this.exposed_callTargetNTimes(target, 1, 2, 2); } function testExpectMultipleCallsWithDataAdditive() public { Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); this.exposed_callTargetNTimes(target, 1, 2, 2); } function testExpectMultipleCallsWithDataAdditiveLowerBound() public { Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); this.exposed_callTargetNTimes(target, 1, 2, 3); } function testExpectInnerCall() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCall(address(inner), abi.encodeWithSelector(inner.numberB.selector)); + VM.expectCall(address(inner), abi.encodeWithSelector(inner.numberB.selector)); this.exposed_expectInnerCall(target); } @@ -122,8 +122,8 @@ contract ExpectCallTest is DSTest { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCall(address(target), abi.encodeWithSelector(target.forwardPay.selector)); - vm.expectCall(address(inner), abi.encodeWithSelector(inner.pay.selector)); + VM.expectCall(address(target), abi.encodeWithSelector(target.forwardPay.selector)); + VM.expectCall(address(inner), abi.encodeWithSelector(inner.pay.selector)); this.exposed_forwardPay(target); } @@ -133,8 +133,8 @@ contract ExpectCallTest is DSTest { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCall(address(target), abi.encodeWithSelector(target.sumInPlace.selector)); - vm.expectCall(address(inner), abi.encodeWithSelector(inner.add.selector)); + VM.expectCall(address(target), abi.encodeWithSelector(target.sumInPlace.selector)); + VM.expectCall(address(inner), abi.encodeWithSelector(inner.add.selector)); this.exposed_expectCallMultipleFunctionsFlattened(target, inner); } @@ -145,26 +145,26 @@ contract ExpectCallTest is DSTest { function testExpectSelectorCall() public { Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector)); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector)); this.exposed_callTargetNTimes(target, 5, 5, 1); } function testExpectCallWithValue() public { Contract target = new Contract(); - vm.expectCall(address(target), 1, abi.encodeWithSelector(target.pay.selector, 2)); + VM.expectCall(address(target), 1, abi.encodeWithSelector(target.pay.selector, 2)); this.exposed_expectCallWithValue(target, 1, 2); } function testExpectCallWithValueWithoutParameters() public { Contract target = new Contract(); - vm.expectCall(address(target), 3, abi.encodeWithSelector(target.pay.selector)); + VM.expectCall(address(target), 3, abi.encodeWithSelector(target.pay.selector)); this.exposed_expectCallWithValue(target, 3, 100); } function testExpectCallWithValueAndGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCall(address(inner), 1, 50_000, abi.encodeWithSelector(inner.pay.selector, 1)); + VM.expectCall(address(inner), 1, 50_000, abi.encodeWithSelector(inner.pay.selector, 1)); this.exposed_forwardPay(target); } @@ -175,7 +175,7 @@ contract ExpectCallTest is DSTest { function testExpectCallWithNoValueAndGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCall(address(inner), 0, 50_000, abi.encodeWithSelector(inner.add.selector, 1, 1)); + VM.expectCall(address(inner), 0, 50_000, abi.encodeWithSelector(inner.add.selector, 1, 1)); this.exposed_addHardGasLimit(target); } @@ -186,14 +186,14 @@ contract ExpectCallTest is DSTest { function testExpectCallWithValueAndMinGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCallMinGas(address(inner), 1, 50_000, abi.encodeWithSelector(inner.pay.selector, 1)); + VM.expectCallMinGas(address(inner), 1, 50_000, abi.encodeWithSelector(inner.pay.selector, 1)); this.exposed_forwardPay(target); } function testExpectCallWithNoValueAndMinGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCallMinGas(address(inner), 0, 25_000, abi.encodeWithSelector(inner.add.selector, 1, 1)); + VM.expectCallMinGas(address(inner), 0, 25_000, abi.encodeWithSelector(inner.add.selector, 1, 1)); this.exposed_addHardGasLimit(target); } @@ -201,17 +201,17 @@ contract ExpectCallTest is DSTest { function testExpectCallForProxyDelegateCall() public { ProxyWithDelegateCall proxyWithDelegateCall = new ProxyWithDelegateCall(); SimpleCall simpleCall = new SimpleCall(); - vm.expectCall(address(simpleCall), abi.encodeWithSignature("call()")); + VM.expectCall(address(simpleCall), abi.encodeWithSignature("call()")); proxyWithDelegateCall.delegateCall(simpleCall); } } contract ExpectCallCountTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testExpectCallCountWithData() public { Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(Contract.add.selector, 1, 2), 3); + VM.expectCall(address(target), abi.encodeWithSelector(Contract.add.selector, 1, 2), 3); this.exposed_expectCallCountWithData(target); } @@ -223,21 +223,21 @@ contract ExpectCallCountTest is DSTest { function testExpectZeroCallCountAssert() public { Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 0); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 0); target.add(3, 3); } function testExpectCountInnerCall() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCall(address(inner), abi.encodeWithSelector(inner.numberB.selector), 1); + VM.expectCall(address(inner), abi.encodeWithSelector(inner.numberB.selector), 1); target.sum(); } function testExpectCountInnerAndOuterCalls() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCall(address(inner), abi.encodeWithSelector(inner.numberB.selector), 2); + VM.expectCall(address(inner), abi.encodeWithSelector(inner.numberB.selector), 2); this.exposed_expectCountInnerAndOuterCalls(inner, target); } @@ -252,19 +252,19 @@ contract ExpectCallCountTest is DSTest { function testExpectCallCountWithValue() public { Contract target = new Contract(); - vm.expectCall(address(target), 1, abi.encodeWithSelector(target.pay.selector, 2), 1); + VM.expectCall(address(target), 1, abi.encodeWithSelector(target.pay.selector, 2), 1); this.exposed_pay{value: 1}(target, 1, 2); } function testExpectZeroCallCountValue() public { Contract target = new Contract(); - vm.expectCall(address(target), 1, abi.encodeWithSelector(target.pay.selector, 2), 0); + VM.expectCall(address(target), 1, abi.encodeWithSelector(target.pay.selector, 2), 0); this.exposed_pay{value: 2}(target, 2, 2); } function testExpectCallCountWithValueWithoutParameters() public { Contract target = new Contract(); - vm.expectCall(address(target), 3, abi.encodeWithSelector(target.pay.selector), 3); + VM.expectCall(address(target), 3, abi.encodeWithSelector(target.pay.selector), 3); this.exposed_expectCallCountWithValueWithoutParameters(target); } @@ -277,7 +277,7 @@ contract ExpectCallCountTest is DSTest { function testExpectCallCountWithValueAndGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCall(address(inner), 1, 50_000, abi.encodeWithSelector(inner.pay.selector, 1), 2); + VM.expectCall(address(inner), 1, 50_000, abi.encodeWithSelector(inner.pay.selector, 1), 2); this.exposed_expectCallCountWithValueAndGas(target); } @@ -295,21 +295,21 @@ contract ExpectCallCountTest is DSTest { function testExpectCallCountWithNoValueAndGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCall(address(inner), 0, 50_000, abi.encodeWithSelector(inner.add.selector, 1, 1), 1); + VM.expectCall(address(inner), 0, 50_000, abi.encodeWithSelector(inner.add.selector, 1, 1), 1); this.exposed_addHardGasLimit(target, 1); } function testExpectZeroCallCountWithNoValueAndWrongGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCall(address(inner), 0, 25_000, abi.encodeWithSelector(inner.add.selector, 1, 1), 0); + VM.expectCall(address(inner), 0, 25_000, abi.encodeWithSelector(inner.add.selector, 1, 1), 0); this.exposed_addHardGasLimit(target, 1); } function testExpectCallCountWithValueAndMinGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCallMinGas(address(inner), 1, 50_000, abi.encodeWithSelector(inner.pay.selector, 1), 1); + VM.expectCallMinGas(address(inner), 1, 50_000, abi.encodeWithSelector(inner.pay.selector, 1), 1); this.exposed_forwardPay(target); } @@ -320,20 +320,20 @@ contract ExpectCallCountTest is DSTest { function testExpectCallCountWithNoValueAndMinGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCallMinGas(address(inner), 0, 25_000, abi.encodeWithSelector(inner.add.selector, 1, 1), 2); + VM.expectCallMinGas(address(inner), 0, 25_000, abi.encodeWithSelector(inner.add.selector, 1, 1), 2); this.exposed_addHardGasLimit(target, 2); } function testExpectCallZeroCountWithNoValueAndWrongMinGas() public { Contract inner = new Contract(); NestedContract target = new NestedContract(inner); - vm.expectCallMinGas(address(inner), 0, 50_001, abi.encodeWithSelector(inner.add.selector, 1, 1), 0); + VM.expectCallMinGas(address(inner), 0, 50_001, abi.encodeWithSelector(inner.add.selector, 1, 1), 0); this.exposed_addHardGasLimit(target, 1); } } contract ExpectCallMixedTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function exposed_callTargetNTimes(Contract target, uint256 a, uint256 b, uint256 times) public { for (uint256 i = 0; i < times; i++) { @@ -343,10 +343,10 @@ contract ExpectCallMixedTest is DSTest { function testExpectMatchPartialAndFull() public { Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector), 2); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector), 2); // Even if a partial match is specified, you should still be able to look for full matches // as one does not override the other. - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2)); this.exposed_expectMatchPartialAndFull(target); } @@ -357,10 +357,10 @@ contract ExpectCallMixedTest is DSTest { function testExpectMatchPartialAndFullFlipped() public { Contract target = new Contract(); - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector)); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector)); // Even if a partial match is specified, you should still be able to look for full matches // as one does not override the other. - vm.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 2); + VM.expectCall(address(target), abi.encodeWithSelector(target.add.selector, 1, 2), 2); this.exposed_expectMatchPartialAndFullFlipped(target); } diff --git a/testdata/default/cheats/ExpectRevert.t.sol b/testdata/default/cheats/ExpectRevert.t.sol index 5ae262a4fd455..df5dba5ba6d7c 100644 --- a/testdata/default/cheats/ExpectRevert.t.sol +++ b/testdata/default/cheats/ExpectRevert.t.sol @@ -72,7 +72,7 @@ contract Dummy { } contract ExpectRevertTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function shouldRevert() internal { revert(); @@ -80,100 +80,100 @@ contract ExpectRevertTest is DSTest { function testExpectRevertString() public { Reverter reverter = new Reverter(); - vm.expectRevert("revert"); + VM.expectRevert("revert"); reverter.revertWithMessage("revert"); } function testExpectRevertWithEncodedErrorPrefix() public { Reverter reverter = new Reverter(); - vm.expectRevert(abi.encodeWithSignature("Error(string)", "my revert reason")); + VM.expectRevert(abi.encodeWithSignature("Error(string)", "my revert reason")); reverter.revertWithMessage("my revert reason"); - vm.expectRevert(abi.encodeWithSignature("Error(string)", "A")); + VM.expectRevert(abi.encodeWithSignature("Error(string)", "A")); reverter.revertWithMessage("A"); - vm.expectRevert(abi.encodeWithSignature("Error(string)", "revert: A")); + VM.expectRevert(abi.encodeWithSignature("Error(string)", "revert: A")); reverter.revertWithMessage("revert: A"); } function testShouldFailIfExpectRevertWrongString() public { Reverter reverter = new Reverter(); - vm.expectRevert("my not so cool error", 0); + VM.expectRevert("my not so cool error", 0); reverter.revertWithMessage("my cool error"); } function testExpectRevertConstructor() public { - vm.expectRevert("constructor revert"); + VM.expectRevert("constructor revert"); new ConstructorReverter("constructor revert"); } function testExpectRevertBuiltin() public { Reverter reverter = new Reverter(); - vm.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x11)); + VM.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x11)); reverter.panic(); } function testExpectRevertCustomError() public { Reverter reverter = new Reverter(); - vm.expectRevert(abi.encodePacked(Reverter.CustomError.selector)); + VM.expectRevert(abi.encodePacked(Reverter.CustomError.selector)); reverter.revertWithCustomError(); } function testExpectRevertNested() public { Reverter reverter = new Reverter(); Reverter inner = new Reverter(); - vm.expectRevert("nested revert"); + VM.expectRevert("nested revert"); reverter.nestedRevert(inner, "nested revert"); } function testExpectRevertCallsThenReverts() public { Reverter reverter = new Reverter(); Dummy dummy = new Dummy(); - vm.expectRevert("called a function and then reverted"); + VM.expectRevert("called a function and then reverted"); reverter.callThenRevert(dummy, "called a function and then reverted"); } function testDummyReturnDataForBigType() public { Dummy dummy = new Dummy(); - vm.expectRevert("reverted with large return type"); + VM.expectRevert("reverted with large return type"); dummy.largeReturnType(); } function testExpectRevertNoReason() public { Reverter reverter = new Reverter(); - vm.expectRevert(bytes("")); + VM.expectRevert(bytes("")); reverter.revertWithoutReason(); } function testExpectRevertAnyRevert() public { - vm.expectRevert(); + VM.expectRevert(); new ConstructorReverter("hello this is a revert message"); Reverter reverter = new Reverter(); - vm.expectRevert(); + VM.expectRevert(); reverter.revertWithMessage("this is also a revert message"); - vm.expectRevert(); + VM.expectRevert(); reverter.panic(); - vm.expectRevert(); + VM.expectRevert(); reverter.revertWithCustomError(); Reverter reverter2 = new Reverter(); - vm.expectRevert(); + VM.expectRevert(); reverter.nestedRevert(reverter2, "this too is a revert message"); Dummy dummy = new Dummy(); - vm.expectRevert(); + VM.expectRevert(); reverter.callThenRevert(dummy, "revert message 4 i ran out of synonims for also"); - vm.expectRevert(); + VM.expectRevert(); reverter.revertWithoutReason(); } function testexpectCheatcodeRevert() public { - vm._expectCheatcodeRevert('JSON value at ".a" is not an object'); - vm.parseJsonKeys('{"a": "b"}', ".a"); + VM._expectCheatcodeRevert('JSON value at ".a" is not an object'); + VM.parseJsonKeys('{"a": "b"}', ".a"); } } @@ -270,7 +270,7 @@ contract DContract { } contract ExpectRevertWithReverterTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); error CContractError(string reason); @@ -286,64 +286,64 @@ contract ExpectRevertWithReverterTest is DSTest { function testExpectRevertsWithReverter() public { // Test expect revert with reverter at first call. - vm.expectRevert(address(aContract)); + VM.expectRevert(address(aContract)); aContract.callAndRevert(); // Test expect revert with reverter at second subcall. - vm.expectRevert(address(bContract)); + VM.expectRevert(address(bContract)); aContract.callAndRevertInBContract(); // Test expect revert with partial data match and reverter at third subcall. - vm.expectPartialRevert(CContractError.selector, address(cContract)); + VM.expectPartialRevert(CContractError.selector, address(cContract)); aContract.callAndRevertInCContractThroughBContract(); // Test expect revert with exact data match and reverter at second subcall. - vm.expectRevert(abi.encodeWithSelector(CContractError.selector, "Reverted by CContract"), address(cContract)); + VM.expectRevert(abi.encodeWithSelector(CContractError.selector, "Reverted by CContract"), address(cContract)); aContract.callAndRevertInCContract(); } function testExpectRevertsWithReverterInConstructor() public { // Test expect revert with reverter when constructor reverts. - vm.expectRevert(abi.encodePacked("Reverted by DContract"), address(cContract)); + VM.expectRevert(abi.encodePacked("Reverted by DContract"), address(cContract)); cContract.createDContract(); - vm.expectRevert(address(bContract)); + VM.expectRevert(address(bContract)); bContract.createDContract(); - vm.expectRevert(address(cContract)); + VM.expectRevert(address(cContract)); bContract.createDContractThroughCContract(); - vm.expectRevert(address(aContract)); + VM.expectRevert(address(aContract)); aContract.createDContract(); - vm.expectRevert(address(bContract)); + VM.expectRevert(address(bContract)); aContract.createDContractThroughBContract(); - vm.expectRevert(address(cContract)); + VM.expectRevert(address(cContract)); aContract.createDContractThroughCContract(); } } contract ExpectRevertCount is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testRevertCountAny() public { uint64 count = 3; Reverter reverter = new Reverter(); - vm.expectRevert(count); + VM.expectRevert(count); reverter.revertWithMessage("revert"); reverter.revertWithMessage("revert2"); reverter.revertWithMessage("revert3"); - vm.expectRevert("revert"); + VM.expectRevert("revert"); reverter.revertWithMessage("revert"); } function testNoRevert() public { uint64 count = 0; Reverter reverter = new Reverter(); - vm.expectRevert(count); + VM.expectRevert(count); reverter.doNotRevert(); } function testRevertCountSpecific() public { uint64 count = 2; Reverter reverter = new Reverter(); - vm.expectRevert("revert", count); + VM.expectRevert("revert", count); reverter.revertWithMessage("revert"); reverter.revertWithMessage("revert"); } @@ -351,26 +351,26 @@ contract ExpectRevertCount is DSTest { function testNoRevertSpecific() public { uint64 count = 0; Reverter reverter = new Reverter(); - vm.expectRevert("revert", count); + VM.expectRevert("revert", count); reverter.doNotRevert(); } function testNoRevertSpecificButDiffRevert() public { uint64 count = 0; Reverter reverter = new Reverter(); - vm.expectRevert("revert", count); + VM.expectRevert("revert", count); reverter.revertWithMessage("revert2"); } function testRevertCountWithConstructor() public { uint64 count = 1; - vm.expectRevert("constructor revert", count); + VM.expectRevert("constructor revert", count); new ConstructorReverter("constructor revert"); } function testNoRevertWithConstructor() public { uint64 count = 0; - vm.expectRevert("constructor revert", count); + VM.expectRevert("constructor revert", count); new CContract(); } @@ -379,11 +379,11 @@ contract ExpectRevertCount is DSTest { Reverter reverter = new Reverter(); Reverter inner = new Reverter(); - vm.expectRevert("nested revert", count); + VM.expectRevert("nested revert", count); reverter.revertWithMessage("nested revert"); reverter.nestedRevert(inner, "nested revert"); - vm.expectRevert("nested revert", count); + VM.expectRevert("nested revert", count); reverter.nestedRevert(inner, "nested revert"); reverter.nestedRevert(inner, "nested revert"); } @@ -393,7 +393,7 @@ contract ExpectRevertCount is DSTest { Reverter reverter = new Reverter(); Dummy dummy = new Dummy(); - vm.expectRevert("called a function and then reverted", count); + VM.expectRevert("called a function and then reverted", count); reverter.callThenRevert(dummy, "called a function and then reverted"); reverter.callThenRevert(dummy, "called a function and then reverted"); } @@ -403,18 +403,18 @@ contract ExpectRevertCount is DSTest { Reverter reverter = new Reverter(); Dummy dummy = new Dummy(); - vm.expectRevert("called a function and then reverted", count); + VM.expectRevert("called a function and then reverted", count); reverter.callThenNoRevert(dummy); } } contract ExpectRevertCountWithReverter is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testRevertCountWithReverter() public { uint64 count = 2; Reverter reverter = new Reverter(); - vm.expectRevert(address(reverter), count); + VM.expectRevert(address(reverter), count); reverter.revertWithMessage("revert"); reverter.revertWithMessage("revert"); } @@ -422,7 +422,7 @@ contract ExpectRevertCountWithReverter is DSTest { function testNoRevertWithReverter() public { uint64 count = 0; Reverter reverter = new Reverter(); - vm.expectRevert(address(reverter), count); + VM.expectRevert(address(reverter), count); reverter.doNotRevert(); } @@ -430,14 +430,14 @@ contract ExpectRevertCountWithReverter is DSTest { uint64 count = 0; Reverter reverter = new Reverter(); Reverter reverter2 = new Reverter(); - vm.expectRevert(address(reverter), count); + VM.expectRevert(address(reverter), count); reverter2.revertWithMessage("revert"); // revert from wrong reverter } function testReverterCountWithData() public { uint64 count = 2; Reverter reverter = new Reverter(); - vm.expectRevert("revert", address(reverter), count); + VM.expectRevert("revert", address(reverter), count); reverter.revertWithMessage("revert"); reverter.revertWithMessage("revert"); } @@ -445,10 +445,10 @@ contract ExpectRevertCountWithReverter is DSTest { function testNoReverterCountWithData() public { uint64 count = 0; Reverter reverter = new Reverter(); - vm.expectRevert("revert", address(reverter), count); + VM.expectRevert("revert", address(reverter), count); reverter.doNotRevert(); - vm.expectRevert("revert", address(reverter), count); + VM.expectRevert("revert", address(reverter), count); reverter.revertWithMessage("revert2"); } } diff --git a/testdata/default/cheats/Fee.t.sol b/testdata/default/cheats/Fee.t.sol index 120627c0004e9..7012b25c589fc 100644 --- a/testdata/default/cheats/Fee.t.sol +++ b/testdata/default/cheats/Fee.t.sol @@ -5,15 +5,15 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract FeeTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testFee() public { - vm.fee(10); + VM.fee(10); assertEq(block.basefee, 10, "fee failed"); } function testFeeFuzzed(uint64 fee) public { - vm.fee(fee); + VM.fee(fee); assertEq(block.basefee, fee, "fee failed"); } } diff --git a/testdata/default/cheats/Ffi.t.sol b/testdata/default/cheats/Ffi.t.sol index 23ac54e6ace12..1a3b4acc67911 100644 --- a/testdata/default/cheats/Ffi.t.sol +++ b/testdata/default/cheats/Ffi.t.sol @@ -5,7 +5,7 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract FfiTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testFfi() public { string[] memory inputs = new string[](3); @@ -14,7 +14,7 @@ contract FfiTest is DSTest { inputs[2] = "echo -n 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000966666920776f726b730000000000000000000000000000000000000000000000"; - bytes memory res = vm.ffi(inputs); + bytes memory res = VM.ffi(inputs); (string memory output) = abi.decode(res, (string)); assertEq(output, "ffi works", "ffi failed"); } @@ -25,7 +25,7 @@ contract FfiTest is DSTest { inputs[1] = "-n"; inputs[2] = "gm"; - bytes memory res = vm.ffi(inputs); + bytes memory res = VM.ffi(inputs); assertEq(string(res), "gm"); } } diff --git a/testdata/default/cheats/Fs.t.sol b/testdata/default/cheats/Fs.t.sol index b4882525944cf..728765b7ef9f6 100644 --- a/testdata/default/cheats/Fs.t.sol +++ b/testdata/default/cheats/Fs.t.sol @@ -5,7 +5,7 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract FsTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); bytes constant FOUNDRY_TOML_ACCESS_ERR = "access to foundry.toml is not allowed"; bytes constant FOUNDRY_READ_ERR = "the path /etc/hosts is not allowed to be accessed for read operations"; bytes constant FOUNDRY_READ_DIR_ERR = "the path /etc is not allowed to be accessed for read operations"; @@ -21,189 +21,189 @@ contract FsTest is DSTest { function testReadFile() public { string memory path = "fixtures/File/read.txt"; - assertEq(vm.readFile(path), "hello readable world\nthis is the second line!"); + assertEq(VM.readFile(path), "hello readable world\nthis is the second line!"); - vm._expectCheatcodeRevert(FOUNDRY_READ_ERR); - vm.readFile("/etc/hosts"); + VM._expectCheatcodeRevert(FOUNDRY_READ_ERR); + VM.readFile("/etc/hosts"); - vm._expectCheatcodeRevert(FOUNDRY_READ_ERR); - vm.readFileBinary("/etc/hosts"); + VM._expectCheatcodeRevert(FOUNDRY_READ_ERR); + VM.readFileBinary("/etc/hosts"); } function testReadLine() public { string memory path = "fixtures/File/read.txt"; - assertEq(vm.readLine(path), "hello readable world"); - assertEq(vm.readLine(path), "this is the second line!"); - assertEq(vm.readLine(path), ""); + assertEq(VM.readLine(path), "hello readable world"); + assertEq(VM.readLine(path), "this is the second line!"); + assertEq(VM.readLine(path), ""); - vm._expectCheatcodeRevert(FOUNDRY_READ_ERR); - vm.readLine("/etc/hosts"); + VM._expectCheatcodeRevert(FOUNDRY_READ_ERR); + VM.readLine("/etc/hosts"); } function testWriteFile() public { string memory path = "fixtures/File/write_file.txt"; string memory data = "hello writable world"; - vm.writeFile(path, data); + VM.writeFile(path, data); - assertEq(vm.readFile(path), data); + assertEq(VM.readFile(path), data); - vm.removeFile(path); + VM.removeFile(path); - vm._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); - vm.writeFile("/etc/hosts", "malicious stuff"); - vm._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); - vm.writeFileBinary("/etc/hosts", "malicious stuff"); + VM._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); + VM.writeFile("/etc/hosts", "malicious stuff"); + VM._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); + VM.writeFileBinary("/etc/hosts", "malicious stuff"); } function testCopyFile() public { string memory from = "fixtures/File/read.txt"; string memory to = "fixtures/File/copy.txt"; - uint64 copied = vm.copyFile(from, to); - assertEq(vm.fsMetadata(to).length, uint256(copied)); - assertEq(vm.readFile(from), vm.readFile(to)); - vm.removeFile(to); + uint64 copied = VM.copyFile(from, to); + assertEq(VM.fsMetadata(to).length, uint256(copied)); + assertEq(VM.readFile(from), VM.readFile(to)); + VM.removeFile(to); } function testWriteLine() public { string memory path = "fixtures/File/write_line.txt"; string memory line1 = "first line"; - vm.writeLine(path, line1); + VM.writeLine(path, line1); string memory line2 = "second line"; - vm.writeLine(path, line2); + VM.writeLine(path, line2); - assertEq(vm.readFile(path), string.concat(line1, "\n", line2, "\n")); + assertEq(VM.readFile(path), string.concat(line1, "\n", line2, "\n")); - vm.removeFile(path); + VM.removeFile(path); - vm._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); - vm.writeLine("/etc/hosts", "malicious stuff"); + VM._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); + VM.writeLine("/etc/hosts", "malicious stuff"); } function testCloseFile() public { string memory path = "fixtures/File/read.txt"; - assertEq(vm.readLine(path), "hello readable world"); - vm.closeFile(path); - assertEq(vm.readLine(path), "hello readable world"); + assertEq(VM.readLine(path), "hello readable world"); + VM.closeFile(path); + assertEq(VM.readLine(path), "hello readable world"); } function testRemoveFile() public { string memory path = "fixtures/File/remove_file.txt"; string memory data = "hello writable world"; - vm.writeFile(path, data); - assertEq(vm.readLine(path), data); + VM.writeFile(path, data); + assertEq(VM.readLine(path), data); - vm.removeFile(path); - vm.writeLine(path, data); - assertEq(vm.readLine(path), data); + VM.removeFile(path); + VM.writeLine(path, data); + assertEq(VM.readLine(path), data); - vm.removeFile(path); + VM.removeFile(path); - vm._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); - vm.removeFile("/etc/hosts"); + VM._expectCheatcodeRevert(FOUNDRY_WRITE_ERR); + VM.removeFile("/etc/hosts"); } function testWriteLineFoundrytoml() public { - string memory root = vm.projectRoot(); + string memory root = VM.projectRoot(); string memory foundryToml = string.concat(root, "/", "foundry.toml"); - vm._expectCheatcodeRevert(); - vm.writeLine(foundryToml, "\nffi = true\n"); + VM._expectCheatcodeRevert(); + VM.writeLine(foundryToml, "\nffi = true\n"); - vm._expectCheatcodeRevert(); - vm.writeLine("foundry.toml", "\nffi = true\n"); + VM._expectCheatcodeRevert(); + VM.writeLine("foundry.toml", "\nffi = true\n"); - vm._expectCheatcodeRevert(); - vm.writeLine("./foundry.toml", "\nffi = true\n"); + VM._expectCheatcodeRevert(); + VM.writeLine("./foundry.toml", "\nffi = true\n"); - vm._expectCheatcodeRevert(); - vm.writeLine("./Foundry.toml", "\nffi = true\n"); + VM._expectCheatcodeRevert(); + VM.writeLine("./Foundry.toml", "\nffi = true\n"); } function testWriteFoundrytoml() public { - string memory root = vm.projectRoot(); + string memory root = VM.projectRoot(); string memory foundryToml = string.concat(root, "/", "foundry.toml"); - vm._expectCheatcodeRevert(); - vm.writeFile(foundryToml, "\nffi = true\n"); + VM._expectCheatcodeRevert(); + VM.writeFile(foundryToml, "\nffi = true\n"); - vm._expectCheatcodeRevert(); - vm.writeFile("foundry.toml", "\nffi = true\n"); + VM._expectCheatcodeRevert(); + VM.writeFile("foundry.toml", "\nffi = true\n"); - vm._expectCheatcodeRevert(); - vm.writeFile("./foundry.toml", "\nffi = true\n"); + VM._expectCheatcodeRevert(); + VM.writeFile("./foundry.toml", "\nffi = true\n"); - vm._expectCheatcodeRevert(); - vm.writeFile("./Foundry.toml", "\nffi = true\n"); + VM._expectCheatcodeRevert(); + VM.writeFile("./Foundry.toml", "\nffi = true\n"); } function testReadDir() public { string memory path = "fixtures/Dir"; { - Vm.DirEntry[] memory entries = vm.readDir(path); + Vm.DirEntry[] memory entries = VM.readDir(path); assertEq(entries.length, 2); assertEntry(entries[0], 1, false); assertEntry(entries[1], 1, true); - Vm.DirEntry[] memory entries2 = vm.readDir(path, 1); + Vm.DirEntry[] memory entries2 = VM.readDir(path, 1); assertEq(entries2.length, 2); assertEq(entries[0].path, entries2[0].path); assertEq(entries[1].path, entries2[1].path); - string memory contents = vm.readFile(entries[0].path); + string memory contents = VM.readFile(entries[0].path); assertEq(contents, unicode"Wow! 😀"); } { - Vm.DirEntry[] memory entries = vm.readDir(path, 2); + Vm.DirEntry[] memory entries = VM.readDir(path, 2); assertEq(entries.length, 4); assertEntry(entries[2], 2, false); assertEntry(entries[3], 2, true); } { - Vm.DirEntry[] memory entries = vm.readDir(path, 3); + Vm.DirEntry[] memory entries = VM.readDir(path, 3); assertEq(entries.length, 5); assertEntry(entries[4], 3, false); } - vm._expectCheatcodeRevert(FOUNDRY_READ_DIR_ERR); - vm.readDir("/etc"); + VM._expectCheatcodeRevert(FOUNDRY_READ_DIR_ERR); + VM.readDir("/etc"); } function testCreateRemoveDir() public { string memory path = "fixtures/Dir/remove_dir"; string memory child = string.concat(path, "/child"); - vm.createDir(path, false); - assertEq(vm.fsMetadata(path).isDir, true); + VM.createDir(path, false); + assertEq(VM.fsMetadata(path).isDir, true); - vm.removeDir(path, false); - vm._expectCheatcodeRevert(); - vm.fsMetadata(path); + VM.removeDir(path, false); + VM._expectCheatcodeRevert(); + VM.fsMetadata(path); // reverts because not recursive - vm._expectCheatcodeRevert(); - vm.createDir(child, false); + VM._expectCheatcodeRevert(); + VM.createDir(child, false); - vm.createDir(child, true); - assertEq(vm.fsMetadata(child).isDir, true); + VM.createDir(child, true); + assertEq(VM.fsMetadata(child).isDir, true); // deleted both, recursively - vm.removeDir(path, true); - vm._expectCheatcodeRevert(); - vm.fsMetadata(path); - vm._expectCheatcodeRevert(); - vm.fsMetadata(child); + VM.removeDir(path, true); + VM._expectCheatcodeRevert(); + VM.fsMetadata(path); + VM._expectCheatcodeRevert(); + VM.fsMetadata(child); } function testFsMetadata() public { - Vm.FsMetadata memory metadata = vm.fsMetadata("fixtures/File"); + Vm.FsMetadata memory metadata = VM.fsMetadata("fixtures/File"); assertEq(metadata.isDir, true); assertEq(metadata.isSymlink, false); assertEq(metadata.readOnly, false); @@ -213,7 +213,7 @@ contract FsTest is DSTest { // assertGt(metadata.accessed, 0); // assertGt(metadata.created, 0); - metadata = vm.fsMetadata("fixtures/File/read.txt"); + metadata = VM.fsMetadata("fixtures/File/read.txt"); assertEq(metadata.isDir, false); assertEq(metadata.isSymlink, false); // This test will fail on windows if we compared to 45, as windows @@ -221,57 +221,57 @@ contract FsTest is DSTest { // unix which only uses the first one. assertTrue(metadata.length == 45 || metadata.length == 46); - metadata = vm.fsMetadata("fixtures/File/symlink"); + metadata = VM.fsMetadata("fixtures/File/symlink"); assertEq(metadata.isDir, false); // TODO: symlinks are canonicalized away in `ensure_path_allowed` // assertEq(metadata.isSymlink, true); - vm._expectCheatcodeRevert(); - vm.fsMetadata("../not-found"); + VM._expectCheatcodeRevert(); + VM.fsMetadata("../not-found"); - vm._expectCheatcodeRevert(FOUNDRY_READ_ERR); - vm.fsMetadata("/etc/hosts"); + VM._expectCheatcodeRevert(FOUNDRY_READ_ERR); + VM.fsMetadata("/etc/hosts"); } function testExists() public { string memory validFilePath = "fixtures/File/read.txt"; - assertTrue(vm.exists(validFilePath)); - assertTrue(vm.exists(validFilePath)); + assertTrue(VM.exists(validFilePath)); + assertTrue(VM.exists(validFilePath)); string memory validDirPath = "fixtures/File"; - assertTrue(vm.exists(validDirPath)); - assertTrue(vm.exists(validDirPath)); + assertTrue(VM.exists(validDirPath)); + assertTrue(VM.exists(validDirPath)); string memory invalidPath = "fixtures/File/invalidfile.txt"; - assertTrue(vm.exists(invalidPath) == false); - assertTrue(vm.exists(invalidPath) == false); + assertTrue(VM.exists(invalidPath) == false); + assertTrue(VM.exists(invalidPath) == false); } function testIsFile() public { string memory validFilePath = "fixtures/File/read.txt"; - assertTrue(vm.isFile(validFilePath)); - assertTrue(vm.isFile(validFilePath)); + assertTrue(VM.isFile(validFilePath)); + assertTrue(VM.isFile(validFilePath)); string memory invalidFilePath = "fixtures/File/invalidfile.txt"; - assertTrue(vm.isFile(invalidFilePath) == false); - assertTrue(vm.isFile(invalidFilePath) == false); + assertTrue(VM.isFile(invalidFilePath) == false); + assertTrue(VM.isFile(invalidFilePath) == false); string memory dirPath = "fixtures/File"; - assertTrue(vm.isFile(dirPath) == false); - assertTrue(vm.isFile(dirPath) == false); + assertTrue(VM.isFile(dirPath) == false); + assertTrue(VM.isFile(dirPath) == false); } function testIsDir() public { string memory validDirPath = "fixtures/File"; - assertTrue(vm.isDir(validDirPath)); - assertTrue(vm.isDir(validDirPath)); + assertTrue(VM.isDir(validDirPath)); + assertTrue(VM.isDir(validDirPath)); string memory invalidDirPath = "fixtures/InvalidDir"; - assertTrue(vm.isDir(invalidDirPath) == false); - assertTrue(vm.isDir(invalidDirPath) == false); + assertTrue(VM.isDir(invalidDirPath) == false); + assertTrue(VM.isDir(invalidDirPath) == false); string memory filePath = "fixtures/File/read.txt"; - assertTrue(vm.isDir(filePath) == false); - assertTrue(vm.isDir(filePath) == false); + assertTrue(VM.isDir(filePath) == false); + assertTrue(VM.isDir(filePath) == false); } } diff --git a/testdata/default/cheats/GasMetering.t.sol b/testdata/default/cheats/GasMetering.t.sol index 3cb105d236f02..0f66ebe34abc3 100644 --- a/testdata/default/cheats/GasMetering.t.sol +++ b/testdata/default/cheats/GasMetering.t.sol @@ -11,69 +11,69 @@ contract B { } contract GasMeteringTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testGasMetering() public { - uint256 gas_start = gasleft(); + uint256 gasStart = gasleft(); consumeGas(); - uint256 gas_end_normal = gas_start - gasleft(); + uint256 gasEndNormal = gasStart - gasleft(); - vm.pauseGasMetering(); - uint256 gas_start_not_metered = gasleft(); + VM.pauseGasMetering(); + uint256 gasStartNotMetered = gasleft(); consumeGas(); - uint256 gas_end_not_metered = gas_start_not_metered - gasleft(); - vm.resumeGasMetering(); + uint256 gasEndNotMetered = gasStartNotMetered - gasleft(); + VM.resumeGasMetering(); - uint256 gas_start_metered = gasleft(); + uint256 gasStartMetered = gasleft(); consumeGas(); - uint256 gas_end_resume_metered = gas_start_metered - gasleft(); + uint256 gasEndResumeMetered = gasStartMetered - gasleft(); - assertEq(gas_end_normal, gas_end_resume_metered); - assertEq(gas_end_not_metered, 0); + assertEq(gasEndNormal, gasEndResumeMetered); + assertEq(gasEndNotMetered, 0); } function testGasMeteringExternal() public { B b = new B(); - uint256 gas_start = gasleft(); + uint256 gasStart = gasleft(); b.a(); - uint256 gas_end_normal = gas_start - gasleft(); + uint256 gasEndNormal = gasStart - gasleft(); - vm.pauseGasMetering(); - uint256 gas_start_not_metered = gasleft(); + VM.pauseGasMetering(); + uint256 gasStartNotMetered = gasleft(); b.a(); - uint256 gas_end_not_metered = gas_start_not_metered - gasleft(); - vm.resumeGasMetering(); + uint256 gasEndNotMetered = gasStartNotMetered - gasleft(); + VM.resumeGasMetering(); - uint256 gas_start_metered = gasleft(); + uint256 gasStartMetered = gasleft(); b.a(); - uint256 gas_end_resume_metered = gas_start_metered - gasleft(); + uint256 gasEndResumeMetered = gasStartMetered - gasleft(); - assertEq(gas_end_normal, gas_end_resume_metered); - assertEq(gas_end_not_metered, 0); + assertEq(gasEndNormal, gasEndResumeMetered); + assertEq(gasEndNotMetered, 0); } function testGasMeteringContractCreate() public { - vm.pauseGasMetering(); - uint256 gas_start_not_metered = gasleft(); + VM.pauseGasMetering(); + uint256 gasStartNotMetered = gasleft(); B b = new B(); - uint256 gas_end_not_metered = gas_start_not_metered - gasleft(); - vm.resumeGasMetering(); + uint256 gasEndNotMetered = gasStartNotMetered - gasleft(); + VM.resumeGasMetering(); - assertEq(gas_end_not_metered, 0); + assertEq(gasEndNotMetered, 0); } function consumeGas() internal returns (uint256 x) { diff --git a/testdata/default/cheats/Load.t.sol b/testdata/default/cheats/Load.t.sol index 06f4b5bd52718..93d7057d37fac 100644 --- a/testdata/default/cheats/Load.t.sol +++ b/testdata/default/cheats/Load.t.sol @@ -9,7 +9,7 @@ contract Storage { } contract LoadTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); uint256 slot0 = 20; Storage store; @@ -22,17 +22,17 @@ contract LoadTest is DSTest { assembly { slot := slot0.slot } - uint256 val = uint256(vm.load(address(this), bytes32(slot))); + uint256 val = uint256(VM.load(address(this), bytes32(slot))); assertEq(val, 20, "load failed"); } function testLoadNotAvailableOnPrecompiles() public { - vm._expectCheatcodeRevert("cannot use precompile 0x0000000000000000000000000000000000000001 as an argument"); - vm.load(address(1), bytes32(0)); + VM._expectCheatcodeRevert("cannot use precompile 0x0000000000000000000000000000000000000001 as an argument"); + VM.load(address(1), bytes32(0)); } function testLoadOtherStorage() public { - uint256 val = uint256(vm.load(address(store), bytes32(0))); + uint256 val = uint256(VM.load(address(store), bytes32(0))); assertEq(val, 10, "load failed"); } } diff --git a/testdata/default/cheats/MemSafety.t.sol b/testdata/default/cheats/MemSafety.t.sol index b18673e93e081..83137fcab3d82 100644 --- a/testdata/default/cheats/MemSafety.t.sol +++ b/testdata/default/cheats/MemSafety.t.sol @@ -5,7 +5,7 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract MemSafetyTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); //////////////////////////////////////////////////////////////// // MSTORE // @@ -15,7 +15,7 @@ contract MemSafetyTest is DSTest { /// will not cause the test to fail while using the `MSTORE` opcode. function testExpectSafeMemory_MSTORE() public { // Allow memory writes in the range of [0x80, 0xA0) within this context - vm.expectSafeMemory(0x80, 0xA0); + VM.expectSafeMemory(0x80, 0xA0); // Write to memory within the range using `MSTORE` assembly { @@ -27,8 +27,8 @@ contract MemSafetyTest is DSTest { /// will not cause the test to fail while using the `MSTORE` opcode. function testExpectSafeMemory_multiRange_MSTORE() public { // Allow memory writes in the range of [0x80, 0x100) and [0x120, 0x140) within this context - vm.expectSafeMemory(0x80, 0x100); - vm.expectSafeMemory(0x120, 0x140); + VM.expectSafeMemory(0x80, 0x100); + VM.expectSafeMemory(0x120, 0x140); // Write to memory within the range using `MSTORE` assembly { @@ -45,7 +45,7 @@ contract MemSafetyTest is DSTest { /// will not cause the test to fail while using the `MSTORE8` opcode. function testExpectSafeMemory_MSTORE8() public { // Allow memory writes in the range of [0x80, 0x81) within this context - vm.expectSafeMemory(0x80, 0x81); + VM.expectSafeMemory(0x80, 0x81); // Write to memory within the range using `MSTORE8` assembly { @@ -57,8 +57,8 @@ contract MemSafetyTest is DSTest { /// will not cause the test to fail while using the `MSTORE8` opcode. function testExpectSafeMemory_multiRange_MSTORE8() public { // Allow memory writes in the range of [0x80, 0x100) and [0x120, 0x121) within this context - vm.expectSafeMemory(0x80, 0x100); - vm.expectSafeMemory(0x120, 0x121); + VM.expectSafeMemory(0x80, 0x100); + VM.expectSafeMemory(0x120, 0x121); // Write to memory within the range using `MSTORE8` assembly { @@ -75,7 +75,7 @@ contract MemSafetyTest is DSTest { /// will not cause the test to fail while using the `CALLDATACOPY` opcode. function testExpectSafeMemory_CALLDATACOPY(uint256 _x) public { // Allow memory writes in the range of [0x80, 0xA0) within this context - vm.expectSafeMemory(0x80, 0xA0); + VM.expectSafeMemory(0x80, 0xA0); // Write to memory within the range using `CALLDATACOPY` assembly { @@ -91,7 +91,7 @@ contract MemSafetyTest is DSTest { /// will not cause the test to fail while using the `CODECOPY` opcode. function testExpectSafeMemory_CODECOPY() public { // Allow memory writes in the range of [0x80, 0xA0) within this context - vm.expectSafeMemory(0x80, 0xA0); + VM.expectSafeMemory(0x80, 0xA0); // Write to memory within the range using `CODECOPY` assembly { @@ -114,7 +114,7 @@ contract MemSafetyTest is DSTest { bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); + VM.expectSafeMemory(0x80, 0x100); // Create a new SubContext contract and call `giveReturndata` on it. _doCallReturnData(address(sc), payload, 0x80, 0x60); @@ -133,7 +133,7 @@ contract MemSafetyTest is DSTest { /// will not cause the test to fail while using the `EXTCODECOPY` opcode. function testExpectSafeMemory_EXTCODECOPY() public { // Allow memory writes in the range of [0x80, 0xA0) within this context - vm.expectSafeMemory(0x80, 0xA0); + VM.expectSafeMemory(0x80, 0xA0); // Write to memory within the range using `EXTCODECOPY` assembly { @@ -156,7 +156,7 @@ contract MemSafetyTest is DSTest { bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); + VM.expectSafeMemory(0x80, 0x100); // Create a new SubContext contract and call `giveReturndata` on it. _doCallReturnData(address(sc), payload, 0x80, 0x60); @@ -176,7 +176,7 @@ contract MemSafetyTest is DSTest { bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); + VM.expectSafeMemory(0x80, 0x100); // Create a new SubContext contract and call `giveReturndata` on it. _doCallCodeReturnData(address(sc), payload, 0x80, 0x60); @@ -196,7 +196,7 @@ contract MemSafetyTest is DSTest { bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); + VM.expectSafeMemory(0x80, 0x100); // Create a new SubContext contract and call `giveReturndata` on it. _doStaticCallReturnData(address(sc), payload, 0x80, 0x60); @@ -216,7 +216,7 @@ contract MemSafetyTest is DSTest { bytes memory payload = abi.encodeWithSelector(SubContext.giveReturndata.selector); // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); + VM.expectSafeMemory(0x80, 0x100); // Create a new SubContext contract and call `giveReturndata` on it. _doDelegateCallReturnData(address(sc), payload, 0x80, 0x60); @@ -229,7 +229,7 @@ contract MemSafetyTest is DSTest { /// @dev Tests that expanding memory within the range given to `expectSafeMemory` /// will not cause the test to fail while using the `MLOAD` opcode. function testExpectSafeMemory_MLOAD() public { - vm.expectSafeMemory(0x80, 0x120); + VM.expectSafeMemory(0x80, 0x120); // This should not revert. Ugly hack to make sure the mload isn't optimized // out. @@ -244,9 +244,9 @@ contract MemSafetyTest is DSTest { /// will cause the test to fail while using the `MLOAD` opcode. /// forge-config: default.allow_internal_expect_revert = true function testExpectSafeMemory_MLOAD_REVERT() public { - vm.expectSafeMemory(0x80, 0x100); + VM.expectSafeMemory(0x80, 0x100); - vm.expectRevert(); + VM.expectRevert(); // This should revert. Ugly hack to make sure the mload isn't optimized // out. @@ -264,7 +264,7 @@ contract MemSafetyTest is DSTest { /// @dev Tests that expanding memory within the range given to `expectSafeMemory` /// will not cause the test to fail while using the `SHA3` opcode. function testExpectSafeMemory_SHA3() public { - vm.expectSafeMemory(0x80, 0x120); + VM.expectSafeMemory(0x80, 0x120); // This should not revert. Ugly hack to make sure the sha3 isn't optimized // out. @@ -285,7 +285,7 @@ contract MemSafetyTest is DSTest { /// @dev Tests that expanding memory within the range given to `expectSafeMemory` /// will not cause the test to fail while using the `LOG0` opcode. function testExpectSafeMemory_LOG0() public { - vm.expectSafeMemory(0x80, 0x120); + VM.expectSafeMemory(0x80, 0x120); // This should not revert. assembly { @@ -297,8 +297,8 @@ contract MemSafetyTest is DSTest { /// will cause the test to fail while using the `LOG0` opcode. /// forge-config: default.allow_internal_expect_revert = true function testExpectSafeMemory_LOG0_REVERT() public { - vm.expectSafeMemory(0x80, 0x100); - vm.expectRevert(); + VM.expectSafeMemory(0x80, 0x100); + VM.expectRevert(); // This should revert. assembly { log0(0x100, 0x20) @@ -312,7 +312,7 @@ contract MemSafetyTest is DSTest { /// @dev Tests that expanding memory within the range given to `expectSafeMemory` /// will not cause the test to fail while using the `CREATE` opcode. function testExpectSafeMemory_CREATE() public { - vm.expectSafeMemory(0x80, 0x120); + VM.expectSafeMemory(0x80, 0x120); // This should not revert. assembly { @@ -323,7 +323,7 @@ contract MemSafetyTest is DSTest { /// @dev Tests that expanding memory within the range given to `expectSafeMemory` /// will not cause the test to fail while using the `CREATE2` opcode. function testExpectSafeMemory_CREATE2() public { - vm.expectSafeMemory(0x80, 0x120); + VM.expectSafeMemory(0x80, 0x120); // This should not revert. assembly { @@ -338,7 +338,7 @@ contract MemSafetyTest is DSTest { /// @dev Tests that expanding memory within the range given to `expectSafeMemory` /// will not cause the test to fail while using the `RETURN` opcode. function testExpectSafeMemory_RETURN() public { - vm.expectSafeMemory(0x80, 0x120); + VM.expectSafeMemory(0x80, 0x120); // This should not revert. assembly { @@ -356,7 +356,7 @@ contract MemSafetyTest is DSTest { bytes memory payload = abi.encodeWithSelector(SubContext.doRevert.selector, 0x100, 0x20); // Expect memory in the range of [0x00, 0x120] to be safe in the next subcontext - vm.expectSafeMemoryCall(0x00, 0x120); + VM.expectSafeMemoryCall(0x00, 0x120); // Call `doRevert` on the SubContext contract and ensure it did revert with zero // data. @@ -379,7 +379,7 @@ contract MemSafetyTest is DSTest { bytes memory payload = abi.encodeWithSelector(SubContext.doMstore8.selector, 0x120, 0xc0ffee); // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); + VM.expectSafeMemory(0x80, 0x100); // Should not revert- the `expectSafeMemory` cheatcode operates at a // per-depth level. @@ -395,7 +395,7 @@ contract MemSafetyTest is DSTest { bytes memory payload = abi.encodeWithSelector(SubContext.doMstore8.selector, 0x120, 0xFF); // Allow memory writes in the range of [0x80, 0x100) within this context - vm.expectSafeMemory(0x80, 0x100); + VM.expectSafeMemory(0x80, 0x100); // Should not revert- the `expectSafeMemory` cheatcode operates at a // per-depth level. @@ -414,7 +414,7 @@ contract MemSafetyTest is DSTest { bytes memory payload = abi.encodeWithSelector(SubContext.doMstore.selector, 0x80, 0xc0ffee); // Allow memory writes in the range of [0x80, 0xA0) within the next created subcontext - vm.expectSafeMemoryCall(0x80, 0xA0); + VM.expectSafeMemoryCall(0x80, 0xA0); // Should not revert- the memory write in this subcontext is within the allowed range. _doCall(address(sc), payload); @@ -431,13 +431,13 @@ contract MemSafetyTest is DSTest { initPtr := mload(0x40) } - vm.expectSafeMemory(initPtr, initPtr + 0x20); + VM.expectSafeMemory(initPtr, initPtr + 0x20); assembly { // write to allowed range mstore(initPtr, 0x01) } - vm.stopExpectSafeMemory(); + VM.stopExpectSafeMemory(); assembly { // write ouside allowed range, this should be fine @@ -453,14 +453,14 @@ contract MemSafetyTest is DSTest { initPtr := mload(0x40) } - vm.expectSafeMemory(initPtr, initPtr + 0x20); + VM.expectSafeMemory(initPtr, initPtr + 0x20); assembly { // write outside of allowed range, this should revert mstore(initPtr, 0x01) mstore(0x40, add(initPtr, 0x20)) } - vm.stopExpectSafeMemory(); + VM.stopExpectSafeMemory(); } //////////////////////////////////////////////////////////////// diff --git a/testdata/default/cheats/MockCalls.t.sol b/testdata/default/cheats/MockCalls.t.sol index 2bd4d8bd9ea2e..2b98f16431d86 100644 --- a/testdata/default/cheats/MockCalls.t.sol +++ b/testdata/default/cheats/MockCalls.t.sol @@ -5,16 +5,16 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract MockCallsTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testMockCallsLastShouldPersist() public { - address mockUser = vm.addr(vm.randomUint()); - address mockErc20 = vm.addr(vm.randomUint()); + address mockUser = VM.addr(VM.randomUint()); + address mockErc20 = VM.addr(VM.randomUint()); bytes memory data = abi.encodeWithSignature("balanceOf(address)", mockUser); bytes[] memory mocks = new bytes[](2); mocks[0] = abi.encode(2 ether); mocks[1] = abi.encode(7.219 ether); - vm.mockCalls(mockErc20, data, mocks); + VM.mockCalls(mockErc20, data, mocks); (, bytes memory ret1) = mockErc20.call(data); assertEq(abi.decode(ret1, (uint256)), 2 ether); (, bytes memory ret2) = mockErc20.call(data); @@ -24,14 +24,14 @@ contract MockCallsTest is DSTest { } function testMockCallsWithValue() public { - address mockUser = vm.addr(vm.randomUint()); - address mockErc20 = vm.addr(vm.randomUint()); + address mockUser = VM.addr(VM.randomUint()); + address mockErc20 = VM.addr(VM.randomUint()); bytes memory data = abi.encodeWithSignature("balanceOf(address)", mockUser); bytes[] memory mocks = new bytes[](3); mocks[0] = abi.encode(2 ether); mocks[1] = abi.encode(1 ether); mocks[2] = abi.encode(6.423 ether); - vm.mockCalls(mockErc20, 1 ether, data, mocks); + VM.mockCalls(mockErc20, 1 ether, data, mocks); (, bytes memory ret1) = mockErc20.call{value: 1 ether}(data); assertEq(abi.decode(ret1, (uint256)), 2 ether); (, bytes memory ret2) = mockErc20.call{value: 1 ether}(data); @@ -41,14 +41,14 @@ contract MockCallsTest is DSTest { } function testMockCalls() public { - address mockUser = vm.addr(vm.randomUint()); - address mockErc20 = vm.addr(vm.randomUint()); + address mockUser = VM.addr(VM.randomUint()); + address mockErc20 = VM.addr(VM.randomUint()); bytes memory data = abi.encodeWithSignature("balanceOf(address)", mockUser); bytes[] memory mocks = new bytes[](3); mocks[0] = abi.encode(2 ether); mocks[1] = abi.encode(1 ether); mocks[2] = abi.encode(6.423 ether); - vm.mockCalls(mockErc20, data, mocks); + VM.mockCalls(mockErc20, data, mocks); (, bytes memory ret1) = mockErc20.call(data); assertEq(abi.decode(ret1, (uint256)), 2 ether); (, bytes memory ret2) = mockErc20.call(data); diff --git a/testdata/default/cheats/Prank.t.sol b/testdata/default/cheats/Prank.t.sol index 151f0d8306776..98ec0bce9866b 100644 --- a/testdata/default/cheats/Prank.t.sol +++ b/testdata/default/cheats/Prank.t.sol @@ -341,8 +341,6 @@ contract PrankTest is DSTest { /// forge-config: default.allow_internal_expect_revert = true function testRevertIfOverwriteUnusedPrank(address sender, address origin) public { // Set the prank, but not use it - address oldOrigin = tx.origin; - Victim victim = new Victim(); vm.startPrank(sender, origin); // try to overwrite the prank. This should fail. vm.expectRevert("vm.startPrank: cannot overwrite a prank until it is applied at least once"); @@ -352,7 +350,6 @@ contract PrankTest is DSTest { /// forge-config: default.allow_internal_expect_revert = true function testRevertIfOverwriteUnusedPrankAfterSuccessfulPrank(address sender, address origin) public { // Set the prank, but not use it - address oldOrigin = tx.origin; Victim victim = new Victim(); vm.startPrank(sender, origin); victim.assertCallerAndOrigin( @@ -538,8 +535,6 @@ contract PrankTest is DSTest { /// /// Ref: issue #1210 function testTxOriginInNestedPrank(address sender, address origin) public { - address oldSender = msg.sender; - address oldOrigin = tx.origin; Victim innerVictim = new Victim(); NestedVictim victim = new NestedVictim(innerVictim); diff --git a/testdata/default/cheats/Prompt.t.sol b/testdata/default/cheats/Prompt.t.sol index 2e623a28ef22c..b3756a455228b 100644 --- a/testdata/default/cheats/Prompt.t.sol +++ b/testdata/default/cheats/Prompt.t.sol @@ -17,16 +17,16 @@ contract PromptTest is DSTest { vm.promptSecret("test"); vm._expectCheatcodeRevert(); - uint256 test = vm.promptSecretUint("test"); + vm.promptSecretUint("test"); } function testPrompt_Address() public { vm._expectCheatcodeRevert(); - address test = vm.promptAddress("test"); + vm.promptAddress("test"); } function testPrompt_Uint() public { vm._expectCheatcodeRevert(); - uint256 test = vm.promptUint("test"); + vm.promptUint("test"); } } diff --git a/testdata/default/cheats/RandomCheatcodes.t.sol b/testdata/default/cheats/RandomCheatcodes.t.sol index c42b4310012f1..d4aacb5cec2de 100644 --- a/testdata/default/cheats/RandomCheatcodes.t.sol +++ b/testdata/default/cheats/RandomCheatcodes.t.sol @@ -5,41 +5,41 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract RandomCheatcodesTest is DSTest { - Vm vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); - int128 constant min = -170141183460469231731687303715884105728; - int128 constant max = 170141183460469231731687303715884105727; + int128 constant MIN = -170141183460469231731687303715884105728; + int128 constant MAX = 170141183460469231731687303715884105727; function test_int128() public { - vm._expectCheatcodeRevert("vm.randomInt: number of bits cannot exceed 256"); - int256 val = vm.randomInt(type(uint256).max); + VM._expectCheatcodeRevert("VM.randomInt: number of bits cannot exceed 256"); + int256 val = VM.randomInt(type(uint256).max); - val = vm.randomInt(128); - assertGe(val, min); - assertLe(val, max); + val = VM.randomInt(128); + assertGe(val, MIN); + assertLe(val, MAX); } /// forge-config: default.allow_internal_expect_revert = true function testReverttIf_int128() public { - int256 val = vm.randomInt(128); - vm.expectRevert("Error: a > b not satisfied [int]"); - require(val > max, "Error: a > b not satisfied [int]"); + int256 val = VM.randomInt(128); + VM.expectRevert("Error: a > b not satisfied [int]"); + require(val > MAX, "Error: a > b not satisfied [int]"); } function test_address() public { - address fresh_address = vm.randomAddress(); - assert(fresh_address != address(this)); - assert(fresh_address != address(vm)); + address freshAddress = VM.randomAddress(); + assert(freshAddress != address(this)); + assert(freshAddress != address(VM)); } function test_randomUintLimit() public { - vm._expectCheatcodeRevert("vm.randomUint: number of bits cannot exceed 256"); - uint256 val = vm.randomUint(type(uint256).max); + VM._expectCheatcodeRevert("VM.randomUint: number of bits cannot exceed 256"); + VM.randomUint(type(uint256).max); } function test_randomUints(uint256 x) public { - x = vm.randomUint(0, 256); - uint256 freshUint = vm.randomUint(x); + x = VM.randomUint(0, 256); + uint256 freshUint = VM.randomUint(x); assert(0 <= freshUint); if (x == 256) { @@ -50,7 +50,7 @@ contract RandomCheatcodesTest is DSTest { } function test_randomSymbolicWord() public { - uint256 freshUint192 = vm.randomUint(192); + uint256 freshUint192 = VM.randomUint(192); assert(0 <= freshUint192); assert(freshUint192 <= type(uint192).max); @@ -58,49 +58,49 @@ contract RandomCheatcodesTest is DSTest { } contract RandomBytesTest is DSTest { - Vm vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); - bytes1 local_byte; - bytes local_bytes; + bytes1 localByte; + bytes localBytes; - function manip_symbolic_bytes(bytes memory b) public { + function manipSymbolicBytes(bytes memory b) public { uint256 middle = b.length / 2; b[middle] = hex"aa"; } function test_symbolic_bytes_revert() public { - vm._expectCheatcodeRevert(); - bytes memory val = vm.randomBytes(type(uint256).max); + VM._expectCheatcodeRevert(); + VM.randomBytes(type(uint256).max); } function test_symbolic_bytes_1() public { - uint256 length = uint256(vm.randomUint(1, type(uint8).max)); - bytes memory fresh_bytes = vm.randomBytes(length); - uint256 index = uint256(vm.randomUint(1)); + uint256 length = uint256(VM.randomUint(1, type(uint8).max)); + bytes memory freshBytes = VM.randomBytes(length); + uint256 index = uint256(VM.randomUint(1)); - local_byte = fresh_bytes[index]; - assertEq(fresh_bytes[index], local_byte); + localByte = freshBytes[index]; + assertEq(freshBytes[index], localByte); } function test_symbolic_bytes_2() public { - uint256 length = uint256(vm.randomUint(1, type(uint8).max)); - bytes memory fresh_bytes = vm.randomBytes(length); + uint256 length = uint256(VM.randomUint(1, type(uint8).max)); + bytes memory freshBytes = VM.randomBytes(length); - local_bytes = fresh_bytes; - assertEq(fresh_bytes, local_bytes); + localBytes = freshBytes; + assertEq(freshBytes, localBytes); } function test_symbolic_bytes_3() public { - uint256 length = uint256(vm.randomUint(1, type(uint8).max)); - bytes memory fresh_bytes = vm.randomBytes(length); + uint256 length = uint256(VM.randomUint(1, type(uint8).max)); + bytes memory freshBytes = VM.randomBytes(length); - manip_symbolic_bytes(fresh_bytes); - assertEq(hex"aa", fresh_bytes[length / 2]); + manipSymbolicBytes(freshBytes); + assertEq(hex"aa", freshBytes[length / 2]); } function test_symbolic_bytes_length(uint8 l) public { - vm.assume(0 < l); - bytes memory fresh_bytes = vm.randomBytes(l); - assertEq(fresh_bytes.length, l); + VM.assume(0 < l); + bytes memory freshBytes = VM.randomBytes(l); + assertEq(freshBytes.length, l); } } diff --git a/testdata/default/cheats/ReadCallers.t.sol b/testdata/default/cheats/ReadCallers.t.sol index dbd198a2d93e8..b1e7e9564598c 100644 --- a/testdata/default/cheats/ReadCallers.t.sol +++ b/testdata/default/cheats/ReadCallers.t.sol @@ -9,13 +9,13 @@ contract Target { } contract ReadCallersTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testReadCallersWithNoActivePrankOrBroadcast() public { address expectedSender = msg.sender; address expectedTxOrigin = tx.origin; - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.None)); assertEq(newSender, expectedSender); @@ -24,10 +24,10 @@ contract ReadCallersTest is DSTest { // Prank Tests function testReadCallersWithActivePrankForMsgSender(address sender) public { - vm.prank(sender); + VM.prank(sender); address expectedTxOrigin = tx.origin; - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.Prank)); assertEq(newSender, sender); @@ -35,9 +35,9 @@ contract ReadCallersTest is DSTest { } function testReadCallersWithActivePrankForMsgSenderAndTxOrigin(address sender, address origin) public { - vm.prank(sender, origin); + VM.prank(sender, origin); - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.Prank)); assertEq(newSender, sender); @@ -49,10 +49,10 @@ contract ReadCallersTest is DSTest { address expectedSender = msg.sender; address expectedTxOrigin = tx.origin; - vm.prank(sender); + VM.prank(sender); target.consumeNewCaller(); - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.None)); assertEq(newSender, expectedSender); @@ -64,10 +64,10 @@ contract ReadCallersTest is DSTest { address expectedSender = msg.sender; address expectedTxOrigin = tx.origin; - vm.prank(sender, origin); + VM.prank(sender, origin); target.consumeNewCaller(); - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.None)); assertEq(newSender, expectedSender); @@ -77,11 +77,11 @@ contract ReadCallersTest is DSTest { function testReadCallersWithActiveRecurrentMsgSenderPrank(address sender) public { address expectedTxOrigin = tx.origin; Target target = new Target(); - vm.startPrank(sender); + VM.startPrank(sender); for (uint256 i = 0; i < 5; i++) { target.consumeNewCaller(); - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.RecurrentPrank)); assertEq(newSender, sender); @@ -91,11 +91,11 @@ contract ReadCallersTest is DSTest { function testReadCallersWithActiveRecurrentMsgSenderAndTxOriginPrank(address sender, address origin) public { Target target = new Target(); - vm.startPrank(sender, origin); + VM.startPrank(sender, origin); for (uint256 i = 0; i < 5; i++) { target.consumeNewCaller(); - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.RecurrentPrank)); assertEq(newSender, sender); @@ -106,11 +106,11 @@ contract ReadCallersTest is DSTest { function testReadCallersAfterStoppingRecurrentMsgSenderPrank(address sender) public { address expectedSender = msg.sender; address expectedTxOrigin = tx.origin; - vm.startPrank(sender); + VM.startPrank(sender); - vm.stopPrank(); + VM.stopPrank(); - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.None)); assertEq(newSender, expectedSender); @@ -120,11 +120,11 @@ contract ReadCallersTest is DSTest { function testReadCallersAfterStoppingRecurrentMsgSenderAndTxOriginPrank(address sender, address origin) public { address expectedSender = msg.sender; address expectedTxOrigin = tx.origin; - vm.startPrank(sender, origin); + VM.startPrank(sender, origin); - vm.stopPrank(); + VM.stopPrank(); - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.None)); assertEq(newSender, expectedSender); @@ -133,9 +133,9 @@ contract ReadCallersTest is DSTest { // Broadcast Tests function testReadCallersWithActiveBroadcast(address sender) public { - vm.broadcast(sender); + VM.broadcast(sender); - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.Broadcast)); assertEq(newSender, sender); @@ -147,10 +147,10 @@ contract ReadCallersTest is DSTest { address expectedSender = msg.sender; address expectedTxOrigin = tx.origin; - vm.broadcast(sender); + VM.broadcast(sender); target.consumeNewCaller(); - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.None)); assertEq(newSender, expectedSender); @@ -159,11 +159,11 @@ contract ReadCallersTest is DSTest { function testReadCallersWithActiveRecurrentBroadcast(address sender) public { Target target = new Target(); - vm.startBroadcast(sender); + VM.startBroadcast(sender); for (uint256 i = 0; i < 5; i++) { target.consumeNewCaller(); - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.RecurrentBroadcast)); assertEq(newSender, sender); @@ -174,11 +174,11 @@ contract ReadCallersTest is DSTest { function testReadCallersAfterStoppingRecurrentBroadcast(address sender) public { address expectedSender = msg.sender; address expectedTxOrigin = tx.origin; - vm.startBroadcast(sender); + VM.startBroadcast(sender); - vm.stopBroadcast(); + VM.stopBroadcast(); - (Vm.CallerMode mode, address newSender, address newOrigin) = vm.readCallers(); + (Vm.CallerMode mode, address newSender, address newOrigin) = VM.readCallers(); assertEq(uint256(mode), uint256(Vm.CallerMode.None)); assertEq(newSender, expectedSender); diff --git a/testdata/default/cheats/RpcUrls.t.sol b/testdata/default/cheats/RpcUrls.t.sol index 86f4d33b1d41c..e39a414b45aec 100644 --- a/testdata/default/cheats/RpcUrls.t.sol +++ b/testdata/default/cheats/RpcUrls.t.sol @@ -16,14 +16,14 @@ contract RpcUrlTest is DSTest { // returns an error if env alias does not exist function testRevertsOnMissingEnv() public { vm._expectCheatcodeRevert("invalid rpc url: rpcUrlEnv"); - string memory url = vm.rpcUrl("rpcUrlEnv"); + vm.rpcUrl("rpcUrlEnv"); } // can set env and return correct url function testCanSetAndGetURLAndAllUrls() public { // this will fail because alias is not set vm._expectCheatcodeRevert("environment variable `RPC_ENV_ALIAS` not found"); - string[2][] memory _urls = vm.rpcUrls(); + vm.rpcUrls(); string memory url = vm.rpcUrl("mainnet"); vm.setEnv("RPC_ENV_ALIAS", url); diff --git a/testdata/default/cheats/SetNonceUnsafe.t.sol b/testdata/default/cheats/SetNonceUnsafe.t.sol index 0caf2b4ce7421..6be2fa67ade60 100644 --- a/testdata/default/cheats/SetNonceUnsafe.t.sol +++ b/testdata/default/cheats/SetNonceUnsafe.t.sol @@ -11,7 +11,7 @@ contract Foo { } contract SetNonceTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); Foo public foo; function setUp() public { @@ -19,16 +19,16 @@ contract SetNonceTest is DSTest { } function testSetNonceUnsafe() public { - vm.setNonceUnsafe(address(foo), 10); + VM.setNonceUnsafe(address(foo), 10); // makes sure working correctly after mutating nonce. foo.f(); - assertEq(vm.getNonce(address(foo)), 10); + assertEq(VM.getNonce(address(foo)), 10); foo.f(); } function testDoesNotFailDecreasingNonce() public { - vm.setNonce(address(foo), 10); - vm.setNonceUnsafe(address(foo), 5); - assertEq(vm.getNonce(address(foo)), 5); + VM.setNonce(address(foo), 10); + VM.setNonceUnsafe(address(foo), 5); + assertEq(VM.getNonce(address(foo)), 5); } } diff --git a/testdata/default/cheats/Skip.t.sol b/testdata/default/cheats/Skip.t.sol index d7e75fa0f51af..ed0b7a455561c 100644 --- a/testdata/default/cheats/Skip.t.sol +++ b/testdata/default/cheats/Skip.t.sol @@ -19,13 +19,13 @@ contract SkipTest is DSTest { revert("This test should fail"); } - function testFuzzSkip(uint256 x) public { + function testFuzzSkip(uint256 /* x */) public { vm.skip(true); revert("Should not reach revert"); } /// forge-config: default.allow_internal_expect_revert = true - function testRevertIfFuzzSkip(uint256 x) public { + function testRevertIfFuzzSkip(uint256 /* x */) public { vm.skip(false); vm.expectRevert("This test should fail"); revert("This test should fail"); diff --git a/testdata/default/cheats/Sleep.t.sol b/testdata/default/cheats/Sleep.t.sol index 7af548e742573..8fe28615e3f6b 100644 --- a/testdata/default/cheats/Sleep.t.sol +++ b/testdata/default/cheats/Sleep.t.sol @@ -5,7 +5,7 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract SleepTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testSleep() public { uint256 milliseconds = 1234; @@ -15,13 +15,13 @@ contract SleepTest is DSTest { // OS X does not support precision more than 1 second inputs[1] = "+%s000"; - bytes memory res = vm.ffi(inputs); - uint256 start = vm.parseUint(string(res)); + bytes memory res = VM.ffi(inputs); + uint256 start = VM.parseUint(string(res)); - vm.sleep(milliseconds); + VM.sleep(milliseconds); - res = vm.ffi(inputs); - uint256 end = vm.parseUint(string(res)); + res = VM.ffi(inputs); + uint256 end = VM.parseUint(string(res)); // Limit precision to 1000 ms assertGe(end - start, milliseconds / 1000 * 1000, "sleep failed"); @@ -37,13 +37,13 @@ contract SleepTest is DSTest { // OS X does not support precision more than 1 second inputs[1] = "+%s000"; - bytes memory res = vm.ffi(inputs); - uint256 start = vm.parseUint(string(res)); + bytes memory res = VM.ffi(inputs); + uint256 start = VM.parseUint(string(res)); - vm.sleep(milliseconds); + VM.sleep(milliseconds); - res = vm.ffi(inputs); - uint256 end = vm.parseUint(string(res)); + res = VM.ffi(inputs); + uint256 end = VM.parseUint(string(res)); // Limit precision to 1000 ms assertGe(end - start, milliseconds / 1000 * 1000, "sleep failed"); diff --git a/testdata/default/cheats/Store.t.sol b/testdata/default/cheats/Store.t.sol index 9a1ce6101c1b0..20245f3bdc037 100644 --- a/testdata/default/cheats/Store.t.sol +++ b/testdata/default/cheats/Store.t.sol @@ -10,7 +10,7 @@ contract Storage { } contract StoreTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); Storage store; function setUp() public { @@ -21,7 +21,7 @@ contract StoreTest is DSTest { assertEq(store.slot0(), 10, "initial value for slot 0 is incorrect"); assertEq(store.slot1(), 20, "initial value for slot 1 is incorrect"); - vm.store(address(store), bytes32(0), bytes32(uint256(1))); + VM.store(address(store), bytes32(0), bytes32(uint256(1))); assertEq(store.slot0(), 1, "store failed"); assertEq(store.slot1(), 20, "store failed"); } @@ -30,16 +30,16 @@ contract StoreTest is DSTest { assertEq(store.slot0(), 10, "initial value for slot 0 is incorrect"); assertEq(store.slot1(), 20, "initial value for slot 1 is incorrect"); - vm._expectCheatcodeRevert("cannot use precompile 0x0000000000000000000000000000000000000001 as an argument"); - vm.store(address(1), bytes32(0), bytes32(uint256(1))); + VM._expectCheatcodeRevert("cannot use precompile 0x0000000000000000000000000000000000000001 as an argument"); + VM.store(address(1), bytes32(0), bytes32(uint256(1))); } function testStoreFuzzed(uint256 slot0, uint256 slot1) public { assertEq(store.slot0(), 10, "initial value for slot 0 is incorrect"); assertEq(store.slot1(), 20, "initial value for slot 1 is incorrect"); - vm.store(address(store), bytes32(0), bytes32(slot0)); - vm.store(address(store), bytes32(uint256(1)), bytes32(slot1)); + VM.store(address(store), bytes32(0), bytes32(slot0)); + VM.store(address(store), bytes32(uint256(1)), bytes32(slot1)); assertEq(store.slot0(), slot0, "store failed"); assertEq(store.slot1(), slot1, "store failed"); } diff --git a/testdata/default/cheats/TryFfi.sol b/testdata/default/cheats/TryFfi.sol index 58d93a48b4fea..5c4ce813d353c 100644 --- a/testdata/default/cheats/TryFfi.sol +++ b/testdata/default/cheats/TryFfi.sol @@ -5,7 +5,7 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract TryFfiTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testTryFfi() public { string[] memory inputs = new string[](3); @@ -14,7 +14,7 @@ contract TryFfiTest is DSTest { inputs[2] = "echo -n 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000966666920776f726b730000000000000000000000000000000000000000000000"; - Vm.FfiResult memory f = vm.tryFfi(inputs); + Vm.FfiResult memory f = VM.tryFfi(inputs); (string memory output) = abi.decode(f.stdout, (string)); assertEq(output, "ffi works", "ffi failed"); assertEq(f.exitCode, 0, "ffi failed"); @@ -25,7 +25,7 @@ contract TryFfiTest is DSTest { inputs[0] = "ls"; inputs[1] = "wad"; - Vm.FfiResult memory f = vm.tryFfi(inputs); + Vm.FfiResult memory f = VM.tryFfi(inputs); assertTrue(f.exitCode != 0); } } diff --git a/testdata/default/cheats/Warp.t.sol b/testdata/default/cheats/Warp.t.sol index 7ba53f6e5eda4..22077a913ad49 100644 --- a/testdata/default/cheats/Warp.t.sol +++ b/testdata/default/cheats/Warp.t.sol @@ -5,22 +5,22 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract WarpTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testWarp() public { - vm.warp(10); + VM.warp(10); assertEq(block.timestamp, 10, "warp failed"); } function testWarpFuzzed(uint32 jump) public { uint256 pre = block.timestamp; - vm.warp(block.timestamp + jump); + VM.warp(block.timestamp + jump); assertEq(block.timestamp, pre + jump, "warp failed"); } function testWarp2() public { assertEq(block.timestamp, 1); - vm.warp(100); + VM.warp(100); assertEq(block.timestamp, 100); } } diff --git a/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol b/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol index bd70dd3aeafba..54b7299f2cdea 100644 --- a/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol +++ b/testdata/default/fuzz/invariant/common/InvariantPreserveState.t.sol @@ -12,7 +12,7 @@ struct FuzzSelector { // https://github.com/foundry-rs/foundry/issues/7219 contract Handler is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function thisFunctionReverts() external { if (block.number < 10) {} else { @@ -22,8 +22,8 @@ contract Handler is DSTest { function advanceTime(uint256 blocks) external { blocks = blocks % 10; - vm.roll(block.number + blocks); - vm.warp(block.timestamp + blocks * 12); + VM.roll(block.number + blocks); + VM.warp(block.timestamp + blocks * 12); } } diff --git a/testdata/default/logs/DebugLogs.t.sol b/testdata/default/logs/DebugLogs.t.sol index b560fd2bfb9ca..00bd59e01c661 100644 --- a/testdata/default/logs/DebugLogs.t.sol +++ b/testdata/default/logs/DebugLogs.t.sol @@ -4,7 +4,7 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract DebugLogsTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); constructor() { emit log_uint(0); @@ -25,14 +25,14 @@ contract DebugLogsTest is DSTest { function testRevertIfWithRevert() public { Fails fails = new Fails(); emit log_uint(4); - vm.expectRevert(); + VM.expectRevert(); fails.failure(); } /// forge-config: default.allow_internal_expect_revert = true function testRevertIfWithRequire() public { emit log_uint(5); - vm.expectRevert(); + VM.expectRevert(); require(false); } diff --git a/testdata/default/repros/Issue10302.t.sol b/testdata/default/repros/Issue10302.t.sol index c47332cb2872d..97ca152c72cf3 100644 --- a/testdata/default/repros/Issue10302.t.sol +++ b/testdata/default/repros/Issue10302.t.sol @@ -11,43 +11,43 @@ contract A { } contract Issue10302Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testDelegateFails() external { - vm.createSelectFork("sepolia"); + VM.createSelectFork("sepolia"); A a = new A(); - vm.startPrank(0x0fe884546476dDd290eC46318785046ef68a0BA9, true); + VM.startPrank(0x0fe884546476dDd290eC46318785046ef68a0BA9, true); (bool success,) = address(a).delegatecall(abi.encodeWithSelector(A.foo.selector)); - vm.stopPrank(); + VM.stopPrank(); require(success, "Delegate call should succeed"); } function testDelegatePassesWhenBalanceSetToZero() external { - vm.createSelectFork("sepolia"); + VM.createSelectFork("sepolia"); A a = new A(); - vm.startPrank(0x0fe884546476dDd290eC46318785046ef68a0BA9, true); - vm.deal(0x0fe884546476dDd290eC46318785046ef68a0BA9, 0 ether); + VM.startPrank(0x0fe884546476dDd290eC46318785046ef68a0BA9, true); + VM.deal(0x0fe884546476dDd290eC46318785046ef68a0BA9, 0 ether); (bool success,) = address(a).delegatecall(abi.encodeWithSelector(A.foo.selector)); - vm.stopPrank(); + VM.stopPrank(); require(success, "Delegate call should succeed"); } function testDelegateCallSucceeds() external { - vm.createSelectFork("sepolia"); + VM.createSelectFork("sepolia"); A a = new A(); - vm.startPrank(0xd363339eE47775888Df411A163c586a8BdEA9dbf, true); + VM.startPrank(0xd363339eE47775888Df411A163c586a8BdEA9dbf, true); (bool success,) = address(a).delegatecall(abi.encodeWithSelector(A.foo.selector)); - vm.stopPrank(); + VM.stopPrank(); require(success, "Delegate call should succeed"); } function testDelegateFailsWhenBalanceGtZero() external { - vm.createSelectFork("sepolia"); + VM.createSelectFork("sepolia"); A a = new A(); - vm.startPrank(0xd363339eE47775888Df411A163c586a8BdEA9dbf, true); - vm.deal(0xd363339eE47775888Df411A163c586a8BdEA9dbf, 1 ether); + VM.startPrank(0xd363339eE47775888Df411A163c586a8BdEA9dbf, true); + VM.deal(0xd363339eE47775888Df411A163c586a8BdEA9dbf, 1 ether); (bool success,) = address(a).delegatecall(abi.encodeWithSelector(A.foo.selector)); - vm.stopPrank(); + VM.stopPrank(); require(success, "Delegate call should succeed"); } } diff --git a/testdata/default/repros/Issue10477.t.sol b/testdata/default/repros/Issue10477.t.sol index 86d36fc741ef4..c1ebef7e51813 100644 --- a/testdata/default/repros/Issue10477.t.sol +++ b/testdata/default/repros/Issue10477.t.sol @@ -19,7 +19,7 @@ contract Counter { } contract Issue10477Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); address payable ALICE_ADDRESS = payable(0x70997970C51812dc3A010C7d01b50e0d17dc79C8); uint256 constant ALICE_PK = 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d; @@ -28,8 +28,8 @@ contract Issue10477Test is DSTest { SimpleDelegate delegate = new SimpleDelegate(); Counter counter = new Counter(); - vm.startBroadcast(ALICE_PK); - vm.signAndAttachDelegation(address(delegate), ALICE_PK); + VM.startBroadcast(ALICE_PK); + VM.signAndAttachDelegation(address(delegate), ALICE_PK); assertTrue(ALICE_ADDRESS.code.length > 0); (bool callResult, bytes memory callData) = @@ -38,12 +38,12 @@ contract Issue10477Test is DSTest { assertTrue(callResult); assertTrue(callData.length == 0); - vm.signAndAttachDelegation(address(0), ALICE_PK); + VM.signAndAttachDelegation(address(0), ALICE_PK); // Expected to succeed here assertTrue(ALICE_ADDRESS.code.length == 0); assertTrue(ALICE_ADDRESS.codehash == 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470); - vm.stopBroadcast(); + VM.stopBroadcast(); } } diff --git a/testdata/default/repros/Issue10527.t.sol b/testdata/default/repros/Issue10527.t.sol index fdf62b22db35c..a7b275c4b9b30 100644 --- a/testdata/default/repros/Issue10527.t.sol +++ b/testdata/default/repros/Issue10527.t.sol @@ -21,7 +21,7 @@ contract Issue10527Test is DSTest { event Event1(); event Event2(); - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); A a; @@ -30,14 +30,14 @@ contract Issue10527Test is DSTest { } function test_foo_Event1() public { - vm.expectEmit(address(a)); + VM.expectEmit(address(a)); emit Event1(); a.foo(); } function test_foo_Event2() public { - vm.expectEmit({emitter: address(a), count: 0}); + VM.expectEmit({emitter: address(a), count: 0}); emit Event2(); a.foo(); diff --git a/testdata/default/repros/Issue10552.t.sol b/testdata/default/repros/Issue10552.t.sol index e77168f150f4d..989524a9bc379 100644 --- a/testdata/default/repros/Issue10552.t.sol +++ b/testdata/default/repros/Issue10552.t.sol @@ -22,7 +22,7 @@ contract Counter { } contract Issue10552Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); Counter public counter; uint256 mainnetId; @@ -31,12 +31,12 @@ contract Issue10552Test is DSTest { function setUp() public { counter = new Counter(); counter.setNumber(10); - vm.makePersistent(address(counter)); + VM.makePersistent(address(counter)); - mainnetId = vm.createFork("mainnet"); - opId = vm.createFork("optimism"); + mainnetId = VM.createFork("mainnet"); + opId = VM.createFork("optimism"); - vm.selectFork(mainnetId); + VM.selectFork(mainnetId); counter.setNumber(100); counter.increment(); assertEq(counter.number(), 101); @@ -46,7 +46,7 @@ contract Issue10552Test is DSTest { } function test_change_fork_states() public { - vm.selectFork(opId); + VM.selectFork(opId); counter.increment(); // should account state changes from mainnet fork // without fix for this test was failing with 11 (initial setNumber(10) + one increment) != 103 @@ -54,7 +54,7 @@ contract Issue10552Test is DSTest { counter.setAnotherNumber(11); assertEq(counter.anotherNumber(), 11); - vm.selectFork(mainnetId); + VM.selectFork(mainnetId); counter.increment(); assertEq(counter.number(), 104); assertEq(counter.anotherNumber(), 11); diff --git a/testdata/default/repros/Issue10586.t.sol b/testdata/default/repros/Issue10586.t.sol index 3d7eefbf3ac03..e7d2980d067ba 100644 --- a/testdata/default/repros/Issue10586.t.sol +++ b/testdata/default/repros/Issue10586.t.sol @@ -5,15 +5,15 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract Target is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function setChainId() public { - vm.chainId(123); + VM.chainId(123); } } contract Issue10586Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); Target public target; @@ -32,7 +32,7 @@ contract Issue10586Test is DSTest { assertEq(block.chainid, 123); // Set the chainId to 100. - vm.chainId(100); + VM.chainId(100); // The chainId is set to 100 in the block. assertEq(block.chainid, 100); diff --git a/testdata/default/repros/Issue2623.t.sol b/testdata/default/repros/Issue2623.t.sol index 31252cae36c3b..a3d79bb522ea7 100644 --- a/testdata/default/repros/Issue2623.t.sol +++ b/testdata/default/repros/Issue2623.t.sol @@ -6,16 +6,16 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/2623 contract Issue2623Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testRollFork() public { - uint256 fork = vm.createFork("mainnet", 10); - vm.selectFork(fork); + uint256 fork = VM.createFork("mainnet", 10); + VM.selectFork(fork); assertEq(block.number, 10); assertEq(block.timestamp, 1438270128); - vm.rollFork(11); + VM.rollFork(11); assertEq(block.number, 11); assertEq(block.timestamp, 1438270136); diff --git a/testdata/default/repros/Issue2629.t.sol b/testdata/default/repros/Issue2629.t.sol index d46868903a60e..a51ee0f608a55 100644 --- a/testdata/default/repros/Issue2629.t.sol +++ b/testdata/default/repros/Issue2629.t.sol @@ -6,19 +6,19 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/2629 contract Issue2629Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testSelectFork() public { address coinbase = 0x0193d941b50d91BE6567c7eE1C0Fe7AF498b4137; - uint256 f1 = vm.createSelectFork("mainnet", 9); - vm.selectFork(f1); + uint256 f1 = VM.createSelectFork("mainnet", 9); + VM.selectFork(f1); assertEq(block.number, 9); assertEq(coinbase.balance, 11250000000000000000); - uint256 f2 = vm.createFork("mainnet", 10); - vm.selectFork(f2); + uint256 f2 = VM.createFork("mainnet", 10); + VM.selectFork(f2); assertEq(block.number, 10); assertEq(coinbase.balance, 16250000000000000000); diff --git a/testdata/default/repros/Issue2723.t.sol b/testdata/default/repros/Issue2723.t.sol index b7678df450cb8..60c624cd5bee0 100644 --- a/testdata/default/repros/Issue2723.t.sol +++ b/testdata/default/repros/Issue2723.t.sol @@ -6,17 +6,17 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/2723 contract Issue2723Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testRollFork() public { address coinbase = 0x0193d941b50d91BE6567c7eE1C0Fe7AF498b4137; - vm.createSelectFork("mainnet", 9); + VM.createSelectFork("mainnet", 9); assertEq(block.number, 9); assertEq(coinbase.balance, 11250000000000000000); - vm.rollFork(10); + VM.rollFork(10); assertEq(block.number, 10); assertEq(coinbase.balance, 16250000000000000000); diff --git a/testdata/default/repros/Issue2984.t.sol b/testdata/default/repros/Issue2984.t.sol index fbcd1ab8c3c4a..0f023d5f9b353 100644 --- a/testdata/default/repros/Issue2984.t.sol +++ b/testdata/default/repros/Issue2984.t.sol @@ -6,20 +6,20 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/2984 contract Issue2984Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); uint256 fork; uint256 snapshot; function setUp() public { - fork = vm.createSelectFork("avaxTestnet", 12880747); - snapshot = vm.snapshotState(); + fork = VM.createSelectFork("avaxTestnet", 12880747); + snapshot = VM.snapshotState(); } function testForkRevertSnapshot() public { - vm.revertToState(snapshot); + VM.revertToState(snapshot); } function testForkSelectSnapshot() public { - uint256 fork2 = vm.createSelectFork("avaxTestnet", 12880749); + uint256 fork2 = VM.createSelectFork("avaxTestnet", 12880749); } } diff --git a/testdata/default/repros/Issue3055.t.sol b/testdata/default/repros/Issue3055.t.sol index 90ac8c3b08afd..0cc50b6779292 100644 --- a/testdata/default/repros/Issue3055.t.sol +++ b/testdata/default/repros/Issue3055.t.sol @@ -6,31 +6,31 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3055 contract Issue3055Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function test_snapshot() external { - uint256 snapshotId = vm.snapshotState(); + uint256 snapshotId = VM.snapshotState(); assertEq(uint256(0), uint256(1)); - vm.revertToState(snapshotId); + VM.revertToState(snapshotId); } function test_snapshot2() public { - uint256 snapshotId = vm.snapshotState(); + uint256 snapshotId = VM.snapshotState(); assertTrue(false); - vm.revertToState(snapshotId); + VM.revertToState(snapshotId); assertTrue(true); } function test_snapshot3(uint256) public { - vm.expectRevert(); + VM.expectRevert(); // Call exposed_snapshot3() using this to perform an external call, // so we can properly test for reverts. this.exposed_snapshot3(); } function exposed_snapshot3() public { - uint256 snapshotId = vm.snapshotState(); + uint256 snapshotId = VM.snapshotState(); assertTrue(false); - vm.revertToState(snapshotId); + VM.revertToState(snapshotId); } } diff --git a/testdata/default/repros/Issue3110.t.sol b/testdata/default/repros/Issue3110.t.sol index 9f1da8d032ec3..8d00542086215 100644 --- a/testdata/default/repros/Issue3110.t.sol +++ b/testdata/default/repros/Issue3110.t.sol @@ -6,26 +6,26 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3110 abstract contract ZeroState is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); // deployer and users - address public deployer = vm.addr(1); + address public deployer = VM.addr(1); Token aaveToken; uint256 public mainnetFork; function setUp() public virtual { - vm.label(deployer, "Deployer"); + VM.label(deployer, "Deployer"); - vm.startPrank(deployer); - mainnetFork = vm.createFork("mainnet"); - vm.selectFork(mainnetFork); + VM.startPrank(deployer); + mainnetFork = VM.createFork("mainnet"); + VM.selectFork(mainnetFork); - vm.rollFork(block.number - 20); + VM.rollFork(block.number - 20); // deploy tokens aaveToken = new Token(); - vm.makePersistent(address(aaveToken)); - vm.stopPrank(); + VM.makePersistent(address(aaveToken)); + VM.stopPrank(); } } @@ -38,7 +38,7 @@ abstract contract TestSate is ZeroState { contract TestFork is TestSate { function testFork() public { - vm.rollFork(block.number + 1); + VM.rollFork(block.number + 1); emit log_uint(aaveToken.balanceOf(deployer)); } } diff --git a/testdata/default/repros/Issue3192.t.sol b/testdata/default/repros/Issue3192.t.sol index 9c5be8d89f3d6..17a9f317fceac 100644 --- a/testdata/default/repros/Issue3192.t.sol +++ b/testdata/default/repros/Issue3192.t.sol @@ -6,18 +6,18 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3192 contract Issue3192Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); uint256 fork1; uint256 fork2; function setUp() public { - fork1 = vm.createFork("mainnet", 7475589); - fork2 = vm.createFork("mainnet", 12880747); - vm.selectFork(fork1); + fork1 = VM.createFork("mainnet", 7475589); + fork2 = VM.createFork("mainnet", 12880747); + VM.selectFork(fork1); } function testForkSwapSelect() public { - assertEq(fork1, vm.activeFork()); - vm.selectFork(fork2); + assertEq(fork1, VM.activeFork()); + VM.selectFork(fork2); } } diff --git a/testdata/default/repros/Issue3221.t.sol b/testdata/default/repros/Issue3221.t.sol index 81398c41fc290..be170e24aa5d3 100644 --- a/testdata/default/repros/Issue3221.t.sol +++ b/testdata/default/repros/Issue3221.t.sol @@ -6,29 +6,29 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3221 contract Issue3221Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); uint256 fork1; uint256 fork2; function setUp() public { - fork1 = vm.createFork("sepolia", 5565573); - fork2 = vm.createFork("avaxTestnet", 12880747); + fork1 = VM.createFork("sepolia", 5565573); + fork2 = VM.createFork("avaxTestnet", 12880747); } function testForkNonce() public { address user = address(0xF0959944122fb1ed4CfaBA645eA06EED30427BAA); // Loads but doesn't touch - assertEq(vm.getNonce(user), 0); + assertEq(VM.getNonce(user), 0); - vm.selectFork(fork2); - assertEq(vm.getNonce(user), 3); - vm.prank(user); + VM.selectFork(fork2); + assertEq(VM.getNonce(user), 3); + VM.prank(user); new Counter(); - vm.selectFork(fork1); - assertEq(vm.getNonce(user), 1); - vm.prank(user); + VM.selectFork(fork1); + assertEq(VM.getNonce(user), 1); + VM.prank(user); new Counter(); } } diff --git a/testdata/default/repros/Issue3596.t.sol b/testdata/default/repros/Issue3596.t.sol index b0c6785874375..da0d0bb3bfde0 100644 --- a/testdata/default/repros/Issue3596.t.sol +++ b/testdata/default/repros/Issue3596.t.sol @@ -6,17 +6,17 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3596 contract Issue3596Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testDealTransfer() public { - address addr = vm.addr(1337); - vm.startPrank(addr); - vm.deal(addr, 20000001 ether); + address addr = VM.addr(1337); + VM.startPrank(addr); + VM.deal(addr, 20000001 ether); payable(address(this)).transfer(20000000 ether); Nested nested = new Nested(); nested.doStuff(); - vm.stopPrank(); + VM.stopPrank(); } } diff --git a/testdata/default/repros/Issue3703.t.sol b/testdata/default/repros/Issue3703.t.sol index 48651be24c669..7ca9fa4d57704 100644 --- a/testdata/default/repros/Issue3703.t.sol +++ b/testdata/default/repros/Issue3703.t.sol @@ -6,11 +6,11 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3703 contract Issue3703Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function setUp() public { uint256 fork = - vm.createSelectFork("polygon", bytes32(0xbed0c8c1b9ff8bf0452979d170c52893bb8954f18a904aa5bcbd0f709be050b9)); + VM.createSelectFork("polygon", bytes32(0xbed0c8c1b9ff8bf0452979d170c52893bb8954f18a904aa5bcbd0f709be050b9)); } function poolState(address poolAddr, uint256 expectedSqrtPriceX96, uint256 expectedLiquidity) private { diff --git a/testdata/default/repros/Issue3723.t.sol b/testdata/default/repros/Issue3723.t.sol index 9ea3fe733c944..64b9ffe7eb308 100644 --- a/testdata/default/repros/Issue3723.t.sol +++ b/testdata/default/repros/Issue3723.t.sol @@ -6,13 +6,13 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/3723 contract Issue3723Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testFailExample() public { - vm.expectRevert(); + VM.expectRevert(); revert(); - vm.expectRevert(); + VM.expectRevert(); emit log_string("Do not revert"); } } diff --git a/testdata/default/repros/Issue4586.t.sol b/testdata/default/repros/Issue4586.t.sol index c904af1e46abb..9930ca47e5650 100644 --- a/testdata/default/repros/Issue4586.t.sol +++ b/testdata/default/repros/Issue4586.t.sol @@ -6,14 +6,14 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/4586 contract Issue4586Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); uint256 constant initialBlock = 16730733; InvariantHandler handler; function setUp() public { - vm.createSelectFork("mainnet", initialBlock); + VM.createSelectFork("mainnet", initialBlock); handler = new InvariantHandler(); } @@ -25,19 +25,19 @@ contract Issue4586Test is DSTest { function test_rollForkTestContract() public { assertEq(block.number, initialBlock); - vm.rollFork(block.number + 1); + VM.rollFork(block.number + 1); assertEq(block.number, initialBlock + 1); } } contract InvariantHandler { address constant HEVM_ADDRESS = address(bytes20(uint160(uint256(keccak256("hevm cheat code"))))); - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); uint256 public calledRollFork; function rollFork() public { - vm.rollFork(block.number + 1); + VM.rollFork(block.number + 1); calledRollFork += 1; } } diff --git a/testdata/default/repros/Issue4832.t.sol b/testdata/default/repros/Issue4832.t.sol index 192d805c1bc36..ffbaafb4ec307 100644 --- a/testdata/default/repros/Issue4832.t.sol +++ b/testdata/default/repros/Issue4832.t.sol @@ -6,12 +6,12 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/4832 contract Issue4832Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testFailExample() public { assertEq(uint256(1), 2); - vm.expectRevert(); + VM.expectRevert(); revert(); } } diff --git a/testdata/default/repros/Issue5529.t.sol b/testdata/default/repros/Issue5529.t.sol index 14ec7cfdbce60..3c829704b1b07 100644 --- a/testdata/default/repros/Issue5529.t.sol +++ b/testdata/default/repros/Issue5529.t.sol @@ -17,20 +17,20 @@ contract Counter { } contract Issue5529Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); Counter public counter; - address public constant default_create2_factory = 0x4e59b44847b379578588920cA78FbF26c0B4956C; + address public constant DEFAULT_CREATE2_FACTORY = 0x4e59b44847b379578588920cA78FbF26c0B4956C; function testCreate2FactoryUsedInTests() public { - address a = vm.computeCreate2Address(0, keccak256(type(Counter).creationCode), address(default_create2_factory)); + address a = VM.computeCreate2Address(0, keccak256(type(Counter).creationCode), address(DEFAULT_CREATE2_FACTORY)); address b = address(new Counter{salt: 0}()); require(a == b, "create2 address mismatch"); } function testCreate2FactoryUsedWhenPranking() public { - vm.startPrank(address(1234)); - address a = vm.computeCreate2Address(0, keccak256(type(Counter).creationCode), address(default_create2_factory)); + VM.startPrank(address(1234)); + address a = VM.computeCreate2Address(0, keccak256(type(Counter).creationCode), address(DEFAULT_CREATE2_FACTORY)); address b = address(new Counter{salt: 0}()); require(a == b, "create2 address mismatch"); } diff --git a/testdata/default/repros/Issue5739.t.sol b/testdata/default/repros/Issue5739.t.sol index 6f3494b7e6e7d..9a40c8b2eba8c 100644 --- a/testdata/default/repros/Issue5739.t.sol +++ b/testdata/default/repros/Issue5739.t.sol @@ -10,26 +10,26 @@ interface IERC20 { // https://github.com/foundry-rs/foundry/issues/5739 contract Issue5739Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); IERC20 dai; function setUp() public { - vm.createSelectFork("mainnet", 19000000); + VM.createSelectFork("mainnet", 19000000); dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F); } function testRollForkStateUpdated() public { // dai not persistent so state should be updated between rolls assertEq(dai.totalSupply(), 3723031040751006502480211083); - vm.rollFork(19925849); + VM.rollFork(19925849); assertEq(dai.totalSupply(), 3320242279303699674318705475); } function testRollForkStatePersisted() public { // make dai persistent so state is preserved between rolls - vm.makePersistent(address(dai)); + VM.makePersistent(address(dai)); assertEq(dai.totalSupply(), 3723031040751006502480211083); - vm.rollFork(19925849); + VM.rollFork(19925849); assertEq(dai.totalSupply(), 3723031040751006502480211083); } } diff --git a/testdata/default/repros/Issue6759.t.sol b/testdata/default/repros/Issue6759.t.sol index ffdcb88935a92..3052f0c404410 100644 --- a/testdata/default/repros/Issue6759.t.sol +++ b/testdata/default/repros/Issue6759.t.sol @@ -6,12 +6,12 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/6759 contract Issue6759Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testCreateMulti() public { - uint256 fork1 = vm.createFork("mainnet", 10); - uint256 fork2 = vm.createFork("mainnet", 10); - uint256 fork3 = vm.createFork("mainnet", 10); + uint256 fork1 = VM.createFork("mainnet", 10); + uint256 fork2 = VM.createFork("mainnet", 10); + uint256 fork3 = VM.createFork("mainnet", 10); assert(fork1 != fork2); assert(fork1 != fork3); assert(fork2 != fork3); diff --git a/testdata/default/repros/Issue8168.t.sol b/testdata/default/repros/Issue8168.t.sol index 9a072ce4bbf8f..915f3cba6cbfb 100644 --- a/testdata/default/repros/Issue8168.t.sol +++ b/testdata/default/repros/Issue8168.t.sol @@ -6,33 +6,33 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/8168 contract Issue8168Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testForkWarpRollPreserved() public { - uint256 fork1 = vm.createFork("mainnet"); - uint256 fork2 = vm.createFork("mainnet"); + uint256 fork1 = VM.createFork("mainnet"); + uint256 fork2 = VM.createFork("mainnet"); - vm.selectFork(fork1); + VM.selectFork(fork1); uint256 initial_fork1_number = block.number; uint256 initial_fork1_ts = block.timestamp; - vm.warp(block.timestamp + 1000); - vm.roll(block.number + 100); + VM.warp(block.timestamp + 1000); + VM.roll(block.number + 100); assertEq(block.timestamp, initial_fork1_ts + 1000); assertEq(block.number, initial_fork1_number + 100); - vm.selectFork(fork2); + VM.selectFork(fork2); uint256 initial_fork2_number = block.number; uint256 initial_fork2_ts = block.timestamp; - vm.warp(block.timestamp + 2000); - vm.roll(block.number + 200); + VM.warp(block.timestamp + 2000); + VM.roll(block.number + 200); assertEq(block.timestamp, initial_fork2_ts + 2000); assertEq(block.number, initial_fork2_number + 200); - vm.selectFork(fork1); + VM.selectFork(fork1); assertEq(block.timestamp, initial_fork1_ts + 1000); assertEq(block.number, initial_fork1_number + 100); - vm.selectFork(fork2); + VM.selectFork(fork2); assertEq(block.timestamp, initial_fork2_ts + 2000); assertEq(block.number, initial_fork2_number + 200); } diff --git a/testdata/default/repros/Issue8287.t.sol b/testdata/default/repros/Issue8287.t.sol index d1e372bda91d8..9d9c22525215c 100644 --- a/testdata/default/repros/Issue8287.t.sol +++ b/testdata/default/repros/Issue8287.t.sol @@ -6,22 +6,22 @@ import "cheats/Vm.sol"; // https://github.com/foundry-rs/foundry/issues/8287 contract Issue8287Test is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testRpcBalance() public { - uint256 f2 = vm.createSelectFork("mainnet", 10); - bytes memory data = vm.rpc("eth_getBalance", "[\"0x551e7784778ef8e048e495df49f2614f84a4f1dc\",\"0x0\"]"); - string memory m = vm.toString(data); + uint256 f2 = VM.createSelectFork("mainnet", 10); + bytes memory data = VM.rpc("eth_getBalance", "[\"0x551e7784778ef8e048e495df49f2614f84a4f1dc\",\"0x0\"]"); + string memory m = VM.toString(data); assertEq(m, "0x2086ac351052600000"); } function testRpcStorage() public { - uint256 f2 = vm.createSelectFork("mainnet", 10); - bytes memory data = vm.rpc( + uint256 f2 = VM.createSelectFork("mainnet", 10); + bytes memory data = VM.rpc( "eth_getStorageAt", "[\"0x551e7784778ef8e048e495df49f2614f84a4f1dc\",\"0x40BdB4497614bAe1A67061EE20AAdE3c2067AC9e\",\"0x0\"]" ); - string memory m = vm.toString(data); + string memory m = VM.toString(data); assertEq(m, "0x0000000000000000000000000000000000000000000000000000000000000000"); } } diff --git a/testdata/default/trace/Trace.t.sol b/testdata/default/trace/Trace.t.sol index 19af6dd7c9fe7..3e7ed983a8143 100644 --- a/testdata/default/trace/Trace.t.sol +++ b/testdata/default/trace/Trace.t.sol @@ -52,7 +52,7 @@ contract RecursiveCall { } contract TraceTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); uint256 nodeId = 0; RecursiveCall first; @@ -63,7 +63,7 @@ contract TraceTest is DSTest { function create() public returns (RecursiveCall) { RecursiveCall node = new RecursiveCall(address(this)); - vm.label(address(node), string(abi.encodePacked("Node ", uintToString(nodeId++)))); + VM.label(address(node), string(abi.encodePacked("Node ", uintToString(nodeId++)))); return node; } diff --git a/testdata/paris/cheats/Fork.t.sol b/testdata/paris/cheats/Fork.t.sol index 2f2e627de131a..7e385bd1ee029 100644 --- a/testdata/paris/cheats/Fork.t.sol +++ b/testdata/paris/cheats/Fork.t.sol @@ -11,10 +11,10 @@ interface IWETH { contract ForkTest is DSTest { address constant WETH_TOKEN_ADDR = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; - uint256 constant mainblock = 14_608_400; + uint256 constant MAIN_BLOCK = 14_608_400; - Vm constant vm = Vm(HEVM_ADDRESS); - IWETH WETH = IWETH(WETH_TOKEN_ADDR); + Vm constant VM = Vm(HEVM_ADDRESS); + IWETH weth = IWETH(WETH_TOKEN_ADDR); uint256 forkA; uint256 forkB; @@ -23,8 +23,8 @@ contract ForkTest is DSTest { // this will create two _different_ forks during setup function setUp() public { - forkA = vm.createFork("mainnet", mainblock); - forkB = vm.createFork("mainnet2", mainblock - 1); + forkA = VM.createFork("mainnet", MAIN_BLOCK); + forkB = VM.createFork("mainnet2", MAIN_BLOCK - 1); testValue = 999; } @@ -35,48 +35,48 @@ contract ForkTest is DSTest { // ensures we can create and select in one step function testCreateSelect() public { - uint256 fork = vm.createSelectFork("mainnet"); - assertEq(fork, vm.activeFork()); + uint256 fork = VM.createSelectFork("mainnet"); + assertEq(fork, VM.activeFork()); } // ensures forks use different ids function testCanSwitchForks() public { - vm.selectFork(forkA); - vm.selectFork(forkB); - vm.selectFork(forkB); - vm.selectFork(forkA); + VM.selectFork(forkA); + VM.selectFork(forkB); + VM.selectFork(forkB); + VM.selectFork(forkA); } function testForksHaveSeparatedStorage() public { - vm.selectFork(forkA); + VM.selectFork(forkA); // read state from forkA - assert(WETH.balanceOf(0x0000000000000000000000000000000000000000) != 1); + assert(weth.balanceOf(0x0000000000000000000000000000000000000000) != 1); - vm.selectFork(forkB); + VM.selectFork(forkB); // read state from forkB - uint256 forkBbalance = WETH.balanceOf(0x0000000000000000000000000000000000000000); + uint256 forkBbalance = weth.balanceOf(0x0000000000000000000000000000000000000000); assert(forkBbalance != 1); - vm.selectFork(forkA); + VM.selectFork(forkA); // modify state bytes32 value = bytes32(uint256(1)); // "0x3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff" is the slot storing the balance of zero address for the weth contract // `cast index address uint 0x0000000000000000000000000000000000000000 3` - bytes32 zero_address_balance_slot = 0x3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff; - vm.store(WETH_TOKEN_ADDR, zero_address_balance_slot, value); + bytes32 zeroAddressBalanceSlot = 0x3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff; + VM.store(WETH_TOKEN_ADDR, zeroAddressBalanceSlot, value); assertEq( - WETH.balanceOf(0x0000000000000000000000000000000000000000), + weth.balanceOf(0x0000000000000000000000000000000000000000), 1, "Cheatcode did not change value at the storage slot." ); // switch forks and ensure the balance on forkB remains untouched - vm.selectFork(forkB); + VM.selectFork(forkB); assert(forkBbalance != 1); // balance of forkB is untouched assertEq( - WETH.balanceOf(0x0000000000000000000000000000000000000000), + weth.balanceOf(0x0000000000000000000000000000000000000000), forkBbalance, "Cheatcode did not change value at the storage slot." ); @@ -86,40 +86,40 @@ contract ForkTest is DSTest { assertEq(testValue, 999); uint256 val = 300; - vm.selectFork(forkA); + VM.selectFork(forkA); assertEq(val, 300); testValue = 100; - vm.selectFork(forkB); + VM.selectFork(forkB); assertEq(val, 300); assertEq(testValue, 100); val = 99; testValue = 300; - vm.selectFork(forkA); + VM.selectFork(forkA); assertEq(val, 99); assertEq(testValue, 300); } // ensures forks use different ids function testCanChangeChainId() public { - vm.selectFork(forkA); + VM.selectFork(forkA); uint256 newChainId = 1337; - vm.chainId(newChainId); + VM.chainId(newChainId); uint256 expected = block.chainid; assertEq(newChainId, expected); } // ensures forks change chain ids automatically function testCanAutoUpdateChainId() public { - vm.createSelectFork("sepolia"); + VM.createSelectFork("sepolia"); assertEq(block.chainid, 11155111); } // ensures forks storage is cached at block function testStorageCaching() public { - vm.createSelectFork("mainnet", 19800000); + VM.createSelectFork("mainnet", 19800000); } } diff --git a/testdata/paris/cheats/GasSnapshots.t.sol b/testdata/paris/cheats/GasSnapshots.t.sol index 98abfa3e48efe..c5cd15ebdb587 100644 --- a/testdata/paris/cheats/GasSnapshots.t.sol +++ b/testdata/paris/cheats/GasSnapshots.t.sol @@ -5,7 +5,7 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract GasSnapshotTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); uint256 public slot0; Flare public flare; @@ -15,33 +15,33 @@ contract GasSnapshotTest is DSTest { } function testSnapshotGasSectionExternal() public { - vm.startSnapshotGas("testAssertGasExternal"); + VM.startSnapshotGas("testAssertGasExternal"); flare.run(1); - uint256 gasUsed = vm.stopSnapshotGas(); + uint256 gasUsed = VM.stopSnapshotGas(); assertGt(gasUsed, 0); } function testSnapshotGasSectionInternal() public { - vm.startSnapshotGas("testAssertGasInternalA"); + VM.startSnapshotGas("testAssertGasInternalA"); slot0 = 1; - vm.stopSnapshotGas(); + VM.stopSnapshotGas(); - vm.startSnapshotGas("testAssertGasInternalB"); + VM.startSnapshotGas("testAssertGasInternalB"); slot0 = 2; - vm.stopSnapshotGas(); + VM.stopSnapshotGas(); - vm.startSnapshotGas("testAssertGasInternalC"); + VM.startSnapshotGas("testAssertGasInternalC"); slot0 = 0; - vm.stopSnapshotGas(); + VM.stopSnapshotGas(); - vm.startSnapshotGas("testAssertGasInternalD"); + VM.startSnapshotGas("testAssertGasInternalD"); slot0 = 1; - vm.stopSnapshotGas(); + VM.stopSnapshotGas(); - vm.startSnapshotGas("testAssertGasInternalE"); + VM.startSnapshotGas("testAssertGasInternalE"); slot0 = 2; - vm.stopSnapshotGas(); + VM.stopSnapshotGas(); } // Writes to `GasSnapshotTest` group with custom names. @@ -50,9 +50,9 @@ contract GasSnapshotTest is DSTest { uint256 b = 456; uint256 c = 789; - vm.snapshotValue("a", a); - vm.snapshotValue("b", b); - vm.snapshotValue("c", c); + VM.snapshotValue("a", a); + VM.snapshotValue("b", b); + VM.snapshotValue("c", c); } // Writes to same `GasSnapshotTest` group with custom names. @@ -61,9 +61,9 @@ contract GasSnapshotTest is DSTest { uint256 e = 456; uint256 f = 789; - vm.snapshotValue("d", d); - vm.snapshotValue("e", e); - vm.snapshotValue("f", f); + VM.snapshotValue("d", d); + VM.snapshotValue("e", e); + VM.snapshotValue("f", f); } // Writes to `CustomGroup` group with custom names. @@ -73,9 +73,9 @@ contract GasSnapshotTest is DSTest { uint256 i = 456; uint256 q = 789; - vm.snapshotValue("CustomGroup", "q", q); - vm.snapshotValue("CustomGroup", "i", i); - vm.snapshotValue("CustomGroup", "o", o); + VM.snapshotValue("CustomGroup", "q", q); + VM.snapshotValue("CustomGroup", "i", i); + VM.snapshotValue("CustomGroup", "o", o); } // Writes to `CustomGroup` group with custom names. @@ -85,50 +85,50 @@ contract GasSnapshotTest is DSTest { uint256 e = 456; uint256 z = 789; - vm.snapshotValue("CustomGroup", "z", z); - vm.snapshotValue("CustomGroup", "x", x); - vm.snapshotValue("CustomGroup", "e", e); + VM.snapshotValue("CustomGroup", "z", z); + VM.snapshotValue("CustomGroup", "x", x); + VM.snapshotValue("CustomGroup", "e", e); } // Writes to `GasSnapshotTest` group with `testSnapshotGasDefault` name. function testSnapshotGasSectionDefaultGroupStop() public { - vm.startSnapshotGas("testSnapshotGasSection"); + VM.startSnapshotGas("testSnapshotGasSection"); flare.run(256); - // vm.stopSnapshotGas() will use the last snapshot name. - uint256 gasUsed = vm.stopSnapshotGas(); + // VM.stopSnapshotGas() will use the last snapshot name. + uint256 gasUsed = VM.stopSnapshotGas(); assertGt(gasUsed, 0); } // Writes to `GasSnapshotTest` group with `testSnapshotGasCustom` name. function testSnapshotGasSectionCustomGroupStop() public { - vm.startSnapshotGas("CustomGroup", "testSnapshotGasSection"); + VM.startSnapshotGas("CustomGroup", "testSnapshotGasSection"); flare.run(256); - // vm.stopSnapshotGas() will use the last snapshot name, even with custom group. - uint256 gasUsed = vm.stopSnapshotGas(); + // VM.stopSnapshotGas() will use the last snapshot name, even with custom group. + uint256 gasUsed = VM.stopSnapshotGas(); assertGt(gasUsed, 0); } // Writes to `GasSnapshotTest` group with `testSnapshotGasSection` name. function testSnapshotGasSectionName() public { - vm.startSnapshotGas("testSnapshotGasSectionName"); + VM.startSnapshotGas("testSnapshotGasSectionName"); flare.run(256); - uint256 gasUsed = vm.stopSnapshotGas("testSnapshotGasSectionName"); + uint256 gasUsed = VM.stopSnapshotGas("testSnapshotGasSectionName"); assertGt(gasUsed, 0); } // Writes to `CustomGroup` group with `testSnapshotGasSection` name. function testSnapshotGasSectionGroupName() public { - vm.startSnapshotGas("CustomGroup", "testSnapshotGasSectionGroupName"); + VM.startSnapshotGas("CustomGroup", "testSnapshotGasSectionGroupName"); flare.run(256); - uint256 gasUsed = vm.stopSnapshotGas("CustomGroup", "testSnapshotGasSectionGroupName"); + uint256 gasUsed = VM.stopSnapshotGas("CustomGroup", "testSnapshotGasSectionGroupName"); assertGt(gasUsed, 0); } @@ -136,7 +136,7 @@ contract GasSnapshotTest is DSTest { function testSnapshotGasLastCallName() public { flare.run(1); - uint256 gasUsed = vm.snapshotGasLastCall("testSnapshotGasLastCallName"); + uint256 gasUsed = VM.snapshotGasLastCall("testSnapshotGasLastCallName"); assertGt(gasUsed, 0); } @@ -144,13 +144,13 @@ contract GasSnapshotTest is DSTest { function testSnapshotGasLastCallGroupName() public { flare.run(1); - uint256 gasUsed = vm.snapshotGasLastCall("CustomGroup", "testSnapshotGasLastCallGroupName"); + uint256 gasUsed = VM.snapshotGasLastCall("CustomGroup", "testSnapshotGasLastCallGroupName"); assertGt(gasUsed, 0); } } contract GasComparisonTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); uint256 public slot0; uint256 public slot1; @@ -159,30 +159,30 @@ contract GasComparisonTest is DSTest { function testGasComparisonEmpty() public { // Start a cheatcode snapshot. - vm.startSnapshotGas("ComparisonGroup", "testGasComparisonEmptyA"); - uint256 a = vm.stopSnapshotGas(); + VM.startSnapshotGas("ComparisonGroup", "testGasComparisonEmptyA"); + uint256 a = VM.stopSnapshotGas(); // Start a comparitive Solidity snapshot. _snapStart(); uint256 b = _snapEnd(); - vm.snapshotValue("ComparisonGroup", "testGasComparisonEmptyB", b); + VM.snapshotValue("ComparisonGroup", "testGasComparisonEmptyB", b); assertEq(a, b); } function testGasComparisonInternalCold() public { // Start a cheatcode snapshot. - vm.startSnapshotGas("ComparisonGroup", "testGasComparisonInternalColdA"); + VM.startSnapshotGas("ComparisonGroup", "testGasComparisonInternalColdA"); slot0 = 1; - uint256 a = vm.stopSnapshotGas(); + uint256 a = VM.stopSnapshotGas(); // Start a comparitive Solidity snapshot. _snapStart(); slot1 = 1; uint256 b = _snapEnd(); - vm.snapshotValue("ComparisonGroup", "testGasComparisonInternalColdB", b); + VM.snapshotValue("ComparisonGroup", "testGasComparisonInternalColdB", b); - vm.assertApproxEqAbs(a, b, 6); + VM.assertApproxEqAbs(a, b, 6); } function testGasComparisonInternalWarm() public { @@ -190,17 +190,17 @@ contract GasComparisonTest is DSTest { slot0 = 1; // Start a cheatcode snapshot. - vm.startSnapshotGas("ComparisonGroup", "testGasComparisonInternalWarmA"); + VM.startSnapshotGas("ComparisonGroup", "testGasComparisonInternalWarmA"); slot0 = 2; - uint256 a = vm.stopSnapshotGas(); + uint256 a = VM.stopSnapshotGas(); // Start a comparitive Solidity snapshot. _snapStart(); slot0 = 3; uint256 b = _snapEnd(); - vm.snapshotValue("ComparisonGroup", "testGasComparisonInternalWarmB", b); + VM.snapshotValue("ComparisonGroup", "testGasComparisonInternalWarmB", b); - vm.assertApproxEqAbs(a, b, 6); + VM.assertApproxEqAbs(a, b, 6); } function testGasComparisonExternal() public { @@ -209,30 +209,30 @@ contract GasComparisonTest is DSTest { target.update(1); // Start a cheatcode snapshot. - vm.startSnapshotGas("ComparisonGroup", "testGasComparisonExternalA"); + VM.startSnapshotGas("ComparisonGroup", "testGasComparisonExternalA"); target.update(2); - uint256 a = vm.stopSnapshotGas(); + uint256 a = VM.stopSnapshotGas(); // Start a comparitive Solidity snapshot. _snapStart(); target.update(3); uint256 b = _snapEnd(); - vm.snapshotValue("ComparisonGroup", "testGasComparisonExternalB", b); + VM.snapshotValue("ComparisonGroup", "testGasComparisonExternalB", b); assertEq(a, b); } function testGasComparisonCreate() public { // Start a cheatcode snapshot. - vm.startSnapshotGas("ComparisonGroup", "testGasComparisonCreateA"); + VM.startSnapshotGas("ComparisonGroup", "testGasComparisonCreateA"); new TargetC(); - uint256 a = vm.stopSnapshotGas(); + uint256 a = VM.stopSnapshotGas(); // Start a comparitive Solidity snapshot. _snapStart(); new TargetC(); uint256 b = _snapEnd(); - vm.snapshotValue("ComparisonGroup", "testGasComparisonCreateB", b); + VM.snapshotValue("ComparisonGroup", "testGasComparisonCreateB", b); assertEq(a, b); } @@ -243,15 +243,15 @@ contract GasComparisonTest is DSTest { target.update(1); // Start a cheatcode snapshot. - vm.startSnapshotGas("ComparisonGroup", "testGasComparisonNestedCallsA"); + VM.startSnapshotGas("ComparisonGroup", "testGasComparisonNestedCallsA"); target.update(2); - uint256 a = vm.stopSnapshotGas(); + uint256 a = VM.stopSnapshotGas(); // Start a comparitive Solidity snapshot. _snapStart(); target.update(3); uint256 b = _snapEnd(); - vm.snapshotValue("ComparisonGroup", "testGasComparisonNestedCallsB", b); + VM.snapshotValue("ComparisonGroup", "testGasComparisonNestedCallsB", b); assertEq(a, b); } @@ -262,15 +262,15 @@ contract GasComparisonTest is DSTest { flare.run(1); // Start a cheatcode snapshot. - vm.startSnapshotGas("ComparisonGroup", "testGasComparisonFlareA"); + VM.startSnapshotGas("ComparisonGroup", "testGasComparisonFlareA"); flare.run(256); - uint256 a = vm.stopSnapshotGas(); + uint256 a = VM.stopSnapshotGas(); // Start a comparitive Solidity snapshot. _snapStart(); flare.run(256); uint256 b = _snapEnd(); - vm.snapshotValue("ComparisonGroup", "testGasComparisonFlareB", b); + VM.snapshotValue("ComparisonGroup", "testGasComparisonFlareB", b); assertEq(a, b); } diff --git a/testdata/paris/cheats/LastCallGas.t.sol b/testdata/paris/cheats/LastCallGas.t.sol index 23f6df224963f..e3deaff13323a 100644 --- a/testdata/paris/cheats/LastCallGas.t.sol +++ b/testdata/paris/cheats/LastCallGas.t.sol @@ -29,7 +29,7 @@ contract Target { } abstract contract LastCallGasFixture is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); Target public target; struct Gas { @@ -39,8 +39,8 @@ abstract contract LastCallGasFixture is DSTest { } function testRevertNoCachedLastCallGas() public { - vm._expectCheatcodeRevert(); - vm.lastCallGas(); + VM._expectCheatcodeRevert(); + VM.lastCallGas(); } function _setup() internal { @@ -71,19 +71,19 @@ contract LastCallGasIsolatedTest is LastCallGasFixture { function testRecordLastCallGas() public { _setup(); _performCall(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 21064, gasMemoryUsed: 0, gasRefunded: 0})); + _assertGas(VM.lastCallGas(), Gas({gasTotalUsed: 21064, gasMemoryUsed: 0, gasRefunded: 0})); _performCall(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 21064, gasMemoryUsed: 0, gasRefunded: 0})); + _assertGas(VM.lastCallGas(), Gas({gasTotalUsed: 21064, gasMemoryUsed: 0, gasRefunded: 0})); _performCall(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 21064, gasMemoryUsed: 0, gasRefunded: 0})); + _assertGas(VM.lastCallGas(), Gas({gasTotalUsed: 21064, gasMemoryUsed: 0, gasRefunded: 0})); } function testRecordGasRefund() public { _setup(); _performRefund(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 21380, gasMemoryUsed: 0, gasRefunded: 4800})); + _assertGas(VM.lastCallGas(), Gas({gasTotalUsed: 21380, gasMemoryUsed: 0, gasRefunded: 4800})); } } @@ -92,18 +92,18 @@ contract LastCallGasDefaultTest is LastCallGasFixture { function testRecordLastCallGas() public { _setup(); _performCall(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 0, gasRefunded: 0})); + _assertGas(VM.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 0, gasRefunded: 0})); _performCall(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 0, gasRefunded: 0})); + _assertGas(VM.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 0, gasRefunded: 0})); _performCall(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 0, gasRefunded: 0})); + _assertGas(VM.lastCallGas(), Gas({gasTotalUsed: 64, gasMemoryUsed: 0, gasRefunded: 0})); } function testRecordGasRefund() public { _setup(); _performRefund(); - _assertGas(vm.lastCallGas(), Gas({gasTotalUsed: 216, gasMemoryUsed: 0, gasRefunded: 19900})); + _assertGas(VM.lastCallGas(), Gas({gasTotalUsed: 216, gasMemoryUsed: 0, gasRefunded: 19900})); } } diff --git a/testdata/paris/fork/Transact.t.sol b/testdata/paris/fork/Transact.t.sol index 92d595f98c516..7880b92b97ea0 100644 --- a/testdata/paris/fork/Transact.t.sol +++ b/testdata/paris/fork/Transact.t.sol @@ -12,7 +12,7 @@ interface IERC20 { } contract TransactOnForkTest is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); IERC20 constant USDT = IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7); @@ -20,8 +20,8 @@ contract TransactOnForkTest is DSTest { function testTransact() public { // A random block https://etherscan.io/block/17134913 - uint256 fork = vm.createFork("mainnet", 17134913); - vm.selectFork(fork); + uint256 fork = VM.createFork("mainnet", 17134913); + VM.selectFork(fork); // a random transfer transaction in the next block: https://etherscan.io/tx/0xaf6201d435b216a858c580e20512a16136916d894aa33260650e164e3238c771 bytes32 tx = 0xaf6201d435b216a858c580e20512a16136916d894aa33260650e164e3238c771; @@ -37,7 +37,7 @@ contract TransactOnForkTest is DSTest { uint256 expectedSenderBalance = sender.balance - transferAmount; // execute the transaction - vm.transact(tx); + VM.transact(tx); // recipient received transfer assertEq(recipient.balance, expectedRecipientBalance); @@ -48,8 +48,8 @@ contract TransactOnForkTest is DSTest { function testTransactCooperatesWithCheatcodes() public { // A random block https://etherscan.io/block/16260609 - uint256 fork = vm.createFork("mainnet", 16260609); - vm.selectFork(fork); + uint256 fork = VM.createFork("mainnet", 16260609); + VM.selectFork(fork); // a random ERC20 USDT transfer transaction in the next block: https://etherscan.io/tx/0x33350512fec589e635865cbdb38fa3a20a2aa160c52611f1783d0ba24ad13c8c bytes32 tx = 0x33350512fec589e635865cbdb38fa3a20a2aa160c52611f1783d0ba24ad13c8c; @@ -76,17 +76,17 @@ contract TransactOnForkTest is DSTest { // vm.expectCall(address(USDT), abi.encodeWithSelector(IERC20.transfer.selector, recipient, transferAmount)); // expect a Transfer event to be emitted - vm.expectEmit(true, true, false, true, address(USDT)); + VM.expectEmit(true, true, false, true, address(USDT)); emit Transfer(address(sender), address(recipient), transferAmount); // start recording logs - vm.recordLogs(); + VM.recordLogs(); // execute the transaction - vm.transact(tx); + VM.transact(tx); // extract recorded logs - Vm.Log[] memory logs = vm.getRecordedLogs(); + Vm.Log[] memory logs = VM.getRecordedLogs(); senderBalance = USDT.balanceOf(sender); recipientBalance = USDT.balanceOf(recipient); diff --git a/testdata/paris/spec/ShanghaiCompat.t.sol b/testdata/paris/spec/ShanghaiCompat.t.sol index fd7213b3d0702..75d1041a798b8 100644 --- a/testdata/paris/spec/ShanghaiCompat.t.sol +++ b/testdata/paris/spec/ShanghaiCompat.t.sol @@ -5,7 +5,7 @@ import "ds-test/test.sol"; import "cheats/Vm.sol"; contract ShanghaiCompat is DSTest { - Vm constant vm = Vm(HEVM_ADDRESS); + Vm constant VM = Vm(HEVM_ADDRESS); function testPush0() public { address target = address(uint160(uint256(0xc4f3))); @@ -20,7 +20,7 @@ contract ShanghaiCompat is DSTest { // 5F PUSH0 // F3 RETURN -> returns mem[0..calldatasize] - vm.etch(target, bytecode); + VM.etch(target, bytecode); (bool success, bytes memory result) = target.call(bytes("hello PUSH0")); assertTrue(success);