Search in sources :

Example 6 with ConsensusElectAccept

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));
}
Also used : ConsensusElectAccept(com.github.dedis.popstellar.model.network.method.message.data.consensus.ConsensusElectAccept) MessageGeneral(com.github.dedis.popstellar.model.network.method.message.MessageGeneral) ConsensusLearn(com.github.dedis.popstellar.model.network.method.message.data.consensus.ConsensusLearn) ConsensusFailure(com.github.dedis.popstellar.model.network.method.message.data.consensus.ConsensusFailure) Test(org.junit.Test)

Aggregations

ConsensusElectAccept (com.github.dedis.popstellar.model.network.method.message.data.consensus.ConsensusElectAccept)6 MessageGeneral (com.github.dedis.popstellar.model.network.method.message.MessageGeneral)4 Test (org.junit.Test)4 MessageID (com.github.dedis.popstellar.model.objects.security.MessageID)3 ConsensusLearn (com.github.dedis.popstellar.model.network.method.message.data.consensus.ConsensusLearn)2 PublicKey (com.github.dedis.popstellar.model.objects.security.PublicKey)2 HiltAndroidTest (dagger.hilt.android.testing.HiltAndroidTest)2 DataInteraction (androidx.test.espresso.DataInteraction)1 ConsensusFailure (com.github.dedis.popstellar.model.network.method.message.data.consensus.ConsensusFailure)1 StateLao (com.github.dedis.popstellar.model.network.method.message.data.lao.StateLao)1 UpdateLao (com.github.dedis.popstellar.model.network.method.message.data.lao.UpdateLao)1 ConsensusNode (com.github.dedis.popstellar.model.objects.ConsensusNode)1 ElectInstance (com.github.dedis.popstellar.model.objects.ElectInstance)1 Lao (com.github.dedis.popstellar.model.objects.Lao)1 Base64DataUtils.generateMessageID (com.github.dedis.popstellar.testutils.Base64DataUtils.generateMessageID)1 Base64DataUtils.generatePublicKey (com.github.dedis.popstellar.testutils.Base64DataUtils.generatePublicKey)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 Disposable (io.reactivex.disposables.Disposable)1