Skip to content

Commit

Permalink
chore(protocol): test isSignalSent and SS_SIGNAL_NOT_RECEIVED error i…
Browse files Browse the repository at this point in the history
…n SignalService (#18763)
  • Loading branch information
xiaodino authored Jan 14, 2025
1 parent 5fd6e0c commit 857842f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/protocol/test/shared/signal/SignalService.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ contract TestSignalService is CommonTest {
vm.prank(deployer);
resolver.registerAddress(ethereumChainId, "signal_service", randAddress());

vm.expectRevert(SignalService.SS_SIGNAL_NOT_RECEIVED.selector);
mockSignalService.proveSignalReceived({
_chainId: ethereumChainId,
_app: randAddress(),
_signal: randBytes32(),
_proof: hex""
});

// proofs.length must > 0 in order not to revert
SignalService.HopProof[] memory proofs = new SignalService.HopProof[](0);

Expand Down Expand Up @@ -578,7 +586,7 @@ contract TestSignalService is CommonTest {
);
}

function test_SignalService_getSyncedChainData() public {
function test_SignalService_getSyncedChainData_isSignalSent() public {
vm.chainId(167_001);

bytes32 kind = LibStrings.H_STATE_ROOT;
Expand All @@ -598,6 +606,12 @@ contract TestSignalService is CommonTest {
assertEq(returnedBlockId, blockId);
assertEq(returnedChainData, expectedChainData);

bytes32 signal = signalService.signalForChainData(chainId, kind, blockId);
bool isSignalSent = signalService.isSignalSent(address(signalService), signal);
assertEq(isSignalSent, true);
isSignalSent = signalService.isSignalSent(signal);
assertEq(isSignalSent, false);

// Test for topBlockId is returned when blockId is 0
uint64 unsetBlockId = 0;
expectedChainData = randBytes32();
Expand All @@ -614,6 +628,10 @@ contract TestSignalService is CommonTest {
uint64 invalidBlockId = blockId + 100; // BlockId that was not synced
vm.expectRevert(SignalService.SS_SIGNAL_NOT_FOUND.selector);
signalService.getSyncedChainData(chainId, kind, invalidBlockId);

signal = signalService.signalForChainData(chainId, kind, invalidBlockId);
isSignalSent = signalService.isSignalSent(address(signalService), signal);
assertEq(isSignalSent, false);
}

function test_SignalService_signalForChainData() public view {
Expand Down

0 comments on commit 857842f

Please sign in to comment.