use of com.radixdlt.environment.rx.RemoteEvent in project radixdlt by radixdlt.
the class MessageCentralValidatorSync method responses.
public Flowable<RemoteEvent<GetVerticesResponse>> responses() {
return this.createFlowable(GetVerticesResponseMessage.class, (src, msg) -> {
BFTNode node = BFTNode.create(src.getPublicKey());
// TODO: Move hasher to a more appropriate place
ImmutableList<VerifiedVertex> hashedVertices = msg.getVertices().stream().map(v -> new VerifiedVertex(v, hasher.hash(v))).collect(ImmutableList.toImmutableList());
return RemoteEvent.create(node, new GetVerticesResponse(hashedVertices));
});
}
use of com.radixdlt.environment.rx.RemoteEvent in project radixdlt by radixdlt.
the class MessageCentralLedgerSyncTest method when_receive_sync_response__then_should_receive_it.
@Test
public void when_receive_sync_response__then_should_receive_it() {
TestSubscriber<RemoteEvent<SyncResponse>> testObserver = this.messageCentralLedgerSync.syncResponses().test();
final var peer = createPeer();
SyncResponseMessage syncResponseMessage = mock(SyncResponseMessage.class);
DtoTxnsAndProof commands = mock(DtoTxnsAndProof.class);
when(syncResponseMessage.getCommands()).thenReturn(commands);
messageCentral.send(peer, syncResponseMessage);
testObserver.awaitCount(1);
testObserver.assertValue(resp -> resp.getEvent().getTxnsAndProof().equals(commands));
}
use of com.radixdlt.environment.rx.RemoteEvent in project radixdlt by radixdlt.
the class MessageCentralLedgerSyncTest method when_receive_sync_request__then_should_receive_it.
@Test
public void when_receive_sync_request__then_should_receive_it() {
TestSubscriber<RemoteEvent<SyncRequest>> testObserver = this.messageCentralLedgerSync.syncRequests().test();
final var peer = createPeer();
SyncRequestMessage syncRequestMessage = mock(SyncRequestMessage.class);
DtoLedgerProof header = mock(DtoLedgerProof.class);
when(syncRequestMessage.getCurrentHeader()).thenReturn(header);
messageCentral.send(peer, syncRequestMessage);
testObserver.awaitCount(1);
testObserver.assertValue(syncRequest -> syncRequest.getEvent().getHeader().equals(header) && syncRequest.getOrigin().getKey().equals(peer.getPublicKey()));
}
use of com.radixdlt.environment.rx.RemoteEvent in project radixdlt by radixdlt.
the class SimulationNetworkTest method when_send_get_vertex_request_to_another_node__then_should_receive_it.
@Test
public void when_send_get_vertex_request_to_another_node__then_should_receive_it() {
HashCode vertexId = mock(HashCode.class);
TestObserver<RemoteEvent<GetVerticesRequest>> rpcRequestListener = network.getNetwork(node2).remoteEvents(GetVerticesRequest.class).toObservable().test();
network.getNetwork(node1).remoteEventDispatcher(GetVerticesRequest.class).dispatch(node2, new GetVerticesRequest(vertexId, 1));
rpcRequestListener.awaitCount(1);
rpcRequestListener.assertValueAt(0, r -> r.getEvent().getVertexId().equals(vertexId));
}
Aggregations