Skip to content

Commit

Permalink
test: add basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroEkkusu committed Nov 3, 2023
1 parent 2679d55 commit a9f2dec
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions test/Counter.t.sol
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

import {Test, console2} from "forge-std/Test.sol";
import {Counter} from "../src/Counter.sol";
import "forge-std/Test.sol";

contract CounterTest is Test {
Counter public counter;
import "script/1.0.0/Deploy.s.sol";

contract CounterTest is Test, Deploy {
function setUp() public {
counter = new Counter(1);
counter.setNumber(0);
run();
}

function test_Increment() public {
function test_IsInitialized() public {
assertEq(counter.number(), 3);
}

function test_RevertsIf_AlreadyInitialized() public {
vm.expectRevert(Initializable.InvalidInitialization.selector);
counter.initialize(1);
}

function test_IncrementsNumber() public {
counter.increment();
assertEq(counter.number(), 1);
assertEq(counter.number(), 4);
}

function testFuzz_SetNumber(uint256 x) public {
function testFuzz_SetsNumber(uint256 x) public {
counter.setNumber(x);
assertEq(counter.number(), x);
}
Expand Down

0 comments on commit a9f2dec

Please sign in to comment.