Search in sources :

Example 1 with ValidatorBFTDataEvent

use of com.radixdlt.constraintmachine.REEvent.ValidatorBFTDataEvent in project radixdlt by radixdlt.

the class InMemorySystemInfoTest method if_validator_data_missing_then_retrieved_via_radix_engine.

@Test
public void if_validator_data_missing_then_retrieved_via_radix_engine() {
    var self = BFTNode.random();
    var radixEngine = TypedMocks.cmock(new TypeLiteral<RadixEngine<LedgerAndBFTProof>>() {
    });
    var systemInfo = new InMemorySystemInfo(null, null, self, radixEngine);
    var validatorBFTData = Optional.of(new ValidatorBFTDataEvent(self.getKey(), 10, 1));
    when(radixEngine.read(any())).thenReturn(validatorBFTData);
    var result = systemInfo.getValidatorBFTData();
    var expected = Optional.of(new ValidatorBFTDataEvent(self.getKey(), 10, 1));
    assertEquals(expected, result);
}
Also used : RadixEngine(com.radixdlt.engine.RadixEngine) ValidatorBFTDataEvent(com.radixdlt.constraintmachine.REEvent.ValidatorBFTDataEvent) Test(org.junit.Test)

Example 2 with ValidatorBFTDataEvent

use of com.radixdlt.constraintmachine.REEvent.ValidatorBFTDataEvent in project radixdlt by radixdlt.

the class InMemorySystemInfoTest method createLedgerUpdate.

private LedgerUpdate createLedgerUpdate(BFTNode self) {
    var events = List.<REEvent>of(new ValidatorBFTDataEvent(self.getKey(), 10, 1));
    var txn = new REProcessedTxn(null, null, null, events);
    var output = ImmutableClassToInstanceMap.<Object, REOutput>of(REOutput.class, REOutput.create(List.of(txn)));
    return new LedgerUpdate(mock(VerifiedTxnsAndProof.class), output);
}
Also used : REOutput(com.radixdlt.statecomputer.REOutput) LedgerUpdate(com.radixdlt.ledger.LedgerUpdate) VerifiedTxnsAndProof(com.radixdlt.ledger.VerifiedTxnsAndProof) REEvent(com.radixdlt.constraintmachine.REEvent) ValidatorBFTDataEvent(com.radixdlt.constraintmachine.REEvent.ValidatorBFTDataEvent) REProcessedTxn(com.radixdlt.constraintmachine.REProcessedTxn)

Example 3 with ValidatorBFTDataEvent

use of com.radixdlt.constraintmachine.REEvent.ValidatorBFTDataEvent in project radixdlt by radixdlt.

the class InMemorySystemInfoTest method radix_engine_is_not_invoked_on_subsequent_request.

@Test
public void radix_engine_is_not_invoked_on_subsequent_request() {
    var self = BFTNode.random();
    var radixEngine = TypedMocks.cmock(new TypeLiteral<RadixEngine<LedgerAndBFTProof>>() {
    });
    var systemInfo = new InMemorySystemInfo(null, null, self, radixEngine);
    var validatorBFTData = Optional.of(new ValidatorBFTDataEvent(self.getKey(), 10, 1));
    System.out.println(new TxAction.CreateSystem(1L));
    when(radixEngine.read(any())).thenReturn(validatorBFTData);
    var result1 = systemInfo.getValidatorBFTData();
    var expected = Optional.of(new ValidatorBFTDataEvent(self.getKey(), 10, 1));
    assertEquals(expected, result1);
    var result2 = systemInfo.getValidatorBFTData();
    assertEquals(result1, result2);
    verify(radixEngine).read(any());
}
Also used : RadixEngine(com.radixdlt.engine.RadixEngine) ValidatorBFTDataEvent(com.radixdlt.constraintmachine.REEvent.ValidatorBFTDataEvent) TxAction(com.radixdlt.atom.TxAction) Test(org.junit.Test)

Example 4 with ValidatorBFTDataEvent

use of com.radixdlt.constraintmachine.REEvent.ValidatorBFTDataEvent in project radixdlt by radixdlt.

the class InMemorySystemInfoTest method if_validator_data_present_then_radix_engine_is_not_invoked.

@Test
public void if_validator_data_present_then_radix_engine_is_not_invoked() {
    var self = BFTNode.random();
    var radixEngine = TypedMocks.cmock(new TypeLiteral<RadixEngine<LedgerAndBFTProof>>() {
    });
    var systemInfo = new InMemorySystemInfo(null, null, self, radixEngine);
    systemInfo.ledgerUpdateEventProcessor().process(createLedgerUpdate(self));
    var result = systemInfo.getValidatorBFTData();
    var expected = Optional.of(new ValidatorBFTDataEvent(self.getKey(), 10, 1));
    assertEquals(expected, result);
    verifyNoInteractions(radixEngine);
}
Also used : RadixEngine(com.radixdlt.engine.RadixEngine) ValidatorBFTDataEvent(com.radixdlt.constraintmachine.REEvent.ValidatorBFTDataEvent) Test(org.junit.Test)

Aggregations

ValidatorBFTDataEvent (com.radixdlt.constraintmachine.REEvent.ValidatorBFTDataEvent)4 RadixEngine (com.radixdlt.engine.RadixEngine)3 Test (org.junit.Test)3 TxAction (com.radixdlt.atom.TxAction)1 REEvent (com.radixdlt.constraintmachine.REEvent)1 REProcessedTxn (com.radixdlt.constraintmachine.REProcessedTxn)1 LedgerUpdate (com.radixdlt.ledger.LedgerUpdate)1 VerifiedTxnsAndProof (com.radixdlt.ledger.VerifiedTxnsAndProof)1 REOutput (com.radixdlt.statecomputer.REOutput)1