use of com.github.dedis.popstellar.model.network.method.message.data.consensus.ConsensusPrepare in project popstellar by dedis.
the class ConsensusHandlerTest method handleConsensusDoNothingOnBackendMessageTest.
@Test
public void handleConsensusDoNothingOnBackendMessageTest() throws DataHandlingException {
LAORepository mockLAORepository = mock(LAORepository.class);
Map<MessageID, MessageGeneral> messageById = new HashMap<>();
when(mockLAORepository.getMessageById()).thenReturn(messageById);
ConsensusPrepare prepare = new ConsensusPrepare(INSTANCE_ID, messageId, CREATION_TIME, 3);
ConsensusPromise promise = new ConsensusPromise(INSTANCE_ID, messageId, CREATION_TIME, 3, true, 2);
ConsensusPropose propose = new ConsensusPropose(INSTANCE_ID, messageId, CREATION_TIME, 3, true, Collections.emptyList());
ConsensusAccept accept = new ConsensusAccept(INSTANCE_ID, messageId, CREATION_TIME, 3, true);
messageHandler.handleMessage(mockLAORepository, messageSender, CONSENSUS_CHANNEL, getMsg(ORGANIZER_KEY, prepare));
messageHandler.handleMessage(mockLAORepository, messageSender, CONSENSUS_CHANNEL, getMsg(ORGANIZER_KEY, promise));
messageHandler.handleMessage(mockLAORepository, messageSender, CONSENSUS_CHANNEL, getMsg(ORGANIZER_KEY, propose));
messageHandler.handleMessage(mockLAORepository, messageSender, CONSENSUS_CHANNEL, getMsg(ORGANIZER_KEY, accept));
// The handlers for prepare/promise/propose/accept should do nothing (call or update nothing)
// because theses messages should only be handle in the backend server.
verify(mockLAORepository, never()).getLaoByChannel(any(Channel.class));
verify(mockLAORepository, never()).updateNodes(any(Channel.class));
}
Aggregations