Skip to content

Commit

Permalink
chore: unit tests for broken properties
Browse files Browse the repository at this point in the history
  • Loading branch information
nican0r committed Oct 21, 2024
1 parent 925073f commit 771bb3d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,13 @@ abstract contract Setup is BaseStorageVariables, PropertiesConstants {
event Log(string);

// This is a fix to allow facilitate dynamic replacement that searches for the `vm.roll` statements.
IHevm constant vm = IHevm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);

function _setUpFork() internal {
IHevm vm = IHevm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);

// Add timestamp and block for Recon dynamic replacement
vm.roll(20770509);
vm.warp(1726578263);
// vm.roll(20996709);
// vm.warp(1729305851);

// NOTE: Addresses from: https://gist.github.com/GalloDaSballo/75d77f8d0837821156fe061d0d8687e1
defaultGovernance = address(0xaDDeE229Bd103bb5B10C3CdB595A01c425dd3264);
Expand Down
50 changes: 47 additions & 3 deletions packages/contracts/foundry_test/ForkToFoundry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ contract ForkToFoundry is
BeforeAfterWithLogging
{
function setUp() public {
vm.createSelectFork("YOUR_RPC_URL", 20777211);
string memory MAINNET_RPC_URL = vm.envString("MAINNET_RPC_URL");
vm.createSelectFork(MAINNET_RPC_URL, 20996709); // NOTE: changed block to match coverage report
_setUpFork();
_setUpActors();
// _setUpActors();
_setUpActorsFork();
actor = actors[address(USER1)];

// If the accounting hasn't been synced since the last rebase
Expand Down Expand Up @@ -56,10 +58,52 @@ contract ForkToFoundry is

// forge test --match-test test_asserts_GENERAL_12_0 -vv
function test_asserts_GENERAL_12_0() public {

vm.roll(block.number + 4963);
vm.warp(block.timestamp + 50417);
asserts_GENERAL_12();
}

// forge test --match-test test_asserts_GENERAL_12_1 -vv
function test_asserts_GENERAL_12_1() public {
// NOTE: from reproducer test immediately breaks but when asserts_test_fail is commented it doesn't
// vm.roll(block.number + 60364);
// vm.warp(block.timestamp + 11077);
// asserts_active_pool_invariant_5();

// vm.roll(block.number + 1984);
// vm.warp(block.timestamp + 322370);
// asserts_test_fail();

// vm.roll(block.number + 33560);
// vm.warp(block.timestamp + 95);
// asserts_GENERAL_12();
// ========================

// NOTE: from shrunken logs breaks immediately
vm.roll(block.number + 1);
vm.warp(block.timestamp + 2973);
asserts_GENERAL_12();
}

// forge test --match-test test_asserts_GENERAL_13_2 -vv
// @audit this fails for all blocks/timestamps, including the initial block/timestamp setup was forked from
function test_asserts_GENERAL_13_2() public {
// from shrunken logs
// vm.roll(block.number + 1);
// vm.warp(block.timestamp + 2963);

// from reproducer
// vm.roll(block.number + 60471);
// vm.warp(block.timestamp + 6401);

// fails for the initial fork block and all others
console2.log("block.number == 20996709: ", block.number == 20996709);
console2.log("block.timestamp == 1729305851: ", block.timestamp == 1729305851);

asserts_GENERAL_13();
}

function test_asserts_GENERAL_14() public {
asserts_GENERAL_14();
}
}

0 comments on commit 771bb3d

Please sign in to comment.