docs: improve wording in comments
cI: reorder values in "on" docs: add a reference to `bound`
This commit is contained in:
parent
bf567974af
commit
c1bc6d1adb
|
@ -8,9 +8,9 @@ env:
|
||||||
MNEMONIC: ${{ secrets.MNEMONIC }}
|
MNEMONIC: ${{ secrets.MNEMONIC }}
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
pull_request:
|
pull_request:
|
||||||
push:
|
push:
|
||||||
workflow_dispatch:
|
|
||||||
branches:
|
branches:
|
||||||
- "main"
|
- "main"
|
||||||
|
|
||||||
|
|
|
@ -9,36 +9,38 @@ interface IERC20 {
|
||||||
function balanceOf(address account) external view returns (uint256);
|
function balanceOf(address account) external view returns (uint256);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev See the "Writing Tests" section in the Foundry Book if this is your first time with Forge.
|
/// @dev If this is your first time with Forge, see the "Writing Tests" tutorial in the Foundry Book.
|
||||||
/// https://book.getfoundry.sh/forge/writing-tests
|
/// https://book.getfoundry.sh/forge/writing-tests
|
||||||
contract FooTest is PRBTest, StdCheats {
|
contract FooTest is PRBTest, StdCheats {
|
||||||
/// @dev An optional function invoked before each test case is run
|
/// @dev An optional function invoked before each test case is run.
|
||||||
function setUp() public virtual {
|
function setUp() public virtual {
|
||||||
// solhint-disable-previous-line no-empty-blocks
|
// solhint-disable-previous-line no-empty-blocks
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Simple test. Run Forge with `-vvvv` to see console logs.
|
/// @dev Basic test. Run it with `-vvv` to see the console log.
|
||||||
function test_Example() external {
|
function test_Example() external {
|
||||||
console2.log("Hello World");
|
console2.log("Hello World");
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Test that fuzzes an unsigned integer.
|
/// @dev Fuzz test that provides random values for an unsigned integer, but it rejects zero as an input.
|
||||||
|
/// If you need more sophisticated input validation, use the `bound` utility instead.
|
||||||
|
/// See https://twitter.com/PaulRBerg/status/1622558791685242880
|
||||||
function testFuzz_Example(uint256 x) external {
|
function testFuzz_Example(uint256 x) external {
|
||||||
vm.assume(x != 0);
|
vm.assume(x != 0); // or x = bound(x, 1, 100)
|
||||||
assertGt(x, 0);
|
assertGt(x, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Test that runs against a fork of Ethereum Mainnet. You need to set `API_KEY_ALCHEMY` in your environment
|
/// @dev Fork test that runs against an Ethereum Mainnet fork. For this to work, you need to set `API_KEY_ALCHEMY`
|
||||||
/// for this test to run - you can get an API key for free at https://alchemy.com.
|
/// in your environment You can get an API key for free at https://alchemy.com.
|
||||||
function testFork_Example() external {
|
function testFork_Example() external {
|
||||||
|
// Silently pass this test if there is no API key.
|
||||||
string memory alchemyApiKey = vm.envOr("API_KEY_ALCHEMY", string(""));
|
string memory alchemyApiKey = vm.envOr("API_KEY_ALCHEMY", string(""));
|
||||||
// Silently pass this test if the user didn't define the API key.
|
|
||||||
if (bytes(alchemyApiKey).length == 0) {
|
if (bytes(alchemyApiKey).length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the test normally, otherwise.
|
// Otherwise, run the test against the mainnet fork.
|
||||||
vm.createSelectFork({ urlOrAlias: "mainnet", blockNumber: 16_428_000 });
|
vm.createSelectFork({ urlOrAlias: "mainnet", blockNumber: 16_428_000 });
|
||||||
address usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
|
address usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
|
||||||
address holder = 0x7713974908Be4BEd47172370115e8b1219F4A5f0;
|
address holder = 0x7713974908Be4BEd47172370115e8b1219F4A5f0;
|
||||||
|
|
Loading…
Reference in New Issue