use of com.radixdlt.hotstuff.BFTConfiguration in project radixdlt by radixdlt.
the class ConsensusModuleTest method setup.
@Before
public void setup() {
var accumulatorState = new AccumulatorState(0, HashUtils.zero256());
var genesis = UnverifiedVertex.createGenesis(LedgerHeader.genesis(accumulatorState, null, 0));
var hashedGenesis = new VerifiedVertex(genesis, HashUtils.zero256());
var qc = QuorumCertificate.ofGenesis(hashedGenesis, LedgerHeader.genesis(accumulatorState, null, 0));
this.validatorKeyPair = ECKeyPair.generateNew();
this.validatorBftNode = BFTNode.create(this.validatorKeyPair.getPublicKey());
var validatorSet = BFTValidatorSet.from(Stream.of(BFTValidator.from(this.validatorBftNode, UInt256.ONE)));
var vertexStoreState = VerifiedVertexStoreState.create(HighQC.from(qc), hashedGenesis, Optional.empty(), hasher);
var proposerElection = new WeightedRotatingLeaders(validatorSet);
this.bftConfiguration = new BFTConfiguration(proposerElection, validatorSet, vertexStoreState);
this.ecKeyPair = ECKeyPair.generateNew();
this.requestSender = rmock(RemoteEventDispatcher.class);
this.responseSender = rmock(RemoteEventDispatcher.class);
this.errorResponseSender = rmock(RemoteEventDispatcher.class);
Guice.createInjector(new ConsensusModule(), new CryptoModule(), getExternalModule()).injectMembers(this);
}
use of com.radixdlt.hotstuff.BFTConfiguration in project radixdlt by radixdlt.
the class BFTValidatorSetNodeSelector method nextNode.
@Override
public Single<BFTNode> nextNode(RunningNetwork network) {
BFTConfiguration config = network.bftConfiguration();
ImmutableList<BFTNode> validators = config.getValidatorSet().nodes().asList();
int validatorSetSize = validators.size();
BFTNode node = validators.get(random.nextInt(validatorSetSize));
return Single.just(node);
}
Aggregations