use of com.github.dedis.popstellar.model.network.method.message.data.consensus.ConsensusElectAccept in project popstellar by dedis.
the class ConsensusHandlerTest method handleConsensusWithInvalidMessageIdTest.
@Test
public void handleConsensusWithInvalidMessageIdTest() {
// When an invalid instance id is used in handler for elect_accept and learn,
// it should throw an InvalidMessageIdException
ConsensusElectAccept electAcceptInvalid = new ConsensusElectAccept(INSTANCE_ID, INVALID_MSG_ID, true);
ConsensusLearn learnInvalid = new ConsensusLearn(INSTANCE_ID, INVALID_MSG_ID, CREATION_TIME, true, Collections.emptyList());
ConsensusFailure failureInvalid = new ConsensusFailure(INSTANCE_ID, INVALID_MSG_ID, CREATION_TIME);
MessageGeneral electAcceptInvalidMsg = getMsg(ORGANIZER_KEY, electAcceptInvalid);
MessageGeneral learnInvalidMsg = getMsg(ORGANIZER_KEY, learnInvalid);
MessageGeneral failureMsg = getMsg(ORGANIZER_KEY, failureInvalid);
assertThrows(InvalidMessageIdException.class, () -> messageHandler.handleMessage(laoRepository, messageSender, CONSENSUS_CHANNEL, electAcceptInvalidMsg));
assertThrows(InvalidMessageIdException.class, () -> messageHandler.handleMessage(laoRepository, messageSender, CONSENSUS_CHANNEL, learnInvalidMsg));
assertThrows(InvalidMessageIdException.class, () -> messageHandler.handleMessage(laoRepository, messageSender, CONSENSUS_CHANNEL, failureMsg));
}
Aggregations