// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
import "forge-std/Test.sol";
import "../src/SampleContract.sol";
import "forge-std/console.sol";
// vm deployer address: 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84
abstract contract StateZero is Test {
SampleContract internal sampleContract;
address alice;
address bob;
function setUp() public virtual {
sampleContract = new SampleContract();
alice = address(0x1);
bob = address(0x2);
vm.label(alice, "alice");
vm.label(bob, "bob");
}
}
contract StateZeroTest is StateZero {
function testChangeStateOne() public {}
function testChangStateOneReverts() public {
vm.expectRevert(bytes("revert message"));
// call function that is intended to revert here
}
function testChangStateOneEmitsEvent() public {
vm.expectEmit(true, true, true, true);
// 1. emit the event with expected values
// 2. call function that is intended to emit the event
}
}
abstract contract StateOne is StateZero {
function setUp() public virtual override {
// run initial set-up function from StateZero
super.setUp();
// function that changes state from zero to one
sampleContract.changeStateOne();
}
}
contract StateOneTest is StateOne {
function testChangeStateTwo() public {}
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.16;
import "forge-std/console2.sol";
import "openzeppelin-contracts/contracts/access/Ownable.sol";
import "openzeppelin-contracts/contracts/utils/Counters.sol";
contract SampleContract {
// initialising new counter variable
using Counters for Counters.Counter;
Counters.Counter public someId;
....
}