Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions src/testing/utils/RecordedLogs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,18 @@ library RecordedLogs {
}

function clearLogs() internal {
bool isActiveFork = false;
uint256 prevForkId;
try vm.activeFork() returns (uint256 forkId) {
prevForkId = forkId;
vm.selectFork(RecordedLogsStorage(STORAGE).forkId());
isActiveFork = true;
} catch {}

vm.getRecordedLogs();
RecordedLogsStorage(STORAGE).clearLogs();

if (isActiveFork) vm.selectFork(prevForkId);
}

function ingestAndFilterLogs(Bridge storage bridge, bool sourceToDestination, bytes32 topic0, bytes32 topic1, address emitter) internal returns (Vm.Log[] memory filteredLogs) {
Expand Down
15 changes: 15 additions & 0 deletions test/CircleCCTPIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ contract CircleCCTPIntegrationTest is IntegrationBaseTest {
destination = getChain("base").createFork();
destination2 = getChain("arbitrum_one").createFork();

DummyReceiver r0 = new DummyReceiver();
assertEq(r0.message().length, 0);
destination.selectFork();
DummyReceiver r1 = new DummyReceiver();
assertEq(r1.message().length, 0);
Expand All @@ -122,6 +124,19 @@ contract CircleCCTPIntegrationTest is IntegrationBaseTest {
assertEq(r1.message(), abi.encode(1));
destination2.selectFork();
assertEq(r2.message(), abi.encode(2));

destination.selectFork();
CCTPForwarder.sendMessage(CCTPForwarder.MESSAGE_TRANSMITTER_CIRCLE_BASE, CCTPForwarder.DOMAIN_ID_CIRCLE_ETHEREUM, address(r0), abi.encode(3));
destination2.selectFork();
CCTPForwarder.sendMessage(CCTPForwarder.MESSAGE_TRANSMITTER_CIRCLE_ARBITRUM_ONE, CCTPForwarder.DOMAIN_ID_CIRCLE_ETHEREUM, address(r0), abi.encode(4));
CCTPForwarder.sendMessage(CCTPForwarder.MESSAGE_TRANSMITTER_CIRCLE_ARBITRUM_ONE, CCTPForwarder.DOMAIN_ID_CIRCLE_ETHEREUM, address(r0), abi.encode(5));

bridge.relayMessagesToDestination(true);
bridge2.relayMessagesToDestination(true);
bridge2.relayMessagesToSource(true);
bridge.relayMessagesToSource(true);

assertEq(r0.message(), abi.encode(3));
}

function initSourceReceiver() internal override returns (address) {
Expand Down
21 changes: 21 additions & 0 deletions test/RecordedLogs.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,25 @@ contract RecordedLogsTest is Test {
assertEq(r1.data(), bytes("123"));
}

function test_clearLogs() public {
// Verify clear logs works even on different forks
source = getChain("mainnet").createFork();
source.selectFork();

string memory label = "clearLogs";
LogGenerator gen = new LogGenerator(label);
gen.makeLogs(1);

Vm.Log[] memory logs = RecordedLogs.getLogs();

assertEq(logs.length, 1);
assertEq(logs[0].data, abi.encode(label, 0));

RecordedLogs.clearLogs();

Vm.Log[] memory logs2 = RecordedLogs.getLogs();

assertEq(logs2.length, 0);
}

}
Loading