Search in sources :

Example 1 with SyncRequest

use of com.radixdlt.sync.messages.remote.SyncRequest in project radixdlt by radixdlt.

the class RemoteSyncServiceTest method when_remote_sync_request_and_unable__then_dont_do_anything.

@Test
public void when_remote_sync_request_and_unable__then_dont_do_anything() {
    SyncRequest request = mock(SyncRequest.class);
    DtoLedgerProof header = mock(DtoLedgerProof.class);
    when(header.getOpaque()).thenReturn(HashUtils.zero256());
    when(header.getLedgerHeader()).thenReturn(mock(LedgerHeader.class));
    when(header.getSignatures()).thenReturn(mock(TimestampedECDSASignatures.class));
    when(request.getHeader()).thenReturn(header);
    processor.syncRequestEventProcessor().process(BFTNode.random(), SyncRequest.create(header));
    verify(syncResponseDispatcher, never()).dispatch(any(BFTNode.class), any());
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) SyncRequest(com.radixdlt.sync.messages.remote.SyncRequest) Test(org.junit.Test)

Example 2 with SyncRequest

use of com.radixdlt.sync.messages.remote.SyncRequest in project radixdlt by radixdlt.

the class RemoteSyncServiceTest method when_remote_sync_request__then_process_it.

@Test
public void when_remote_sync_request__then_process_it() {
    SyncRequest request = mock(SyncRequest.class);
    DtoLedgerProof header = mock(DtoLedgerProof.class);
    when(header.getOpaque()).thenReturn(HashUtils.zero256());
    when(header.getLedgerHeader()).thenReturn(mock(LedgerHeader.class));
    when(header.getSignatures()).thenReturn(mock(TimestampedECDSASignatures.class));
    when(request.getHeader()).thenReturn(header);
    BFTNode node = mock(BFTNode.class);
    VerifiedTxnsAndProof verifiedTxnsAndProof = mock(VerifiedTxnsAndProof.class);
    LedgerProof verifiedHeader = mock(LedgerProof.class);
    when(verifiedHeader.toDto()).thenReturn(header);
    when(verifiedTxnsAndProof.getProof()).thenReturn(verifiedHeader);
    when(reader.getNextCommittedTxns(any())).thenReturn(verifiedTxnsAndProof);
    processor.syncRequestEventProcessor().process(node, SyncRequest.create(header));
    verify(syncResponseDispatcher, times(1)).dispatch(eq(node), any());
}
Also used : TimestampedECDSASignatures(com.radixdlt.hotstuff.TimestampedECDSASignatures) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) LedgerHeader(com.radixdlt.hotstuff.LedgerHeader) BFTNode(com.radixdlt.hotstuff.bft.BFTNode) SyncRequest(com.radixdlt.sync.messages.remote.SyncRequest) VerifiedTxnsAndProof(com.radixdlt.ledger.VerifiedTxnsAndProof) LedgerProof(com.radixdlt.hotstuff.LedgerProof) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) Test(org.junit.Test)

Aggregations

LedgerHeader (com.radixdlt.hotstuff.LedgerHeader)2 TimestampedECDSASignatures (com.radixdlt.hotstuff.TimestampedECDSASignatures)2 BFTNode (com.radixdlt.hotstuff.bft.BFTNode)2 DtoLedgerProof (com.radixdlt.ledger.DtoLedgerProof)2 SyncRequest (com.radixdlt.sync.messages.remote.SyncRequest)2 Test (org.junit.Test)2 LedgerProof (com.radixdlt.hotstuff.LedgerProof)1 VerifiedTxnsAndProof (com.radixdlt.ledger.VerifiedTxnsAndProof)1