Skip to content

Commit

Permalink
Fix L1 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fmkra committed May 23, 2024
1 parent 3e6ea6a commit f692337
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
6 changes: 4 additions & 2 deletions l1/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ libs = ["lib"]
gas_reports = ["*"]
optimizer = true
optimizer_runs = 20000
solc = "0.8.21"
evm_version = "shanghai"

[rpc_endpoints]
goerli = "https://rpc.ankr.com/eth_goerli"
sepolia = "https://sepolia.drpc.org"

[etherscan]
goerli = { key = "${ETHERSCAN_API_KEY}" }
sepolia = { key = "${ETHERSCAN_API_KEY}" }

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
10 changes: 6 additions & 4 deletions l1/src/L1MessagesSender.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ contract L1MessagesSender is Ownable {
}

/// @param aggregatorId The id of a tree previously created by the aggregators factory
function sendPoseidonMMRTreeToL2(uint256 aggregatorId) external payable {
function sendPoseidonMMRTreeToL2(uint256 aggregatorId, uint256 mmrId) external payable {
address existingAggregatorAddr = aggregatorsFactory.aggregatorsById(
aggregatorId
);
Expand All @@ -70,7 +70,7 @@ contract L1MessagesSender is Ownable {
require(mmrSize >= 1, "Invalid tree size");
require(poseidonMMRRoot != bytes32(0), "Invalid root (Poseidon)");

_sendPoseidonMMRTreeToL2(poseidonMMRRoot, mmrSize, aggregatorId);
_sendPoseidonMMRTreeToL2(poseidonMMRRoot, mmrSize, aggregatorId, mmrId);
}

function _sendBlockHashToL2(
Expand All @@ -97,13 +97,15 @@ contract L1MessagesSender is Ownable {
function _sendPoseidonMMRTreeToL2(
bytes32 poseidonMMRRoot,
uint256 mmrSize,
uint256 aggregatorId
uint256 aggregatorId,
uint256 mmrId
) internal {
uint256[] memory message = new uint256[](3);
uint256[] memory message = new uint256[](4);

message[0] = uint256(poseidonMMRRoot);
message[1] = mmrSize;
message[2] = aggregatorId;
message[3] = mmrId;

// Pass along msg.value
starknetCore.sendMessageToL2{value: msg.value}(
Expand Down
12 changes: 7 additions & 5 deletions l1/test/L1MessagesSender.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ contract L1MessagesSenderTest is Test {
L1MessagesSender public sender;

function setUp() public {
vm.createSelectFork(vm.rpcUrl("goerli"));
vm.createSelectFork(vm.rpcUrl("sepolia"));

sender = new L1MessagesSender(
IStarknetCore(0xde29d060D45901Fb19ED6C6e959EB22d8626708e),
0x07bf6b32382276bFF5341f810A6811233A9591228642F60160129629448a21b6,
0xB8Cb7707b5160eaE8931e0cf02B563a5CeA75F09
IStarknetCore(0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057),
0x002e94a2344485429762F272c4Cf80F7378b30e1E9A34d662e0ba282135CC916,
0x70C61dd17b7207B450Cb7DeDC92C1707A07a1213
);
}

Expand All @@ -35,7 +35,9 @@ contract L1MessagesSenderTest is Test {
// This aggregator id must exist in the factory
uint256 aggregatorId = 1;

uint256 mmrId = 4;

// Value must be greater than 0
sender.sendPoseidonMMRTreeToL2{value: 1}(aggregatorId);
sender.sendPoseidonMMRTreeToL2{value: 1}(aggregatorId, mmrId);
}
}

0 comments on commit f692337

Please sign in to comment.