Search in sources :

Example 1 with ConsensusRoundIdentifier

use of org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier in project besu by hyperledger.

the class RoundChangePayloadValidatorTest method roundChangeWithMatchingTargetAndPrepareFails.

@Test
public void roundChangeWithMatchingTargetAndPrepareFails() {
    final RoundChangePayload payload = new RoundChangePayload(new ConsensusRoundIdentifier(chainHeight, 1), Optional.of(new PreparedRoundMetadata(preparedBlockHash, 1)));
    final SignedData<RoundChangePayload> signedPayload = createSignedPayload(payload, validators.getNode(0).getNodeKey());
    assertThat(messageValidator.validate(signedPayload)).isFalse();
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) PreparedRoundMetadata(org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata) RoundChangePayload(org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload) Test(org.junit.Test)

Example 2 with ConsensusRoundIdentifier

use of org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier in project besu by hyperledger.

the class RoundChangePayloadValidatorTest method roundChangeForFutureHeightFails.

@Test
public void roundChangeForFutureHeightFails() {
    final RoundChangePayload payload = new RoundChangePayload(new ConsensusRoundIdentifier(chainHeight + 1, 1), Optional.of(new PreparedRoundMetadata(preparedBlockHash, 0)));
    final SignedData<RoundChangePayload> signedPayload = createSignedPayload(payload, validators.getNode(0).getNodeKey());
    assertThat(messageValidator.validate(signedPayload)).isFalse();
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) PreparedRoundMetadata(org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata) RoundChangePayload(org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload) Test(org.junit.Test)

Example 3 with ConsensusRoundIdentifier

use of org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier in project besu by hyperledger.

the class RoundChangePayloadValidatorTest method roundChangeWithZeroTargetRoundFails.

@Test
public void roundChangeWithZeroTargetRoundFails() {
    final RoundChangePayload payload = new RoundChangePayload(new ConsensusRoundIdentifier(chainHeight, 0), Optional.of(new PreparedRoundMetadata(preparedBlockHash, 0)));
    final SignedData<RoundChangePayload> signedPayload = createSignedPayload(payload, validators.getNode(0).getNodeKey());
    assertThat(messageValidator.validate(signedPayload)).isFalse();
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) PreparedRoundMetadata(org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata) RoundChangePayload(org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload) Test(org.junit.Test)

Example 4 with ConsensusRoundIdentifier

use of org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier in project besu by hyperledger.

the class RoundChangePayloadValidatorTest method roundChangeForPriorHeightFails.

@Test
public void roundChangeForPriorHeightFails() {
    final RoundChangePayload payload = new RoundChangePayload(new ConsensusRoundIdentifier(chainHeight - 1, 1), Optional.of(new PreparedRoundMetadata(preparedBlockHash, 0)));
    final SignedData<RoundChangePayload> signedPayload = createSignedPayload(payload, validators.getNode(0).getNodeKey());
    assertThat(messageValidator.validate(signedPayload)).isFalse();
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) PreparedRoundMetadata(org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata) RoundChangePayload(org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload) Test(org.junit.Test)

Example 5 with ConsensusRoundIdentifier

use of org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier in project besu by hyperledger.

the class RoundChangePayloadValidatorTest method roundChangePayloadSignedByNonValidatorFails.

@Test
public void roundChangePayloadSignedByNonValidatorFails() {
    final RoundChangePayload payload = new RoundChangePayload(new ConsensusRoundIdentifier(chainHeight, 1), Optional.of(new PreparedRoundMetadata(preparedBlockHash, 0)));
    final NodeKey nonValidatorKey = NodeKeyUtils.generate();
    final SignedData<RoundChangePayload> signedPayload = createSignedPayload(payload, nonValidatorKey);
    assertThat(messageValidator.validate(signedPayload)).isFalse();
}
Also used : ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) PreparedRoundMetadata(org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata) RoundChangePayload(org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload) NodeKey(org.hyperledger.besu.crypto.NodeKey) Test(org.junit.Test)

Aggregations

ConsensusRoundIdentifier (org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier)135 Test (org.junit.Test)57 Test (org.junit.jupiter.api.Test)46 Block (org.hyperledger.besu.ethereum.core.Block)36 SignedData (org.hyperledger.besu.consensus.common.bft.payload.SignedData)19 RoundChangeCertificate (org.hyperledger.besu.consensus.ibft.payload.RoundChangeCertificate)19 Proposal (org.hyperledger.besu.consensus.ibft.messagewrappers.Proposal)18 Address (org.hyperledger.besu.datatypes.Address)14 NodeKey (org.hyperledger.besu.crypto.NodeKey)13 RoundChange (org.hyperledger.besu.consensus.ibft.messagewrappers.RoundChange)11 PreparedRoundArtifacts (org.hyperledger.besu.consensus.ibft.statemachine.PreparedRoundArtifacts)11 RoundChangePayload (org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload)11 RoundExpiry (org.hyperledger.besu.consensus.common.bft.events.RoundExpiry)10 Prepare (org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare)10 PreparedRoundMetadata (org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata)10 ValidatorPeer (org.hyperledger.besu.consensus.qbft.support.ValidatorPeer)10 Prepare (org.hyperledger.besu.consensus.ibft.messagewrappers.Prepare)9 Proposal (org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal)9 RoundChange (org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange)9 PreparedCertificate (org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate)8