use of com.radixdlt.consensus.HashSigner in project radixdlt by radixdlt.
the class SafetyRulesTest method when_vote_with_qc_on_different_locked_view__then_exception_is_thrown.
@Test
public void when_vote_with_qc_on_different_locked_view__then_exception_is_thrown() {
Hasher hasher = mock(Hasher.class);
when(hasher.hash(any())).thenReturn(mock(HashCode.class));
HashSigner hashSigner = mock(HashSigner.class);
when(hashSigner.sign(any(HashCode.class))).thenReturn(ECDSASignature.zeroSignature());
Vote lastVote = mock(Vote.class);
when(lastVote.getView()).thenReturn(View.of(1));
SafetyRules safetyRules = new SafetyRules(BFTNode.random(), new SafetyState(View.of(2), Optional.of(lastVote)), mock(PersistentSafetyStateStore.class), hasher, hashSigner);
VerifiedVertex vertex = mock(VerifiedVertex.class);
when(vertex.getView()).thenReturn(View.of(3));
BFTHeader parent = mock(BFTHeader.class);
when(parent.getView()).thenReturn(View.of(0));
when(vertex.getParentHeader()).thenReturn(parent);
assertThat(safetyRules.voteFor(vertex, mock(BFTHeader.class), 0L, mock(HighQC.class))).isEmpty();
}
use of com.radixdlt.consensus.HashSigner in project radixdlt by radixdlt.
the class SimulationNodes method createBFTInstance.
private Injector createBFTInstance(ECKeyPair self) {
Module module = Modules.combine(new AbstractModule() {
@Provides
@Self
private BFTNode self() {
return BFTNode.create(self.getPublicKey());
}
@Provides
@Self
private ECPublicKey key() {
return self.getPublicKey();
}
@Provides
@LocalSigner
HashSigner hashSigner() {
return self::sign;
}
}, new NodeNetworkMessagesModule(underlyingNetwork), baseModule);
// can break network behavior if incorrect modules are used
if (overrideModule != null) {
module = Modules.override(module).with(overrideModule);
}
Module byzantineModule = byzantineNodeModules.get(self);
if (byzantineModule != null) {
module = Modules.override(module).with(byzantineModule);
}
return Guice.createInjector(module);
}
use of com.radixdlt.consensus.HashSigner in project radixdlt by radixdlt.
the class SafetyRulesTest method setup.
@Before
public void setup() {
this.safetyState = mock(SafetyState.class);
Hasher hasher = mock(Hasher.class);
when(hasher.hash(any())).thenReturn(HashUtils.random256());
when(hasher.hashBytes(any())).thenReturn(HashUtils.random256());
HashSigner hashSigner = mock(HashSigner.class);
when(hashSigner.sign(any(HashCode.class))).thenReturn(ECDSASignature.zeroSignature());
this.safetyRules = new SafetyRules(mock(BFTNode.class), safetyState, mock(PersistentSafetyStateStore.class), hasher, hashSigner);
}
Aggregations