Search in sources :

Example 1 with RoundChangeMessageValidator

use of org.hyperledger.besu.consensus.ibft.validation.RoundChangeMessageValidator in project besu by hyperledger.

the class RoundChangeManagerTest method setup.

@Before
public void setup() {
    validators.add(Util.publicKeyToAddress(proposerKey.getPublicKey()));
    validators.add(Util.publicKeyToAddress(validator1Key.getPublicKey()));
    validators.add(Util.publicKeyToAddress(validator2Key.getPublicKey()));
    final BlockValidator blockValidator = mock(BlockValidator.class);
    when(blockValidator.validateAndProcessBlock(any(), any(), any(), any())).thenReturn(new Result(new BlockProcessingOutputs(null, null)));
    final RoundChangePayloadValidator.MessageValidatorForHeightFactory messageValidatorFactory = mock(RoundChangePayloadValidator.MessageValidatorForHeightFactory.class);
    when(messageValidatorFactory.createAt(ri1)).thenAnswer(invocation -> new SignedDataValidator(validators, Util.publicKeyToAddress(proposerKey.getPublicKey()), ri1));
    when(messageValidatorFactory.createAt(ri2)).thenAnswer(invocation -> new SignedDataValidator(validators, Util.publicKeyToAddress(validator1Key.getPublicKey()), ri2));
    when(messageValidatorFactory.createAt(ri3)).thenAnswer(invocation -> new SignedDataValidator(validators, Util.publicKeyToAddress(validator2Key.getPublicKey()), ri3));
    final RoundChangeMessageValidator roundChangeMessageValidator = new RoundChangeMessageValidator(new RoundChangePayloadValidator(messageValidatorFactory, validators, BftHelpers.calculateRequiredValidatorQuorum(BftHelpers.calculateRequiredValidatorQuorum(validators.size())), 2), proposalConsistencyValidator, bftBlockInterface);
    manager = new RoundChangeManager(2, roundChangeMessageValidator);
    when(proposalConsistencyValidator.validateProposalMatchesBlock(any(), any(), any())).thenReturn(true);
}
Also used : BlockProcessingOutputs(org.hyperledger.besu.ethereum.BlockValidator.BlockProcessingOutputs) RoundChangePayloadValidator(org.hyperledger.besu.consensus.ibft.validation.RoundChangePayloadValidator) RoundChangeMessageValidator(org.hyperledger.besu.consensus.ibft.validation.RoundChangeMessageValidator) SignedDataValidator(org.hyperledger.besu.consensus.ibft.validation.SignedDataValidator) BlockValidator(org.hyperledger.besu.ethereum.BlockValidator) Result(org.hyperledger.besu.ethereum.BlockValidator.Result) Before(org.junit.Before)

Aggregations

RoundChangeMessageValidator (org.hyperledger.besu.consensus.ibft.validation.RoundChangeMessageValidator)1 RoundChangePayloadValidator (org.hyperledger.besu.consensus.ibft.validation.RoundChangePayloadValidator)1 SignedDataValidator (org.hyperledger.besu.consensus.ibft.validation.SignedDataValidator)1 BlockValidator (org.hyperledger.besu.ethereum.BlockValidator)1 BlockProcessingOutputs (org.hyperledger.besu.ethereum.BlockValidator.BlockProcessingOutputs)1 Result (org.hyperledger.besu.ethereum.BlockValidator.Result)1 Before (org.junit.Before)1