Search in sources :

Example 1 with RadixEngine

use of com.radixdlt.engine.RadixEngine 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 RadixEngine

use of com.radixdlt.engine.RadixEngine 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 3 with RadixEngine

use of com.radixdlt.engine.RadixEngine 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)3 RadixEngine (com.radixdlt.engine.RadixEngine)3 Test (org.junit.Test)3 TxAction (com.radixdlt.atom.TxAction)1