Skip to content

Commit

Permalink
Merge pull request #215 from Consensys/fix/ccip-gateway-tests
Browse files Browse the repository at this point in the history
fix: TestL1 contract to match the new linea-state-verifier contracts
  • Loading branch information
Julink-eth authored Jul 25, 2024
2 parents 54336d0 + 373c507 commit b1b074e
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions packages/linea-ccip-gateway/contracts/TestL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {IEVMVerifier} from "linea-state-verifier/contracts/IEVMVerifier.sol";
contract TestL1 is EVMFetchTarget {
using EVMFetcher for EVMFetcher.EVMFetchRequest;

uint256 constant L2_BLOCK_RANGE_ACCEPTED = 86400;
uint256 constant ACCEPTED_L2_BLOCK_RANGE_LENGTH = 86400;

IEVMVerifier verifier; // Slot 0
address target;
Expand All @@ -18,10 +18,22 @@ contract TestL1 is EVMFetchTarget {
target = _target;
}

/**
* @dev inherits from EVMFetchTarget
*/
function getAcceptedL2BlockRangeLength()
public
pure
override
returns (uint256)
{
return ACCEPTED_L2_BLOCK_RANGE_LENGTH;
}

function getLatest() public view returns (uint256) {
EVMFetcher.newFetchRequest(verifier, target).getStatic(0).fetch(
this.getLatestCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
""
);
}

Expand All @@ -35,7 +47,7 @@ contract TestL1 is EVMFetchTarget {
function getName() public view returns (string memory) {
EVMFetcher.newFetchRequest(verifier, target).getDynamic(1).fetch(
this.getNameCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
""
);
}

Expand All @@ -51,10 +63,7 @@ contract TestL1 is EVMFetchTarget {
.newFetchRequest(verifier, target)
.getDynamic(3)
.element(idx)
.fetch(
this.getHighscorerCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
);
.fetch(this.getHighscorerCallback.selector, "");
}

function getHighscorerCallback(
Expand All @@ -70,10 +79,7 @@ contract TestL1 is EVMFetchTarget {
.getStatic(0)
.getStatic(2)
.ref(0)
.fetch(
this.getLatestHighscoreCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
);
.fetch(this.getLatestHighscoreCallback.selector, "");
}

function getLatestHighscoreCallback(
Expand All @@ -89,10 +95,7 @@ contract TestL1 is EVMFetchTarget {
.getStatic(0)
.getDynamic(3)
.ref(0)
.fetch(
this.getLatestHighscorerCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
);
.fetch(this.getLatestHighscorerCallback.selector, "");
}

function getLatestHighscorerCallback(
Expand All @@ -109,10 +112,7 @@ contract TestL1 is EVMFetchTarget {
.newFetchRequest(verifier, target)
.getDynamic(4)
.element(_name)
.fetch(
this.getNicknameCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
);
.fetch(this.getNicknameCallback.selector, "");
}

function getNicknameCallback(
Expand All @@ -128,10 +128,7 @@ contract TestL1 is EVMFetchTarget {
.getDynamic(1)
.getDynamic(4)
.ref(0)
.fetch(
this.getPrimaryNicknameCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
);
.fetch(this.getPrimaryNicknameCallback.selector, "");
}

function getPrimaryNicknameCallback(
Expand All @@ -144,7 +141,7 @@ contract TestL1 is EVMFetchTarget {
function getZero() public view returns (uint256) {
EVMFetcher.newFetchRequest(verifier, target).getStatic(5).fetch(
this.getZeroCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
""
);
}

Expand All @@ -161,10 +158,7 @@ contract TestL1 is EVMFetchTarget {
.getStatic(5)
.getStatic(2)
.ref(0)
.fetch(
this.getZeroIndexCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
);
.fetch(this.getZeroIndexCallback.selector, "");
}

function getZeroIndexCallback(
Expand Down

0 comments on commit b1b074e

Please sign in to comment.