-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6616: createSelectFork does not fork latest block number if you sleep (
#7087) * - if no block provided then fork is created using latest block for fork id (url@latest_block). if block provided then fork id is url@provided_block (this means there'll no longer be a url@latest fork id but always url@block) - after creation of fork the id is checked if in inserted forks. If it doesn't exist then it's inserted, otherwise the existing backend is reused and a new fork url@latest_block-1 recorded CreatedFork::inc_senders increments number of senders and returns the new unique fork id. CreatedFork::num_senders was removed MultiForkHandler::insert_new_fork added to handle fork insertion / send on channels * Dummy test * Add back comment, minor code style * Consume fork ids in insert_new_fork * add comment --------- Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
- Loading branch information
Showing
3 changed files
with
78 additions
and
50 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
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
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,22 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity 0.8.18; | ||
|
||
import "ds-test/test.sol"; | ||
import "../cheats/Vm.sol"; | ||
|
||
// https://github.com/foundry-rs/foundry/issues/6616 | ||
contract Issue6616Test is DSTest { | ||
Vm constant vm = Vm(HEVM_ADDRESS); | ||
|
||
function testCreateForkRollLatestBlock() public { | ||
vm.createSelectFork("rpcAlias"); | ||
uint256 startBlock = block.number; | ||
// this will create new forks and exit once a new latest block is found | ||
for (uint256 i; i < 10; i++) { | ||
vm.sleep(5000); | ||
vm.createSelectFork("rpcAlias"); | ||
if (block.number > startBlock) break; | ||
} | ||
assertGt(block.number, startBlock); | ||
} | ||
} |