Skip to content

Commit

Permalink
forge test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dusannosovic-ethernal committed Jan 23, 2025
1 parent d49bd25 commit d17b417
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
24 changes: 0 additions & 24 deletions contracts/blade/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -251,30 +251,6 @@ contract Gateway is ValidatorSetStorage, IGateway {
return desiredMessages;
}

// Function to calculate Merkle Root from an array of BridgeMessages
function calculateMerkleRoot(BridgeMessage[] memory messages) internal pure returns (bytes32) {
require(messages.length > 0, "No messages provided");

// Convert the BridgeMessages to their keccak256 hashes (this will be the actual leaves)
bytes32[] memory leaves = new bytes32[](messages.length);

for (uint256 i = 0; i < messages.length; i++) {
leaves[i] = keccak256(
abi.encode(
messages[i].id,
messages[i].sourceChainId,
messages[i].destinationChainId,
messages[i].sender,
messages[i].receiver,
messages[i].payload
)
);
}

// Pass the leaves to compute the Merkle root
return Merkle.computeMerkleRoot(leaves);
}

// slither-disable-next-line unused-state,naming-convention
uint256[50] private __gap;
}
5 changes: 1 addition & 4 deletions test/forge/blade/Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,7 @@ contract GatewayReceiveBatchTests is GatewayInitialized {
function testReceiveBatch_Success() public {
BridgeMessageBatch memory batch = BridgeMessageBatch({messages: msgs, sourceChainId: 2, destinationChainId: 3, threshold: 1000, isRollback: false});

vm.expectEmit();
emit BridgeMessageResult(1, false, 2, 3, bytes(""));
vm.expectEmit();
emit BridgeMessageResult(2, false, 2, 3, bytes(""));
vm.expectRevert("receiver has no code");
gateway.receiveBatch(batch, aggMessagePoints[3], bitmaps[3]);
}
}

0 comments on commit d17b417

Please sign in to comment.