-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6309130
commit 204ad2b
Showing
4 changed files
with
67 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
"initialOwner": "0x48789ECd4317eCc8dBdB1d06EF39F01c5862a941" | ||
}, | ||
"Counter": { | ||
"number": 3 | ||
"number": 10 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.22; | ||
|
||
import "forge-std/Test.sol"; | ||
import "test/util/TestHelpers.sol"; | ||
|
||
import "script/1.0.0/Deploy.s.sol"; | ||
|
||
abstract contract BeforeScript is Test, TestHelpers, CounterDeployer { | ||
Counter internal counter; | ||
|
||
function setUp() public { | ||
(counter, , ) = deployCounter_NoInit(makeAddr("")); | ||
} | ||
} | ||
|
||
contract CounterTest_Zero is BeforeScript { | ||
function test_Initializes(uint256 number) public { | ||
counter.initialize(number); | ||
assertEq(counter.number(), number); | ||
} | ||
} | ||
|
||
abstract contract AfterScript is Test, TestHelpers, Deploy { | ||
function setUp() public virtual { | ||
run(); | ||
} | ||
} | ||
|
||
contract CounterTest_Initialized is AfterScript { | ||
function test_IsInitialized() public { | ||
assertEq(counter.number(), 10); | ||
} | ||
|
||
function test_RevertsIf_InitializedAgain() public { | ||
vm.expectRevert(Initializable.InvalidInitialization.selector); | ||
counter.initialize(1); | ||
} | ||
|
||
function test_IncrementsNumber() public { | ||
counter.increment(); | ||
assertEq(counter.number(), 11); | ||
} | ||
|
||
function testFuzz_SetsNumber(uint256 x) public { | ||
counter.setNumber(x); | ||
assertEq(counter.number(), x); | ||
} | ||
|
||
function test_ReturnsVersion() public { | ||
assertEq(counter.version(), "1.0.0"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.22; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
abstract contract TestHelpers is Test { | ||
Account internal DEPLOYER; | ||
|
||
constructor() { | ||
DEPLOYER = makeAccount("DEPLOYER"); | ||
vm.setEnv("PRIVATE_KEY", vm.toString(DEPLOYER.key)); | ||
} | ||
} |