use of com.radixdlt.crypto.ECKeyPair in project radixdlt by radixdlt.
the class MempoolTest method add_remote_command_to_mempool.
@Test
public void add_remote_command_to_mempool() throws Exception {
// Arrange
getInjector().injectMembers(this);
ECKeyPair keyPair = ECKeyPair.generateNew();
var txn = createTxn(keyPair);
// Act
processor.handleMessage(getFirstPeer(), MempoolAdd.create(txn), null);
// Assert
assertThat(systemCounters.get(CounterType.MEMPOOL_CURRENT_SIZE)).isEqualTo(1);
// FIXME: Added hack which requires genesis to be sent as message so ignore this check for now
// assertThat(network.allMessages())
// .hasOnlyOneElementSatisfying(m ->
// assertThat(m.message()).isInstanceOf(MempoolAddSuccess.class));
}
use of com.radixdlt.crypto.ECKeyPair in project radixdlt by radixdlt.
the class MempoolTest method add_same_command_to_mempool.
@Test
public void add_same_command_to_mempool() throws Exception {
// Arrange
getInjector().injectMembers(this);
ECKeyPair keyPair = ECKeyPair.generateNew();
var txn = createTxn(keyPair);
MempoolAdd mempoolAdd = MempoolAdd.create(txn);
processor.handleMessage(getFirstPeer(), mempoolAdd, null);
// Act
processor.handleMessage(getFirstPeer(), mempoolAdd, null);
// Assert
assertThat(systemCounters.get(CounterType.MEMPOOL_CURRENT_SIZE)).isEqualTo(1);
}
use of com.radixdlt.crypto.ECKeyPair in project radixdlt by radixdlt.
the class MempoolTest method mempool_removes_conflicts_on_commit.
@Test
public void mempool_removes_conflicts_on_commit() throws Exception {
// Arrange
getInjector().injectMembers(this);
ECKeyPair keyPair = ECKeyPair.generateNew();
var txn = createTxn(keyPair, 2);
MempoolAdd mempoolAdd = MempoolAdd.create(txn);
processor.handleMessage(getFirstPeer(), mempoolAdd, null);
// Act
var txn2 = createTxn(keyPair, 1);
var proof = mock(LedgerProof.class);
when(proof.getAccumulatorState()).thenReturn(new AccumulatorState(genesisTxns.getTxns().size() + 1, HashUtils.random256()));
when(proof.getStateVersion()).thenReturn((long) genesisTxns.getTxns().size() + 1);
when(proof.getView()).thenReturn(View.of(1));
var commandsAndProof = VerifiedTxnsAndProof.create(List.of(txn2), proof);
stateComputer.commit(commandsAndProof, null);
// Assert
assertThat(systemCounters.get(CounterType.MEMPOOL_CURRENT_SIZE)).isZero();
}
use of com.radixdlt.crypto.ECKeyPair in project radixdlt by radixdlt.
the class MempoolTest method relay_successful_remote_add.
@Test
public void relay_successful_remote_add() throws Exception {
// Arrange
getInjector().injectMembers(this);
ECKeyPair keyPair = ECKeyPair.generateNew();
var txn = createTxn(keyPair);
// Act
processor.handleMessage(self, MempoolAddSuccess.create(txn, null, getFirstPeer()), null);
// Assert
assertThat(systemCounters.get(CounterType.MEMPOOL_RELAYS_SENT)).isEqualTo(NUM_PEERS - 1);
}
use of com.radixdlt.crypto.ECKeyPair in project radixdlt by radixdlt.
the class SimulationNodes method createBFTModule.
private Module createBFTModule(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
private ECKeyPair keyPair() {
return self;
}
@Provides
@LocalSigner
HashSigner hashSigner() {
return self::sign;
}
}, new NodeNetworkMessagesModule(underlyingNetwork), baseModule);
// can break network behavior if incorrect modules are used
if (overrideModules.containsKey(self.getPublicKey())) {
final var nodeOverrideModules = overrideModules.get(self.getPublicKey());
module = Modules.override(module).with(nodeOverrideModules);
}
return module;
}
Aggregations