Search in sources :

Example 1 with LedgerProof

use of com.radixdlt.consensus.LedgerProof in project radixdlt by radixdlt.

the class RadixEngineStateComputerTest method committing_epoch_change_with_additional_cmds_should_fail.

// TODO: should catch this and log it somewhere as proof of byzantine quorum
@Test
public void committing_epoch_change_with_additional_cmds_should_fail() throws Exception {
    // Arrange
    var keyPair = ECKeyPair.generateNew();
    var cmd0 = systemUpdateCommand(0, 2);
    var cmd1 = registerCommand(keyPair);
    var ledgerProof = new LedgerProof(HashUtils.random256(), LedgerHeader.create(0, View.of(9), new AccumulatorState(3, HashUtils.zero256()), 0), new TimestampedECDSASignatures());
    var commandsAndProof = VerifiedTxnsAndProof.create(ImmutableList.of(cmd0, cmd1), ledgerProof);
    // Act
    // Assert
    assertThatThrownBy(() -> sut.commit(commandsAndProof, null)).isInstanceOf(ByzantineQuorumException.class);
}
Also used : TimestampedECDSASignatures(com.radixdlt.consensus.TimestampedECDSASignatures) AccumulatorState(com.radixdlt.ledger.AccumulatorState) LedgerProof(com.radixdlt.consensus.LedgerProof) Test(org.junit.Test)

Example 2 with LedgerProof

use of com.radixdlt.consensus.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);
}
Also used : TimestampedECDSASignatures(com.radixdlt.consensus.TimestampedECDSASignatures) AccumulatorState(com.radixdlt.ledger.AccumulatorState) LedgerProof(com.radixdlt.consensus.LedgerProof) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with LedgerProof

use of com.radixdlt.consensus.LedgerProof in project radixdlt by radixdlt.

the class RadixEngineStateComputerTest method committing_epoch_change_when_there_shouldnt_be_one__should_fail.

// TODO: should catch this and log it somewhere as proof of byzantine quorum
@Test
public void committing_epoch_change_when_there_shouldnt_be_one__should_fail() throws TxBuilderException {
    // Arrange
    var cmd0 = systemUpdateCommand(1, 1);
    var ledgerProof = new LedgerProof(HashUtils.random256(), LedgerHeader.create(0, View.of(9), new AccumulatorState(3, HashUtils.zero256()), 0, BFTValidatorSet.from(Stream.of(BFTValidator.from(BFTNode.random(), UInt256.ONE)))), new TimestampedECDSASignatures());
    var commandsAndProof = VerifiedTxnsAndProof.create(ImmutableList.of(cmd0), ledgerProof);
    // Act
    // Assert
    assertThatThrownBy(() -> sut.commit(commandsAndProof, null)).isInstanceOf(ByzantineQuorumException.class);
}
Also used : TimestampedECDSASignatures(com.radixdlt.consensus.TimestampedECDSASignatures) AccumulatorState(com.radixdlt.ledger.AccumulatorState) LedgerProof(com.radixdlt.consensus.LedgerProof) Test(org.junit.Test)

Example 4 with LedgerProof

use of com.radixdlt.consensus.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);
}
Also used : LedgerProof(com.radixdlt.consensus.LedgerProof) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) Test(org.junit.Test)

Example 5 with LedgerProof

use of com.radixdlt.consensus.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());
}
Also used : LedgerProof(com.radixdlt.consensus.LedgerProof) DtoLedgerProof(com.radixdlt.ledger.DtoLedgerProof) Test(org.junit.Test)

Aggregations

LedgerProof (com.radixdlt.consensus.LedgerProof)26 Test (org.junit.Test)17 DtoLedgerProof (com.radixdlt.ledger.DtoLedgerProof)13 BFTNode (com.radixdlt.consensus.bft.BFTNode)9 TimestampedECDSASignatures (com.radixdlt.consensus.TimestampedECDSASignatures)7 AccumulatorState (com.radixdlt.ledger.AccumulatorState)7 LedgerHeader (com.radixdlt.consensus.LedgerHeader)4 AbstractModule (com.google.inject.AbstractModule)3 TypeLiteral (com.google.inject.TypeLiteral)3 Txn (com.radixdlt.atom.Txn)3 BFTConfiguration (com.radixdlt.consensus.BFTConfiguration)3 HighQC (com.radixdlt.consensus.HighQC)3 Self (com.radixdlt.consensus.bft.Self)3 ImmutableClassToInstanceMap (com.google.common.collect.ImmutableClassToInstanceMap)2 Inject (com.google.inject.Inject)2 HashSigner (com.radixdlt.consensus.HashSigner)2 Proposal (com.radixdlt.consensus.Proposal)2 QuorumCertificate (com.radixdlt.consensus.QuorumCertificate)2 UnverifiedVertex (com.radixdlt.consensus.UnverifiedVertex)2 Vote (com.radixdlt.consensus.Vote)2