use of com.radixdlt.hotstuff.LedgerProof in project radixdlt by radixdlt.
the class RadixEngineStateComputerTest method committing_epoch_high_views_should_fail.
// TODO: should catch this and log it somewhere as proof of byzantine quorum
@Test
// state not easily obtained where checked in the RadixEngine
@Ignore("FIXME: Reinstate when upper bound on epoch view is in place.")
public void committing_epoch_high_views_should_fail() throws TxBuilderException {
// Arrange
var cmd0 = systemUpdateCommand(10, 1);
var ledgerProof = new LedgerProof(HashUtils.random256(), LedgerHeader.create(0, View.of(11), new AccumulatorState(3, HashUtils.zero256()), 0), new TimestampedECDSASignatures());
var commandsAndProof = VerifiedTxnsAndProof.create(ImmutableList.of(cmd0), ledgerProof);
// Act
// Assert
assertThatThrownBy(() -> sut.commit(commandsAndProof, null)).isInstanceOf(ByzantineQuorumException.class);
}
use of com.radixdlt.hotstuff.LedgerProof in project radixdlt by radixdlt.
the class BerkeleyLedgerEntryStoreTest method storeMetadataWithForks.
private void storeMetadataWithForks(long epoch, ImmutableSet<ForkVotingResult> forkVotingResults) throws RadixEngineException {
final var fakeTx = mock(REProcessedTxn.class);
final var txn = mock(Txn.class);
when(txn.getId()).thenReturn(AID.from(HashUtils.random256().asBytes()));
when(fakeTx.getTxn()).thenReturn(txn);
when(fakeTx.getGroupedStateUpdates()).thenReturn(List.of());
when(txn.getPayload()).thenReturn(HashUtils.random256().asBytes());
final var proof1 = LedgerAndBFTProof.create(new LedgerProof(HashUtils.random256(), LedgerHeader.create(epoch, View.of(0L), new AccumulatorState(epoch, /* using same state version as epoch */
HashCode.fromInt(1)), 0L), new TimestampedECDSASignatures(Map.of()))).withForksVotingResults(forkVotingResults);
sut.transaction(tx -> {
tx.storeTxn(fakeTx);
tx.storeMetadata(proof1);
return null;
});
}
use of com.radixdlt.hotstuff.LedgerProof in project radixdlt by radixdlt.
the class LocalSyncServiceTest method when_sync_check_is_triggered_at_non_idle__then_should_be_ignored.
@Test
public void when_sync_check_is_triggered_at_non_idle__then_should_be_ignored() {
final LedgerProof currentHeader = mock(LedgerProof.class);
this.setupSyncServiceWithState(SyncState.SyncCheckState.init(currentHeader, ImmutableSet.of()));
this.localSyncService.syncCheckTriggerEventProcessor().process(SyncCheckTrigger.create());
this.setupSyncServiceWithState(SyncState.SyncingState.init(currentHeader, ImmutableList.of(), currentHeader));
this.localSyncService.syncCheckTriggerEventProcessor().process(SyncCheckTrigger.create());
verifyNoMoreInteractions(peersView);
verifyNoMoreInteractions(statusRequestDispatcher);
}
use of com.radixdlt.hotstuff.LedgerProof in project radixdlt by radixdlt.
the class LocalSyncServiceTest method when_status_timeout_with_at_least_one_response__then_should_start_sync.
@Test
public void when_status_timeout_with_at_least_one_response__then_should_start_sync() {
final LedgerProof currentHeader = createHeaderAtStateVersion(10L);
final LedgerProof statusHeader1 = createHeaderAtStateVersion(12L);
final LedgerProof statusHeader2 = createHeaderAtStateVersion(20L);
final var waiting1 = createPeer();
final var waiting2 = createPeer();
setupPeersView(waiting1, waiting2);
final var syncState = SyncState.SyncCheckState.init(currentHeader, ImmutableSet.of(waiting1, waiting2));
this.setupSyncServiceWithState(syncState);
this.localSyncService.statusResponseEventProcessor().process(waiting1, StatusResponse.create(statusHeader1));
this.localSyncService.syncCheckReceiveStatusTimeoutEventProcessor().process(SyncCheckReceiveStatusTimeout.create());
// even though statusHeader2 is more up to date, it should be ignored because was received
// after a timeout event
this.localSyncService.statusResponseEventProcessor().process(waiting2, StatusResponse.create(statusHeader2));
verify(syncRequestDispatcher, times(1)).dispatch(eq(waiting1), any());
}
use of com.radixdlt.hotstuff.LedgerProof in project radixdlt by radixdlt.
the class LocalSyncServiceTest method when_status_response_received_at_non_sync_check__then_should_be_ignored.
@Test
public void when_status_response_received_at_non_sync_check__then_should_be_ignored() {
final LedgerProof currentHeader = mock(LedgerProof.class);
final LedgerProof statusHeader = mock(LedgerProof.class);
final BFTNode sender = createPeer();
this.setupSyncServiceWithState(SyncState.IdleState.init(currentHeader));
this.localSyncService.statusResponseEventProcessor().process(sender, StatusResponse.create(statusHeader));
this.setupSyncServiceWithState(SyncState.SyncingState.init(currentHeader, ImmutableList.of(), currentHeader));
this.localSyncService.statusResponseEventProcessor().process(sender, StatusResponse.create(statusHeader));
verifyNoMoreInteractions(peersView);
verifyNoMoreInteractions(statusRequestDispatcher);
verifyNoMoreInteractions(syncRequestDispatcher);
verifyNoMoreInteractions(syncRequestTimeoutDispatcher);
}
Aggregations