Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overload _createSelectForkAndSetupAxiom to allow fork from latest #19

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/AxiomTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,35 @@ abstract contract AxiomTest is Test {
uint256 amount
);

/// @dev Create a forked test environment and set up Axiom contracts
/// @dev Create a forked test environment from the latest block and set up Axiom contracts
/// @param urlOrAlias The URL or alias of the fork to create
function _createSelectForkAndSetupAxiom(
string memory urlOrAlias
) internal {
vm.createSelectFork(urlOrAlias);
_setupAxiomFromFork(block.number);

axiomVm = new AxiomVm(axiomV2QueryAddress, urlOrAlias);
}

/// @dev Create a forked test environment from a specified block and set up Axiom contracts
/// @param urlOrAlias The URL or alias of the fork to create
/// @param forkBlock The block number to fork from
function _createSelectForkAndSetupAxiom(
string memory urlOrAlias,
uint256 forkBlock
) internal {
vm.createSelectFork(urlOrAlias, forkBlock);
_setupAxiomFromFork(forkBlock);

axiomVm = new AxiomVm(axiomV2QueryAddress, urlOrAlias);
}

/// @dev Set up Axiom contracts
/// @param forkBlock The block number that the fork was created from
function _setupAxiomFromFork(
uint256 forkBlock
) private {
uint64 chainId = uint64(block.chainid);

if (chainId == MAINNET_CHAIN_ID) {
Expand Down Expand Up @@ -113,8 +134,6 @@ abstract contract AxiomTest is Test {

vm.makePersistent(axiomV2CoreAddress);
vm.makePersistent(axiomV2QueryAddress);

axiomVm = new AxiomVm(axiomV2QueryAddress, urlOrAlias);
}

/// @dev Create a query into Axiom with default parameters
Expand Down
Loading