Skip to content

Commit

Permalink
fix for subsequent messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hexonaut committed Jun 8, 2024
1 parent 9874e5c commit 46ee62c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/testing/bridges/AMBBridgeTesting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ library AMBBridgeTesting {
return bridge;
}

function relayMessagesToDestination(Bridge memory bridge, bool switchToDestinationFork) internal {
function relayMessagesToDestination(Bridge storage bridge, bool switchToDestinationFork) internal {
bridge.destination.selectFork();

Vm.Log[] memory logs = bridge.ingestAndFilterLogs(true, USER_REQUEST_FOR_AFFIRMATION_TOPIC, USER_REQUEST_FOR_SIGNATURE_TOPIC, bridge.sourceCrossChainMessenger);
Expand All @@ -82,7 +82,7 @@ library AMBBridgeTesting {
}
}

function relayMessagesToSource(Bridge memory bridge, bool switchToSourceFork) internal {
function relayMessagesToSource(Bridge storage bridge, bool switchToSourceFork) internal {
bridge.source.selectFork();

Vm.Log[] memory logs = bridge.ingestAndFilterLogs(false, USER_REQUEST_FOR_AFFIRMATION_TOPIC, USER_REQUEST_FOR_SIGNATURE_TOPIC, bridge.destinationCrossChainMessenger);
Expand Down
4 changes: 2 additions & 2 deletions src/testing/bridges/ArbitrumBridgeTesting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ library ArbitrumBridgeTesting {
return bridge;
}

function relayMessagesToDestination(Bridge memory bridge, bool switchToDestinationFork) internal {
function relayMessagesToDestination(Bridge storage bridge, bool switchToDestinationFork) internal {
bridge.destination.selectFork();

Vm.Log[] memory logs = RecordedLogs.getLogs();
Expand All @@ -149,7 +149,7 @@ library ArbitrumBridgeTesting {
}
}

function relayMessagesToSource(Bridge memory bridge, bool switchToSourceFork) internal {
function relayMessagesToSource(Bridge storage bridge, bool switchToSourceFork) internal {
bridge.source.selectFork();

Vm.Log[] memory logs = bridge.ingestAndFilterLogs(false, SEND_TO_L1_TOPIC, bridge.destinationCrossChainMessenger);
Expand Down
4 changes: 2 additions & 2 deletions src/testing/bridges/CCTPBridgeTesting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ library CCTPBridgeTesting {
return bridge;
}

function relayMessagesToDestination(Bridge memory bridge, bool switchToDestinationFork) internal {
function relayMessagesToDestination(Bridge storage bridge, bool switchToDestinationFork) internal {
bridge.destination.selectFork();

Vm.Log[] memory logs = bridge.ingestAndFilterLogs(true, SENT_MESSAGE_TOPIC, bridge.sourceCrossChainMessenger);
Expand All @@ -84,7 +84,7 @@ library CCTPBridgeTesting {
}
}

function relayMessagesToSource(Bridge memory bridge, bool switchToSourceFork) internal {
function relayMessagesToSource(Bridge storage bridge, bool switchToSourceFork) internal {
bridge.source.selectFork();

Vm.Log[] memory logs = bridge.ingestAndFilterLogs(false, SENT_MESSAGE_TOPIC, bridge.destinationCrossChainMessenger);
Expand Down
4 changes: 2 additions & 2 deletions src/testing/bridges/OptimismBridgeTesting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ library OptimismBridgeTesting {
return bridge;
}

function relayMessagesToDestination(Bridge memory bridge, bool switchToDestinationFork) internal {
function relayMessagesToDestination(Bridge storage bridge, bool switchToDestinationFork) internal {
bridge.destination.selectFork();

address malias;
Expand All @@ -100,7 +100,7 @@ library OptimismBridgeTesting {
}
}

function relayMessagesToSource(Bridge memory bridge, bool switchToSourceFork) internal {
function relayMessagesToSource(Bridge storage bridge, bool switchToSourceFork) internal {
bridge.source.selectFork();

Vm.Log[] memory logs = bridge.ingestAndFilterLogs(false, SENT_MESSAGE_TOPIC, bridge.destinationCrossChainMessenger);
Expand Down
4 changes: 2 additions & 2 deletions src/testing/utils/RecordedLogs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ library RecordedLogs {
return logs;
}

function ingestAndFilterLogs(Bridge memory bridge, bool sourceToDestination, bytes32 topic0, bytes32 topic1, address emitter) internal returns (Vm.Log[] memory filteredLogs) {
function ingestAndFilterLogs(Bridge storage bridge, bool sourceToDestination, bytes32 topic0, bytes32 topic1, address emitter) internal returns (Vm.Log[] memory filteredLogs) {
Vm.Log[] memory logs = RecordedLogs.getLogs();
uint256 lastIndex = sourceToDestination ? bridge.lastSourceLogIndex : bridge.lastDestinationLogIndex;
uint256 pushedIndex = 0;
Expand All @@ -53,7 +53,7 @@ library RecordedLogs {
assembly { mstore(filteredLogs, pushedIndex) }
}

function ingestAndFilterLogs(Bridge memory bridge, bool sourceToDestination, bytes32 topic, address emitter) internal returns (Vm.Log[] memory filteredLogs) {
function ingestAndFilterLogs(Bridge storage bridge, bool sourceToDestination, bytes32 topic, address emitter) internal returns (Vm.Log[] memory filteredLogs) {
return ingestAndFilterLogs(bridge, sourceToDestination, topic, bytes32(0), emitter);
}

Expand Down
10 changes: 10 additions & 0 deletions test/IntegrationBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ abstract contract IntegrationBaseTest is Test {
assertEq(moSource.length(), 2);
assertEq(moSource.messages(0), 3);
assertEq(moSource.messages(1), 4);

// One more message to destination
vm.startPrank(sourceAuthority);
queueSourceToDestination(abi.encodeCall(MessageOrdering.push, (5)));
vm.stopPrank();

relaySourceToDestination();

assertEq(moDestination.length(), 3);
assertEq(moDestination.messages(2), 5);
}

function initSourceReceiver() internal virtual returns (address);
Expand Down

0 comments on commit 46ee62c

Please sign in to comment.