Skip to content

Commit

Permalink
Update "pass agent root" test
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Sep 7, 2023
1 parent cd24188 commit c40606f
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions packages/contracts-core/test/suite/Destination.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,33 @@ contract DestinationTest is ExecutionHubTest {
InterfaceDestination(localDestination()).acceptAttestation(agentIndex[notary], 0, "", 0, new ChainGas[](0));
}

function test_acceptAttestation_notAccepted_agentRootUpdated(
function test_acceptAttestation_passesAgentRoot(
RawAttestation memory firstRA,
RawAttestation memory secondRA,
uint32 firstRootSubmittedAt
) public {
bytes32 agentRootLM = lightManager.agentRoot();
vm.assume(firstRA._agentRoot != agentRootLM);
vm.assume(firstRA.snapRoot != secondRA.snapRoot);
test_submitAttestation(firstRA, firstRootSubmittedAt);
skip(AGENT_ROOT_OPTIMISTIC_PERIOD);
// Mock a call from lightInbox, could as well use the empty values as they won't be checked for validity
vm.prank(address(lightInbox));
assertFalse(InterfaceDestination(localDestination()).acceptAttestation(0, 0, "", 0, new ChainGas[](0)));
// Form a second attestation: Notary 1
RawSnapshot memory rs = Random(secondRA.snapRoot).nextSnapshot();
secondRA._snapGasHash = rs.snapGasHash();
secondRA.setDataHash();
uint256[] memory snapGas = rs.snapGas();
address notaryS = domains[DOMAIN_LOCAL].agents[1];
(bytes memory attPayload, bytes memory attSig) = signAttestation(notaryS, secondRA);
uint256 newRootTimestamp = block.timestamp;
assertTrue(lightInbox.submitAttestation(attPayload, attSig, secondRA._agentRoot, snapGas));
(uint40 snapRootTime, uint40 agentRootTime, uint32 index) =
InterfaceDestination(localDestination()).destStatus();
assertEq(snapRootTime, firstRootSubmittedAt);
assertEq(agentRootTime, firstRootSubmittedAt);
assertEq(index, agentIndex[domains[DOMAIN_LOCAL].agent]);
// Dest status should point to the new root
assertEq(snapRootTime, newRootTimestamp);
assertEq(agentRootTime, newRootTimestamp);
assertEq(index, agentIndex[notaryS]);
// New agent root should be pending in Destination
assertEq(InterfaceDestination(localDestination()).nextAgentRoot(), secondRA._agentRoot);
// Should update the Agent Merkle Root
assertEq(lightManager.agentRoot(), firstRA._agentRoot);
}
Expand Down

0 comments on commit c40606f

Please sign in to comment.