use of com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule in project radixdlt by radixdlt.
the class ApiTest method setup.
@Before
public void setup() {
var injector = Guice.createInjector(MempoolConfig.asModule(mempoolMaxSize, 10), new MainnetForkConfigsModule(), new RadixEngineForksLatestOnlyModule(RERulesConfig.testingDefault().overrideFeeTable(FeeTable.create(Amount.ofSubunits(UInt256.ONE), Map.of(ValidatorRegisteredCopy.class, Amount.ofSubunits(UInt256.ONE))))), new ForksModule(), new SingleNodeAndPeersDeterministicNetworkModule(TEST_KEY, 1), new MockedGenesisModule(Set.of(TEST_KEY.getPublicKey()), totalTokenAmount, stakeAmount), new AbstractModule() {
@Override
protected void configure() {
bind(BerkeleyRecoverableProcessedTxnStore.class).in(Scopes.SINGLETON);
Multibinder.newSetBinder(binder(), BerkeleyAdditionalStore.class).addBinding().to(BerkeleyRecoverableProcessedTxnStore.class);
bindConstant().annotatedWith(DatabaseLocation.class).to(folder.getRoot().getAbsolutePath());
bindConstant().annotatedWith(NetworkId.class).to(99);
bind(P2PConfig.class).toInstance(mock(P2PConfig.class));
bind(AddressBook.class).in(Scopes.SINGLETON);
var selfUri = RadixNodeUri.fromPubKeyAndAddress(99, TEST_KEY.getPublicKey(), "localhost", 23456);
bind(RadixNodeUri.class).annotatedWith(Self.class).toInstance(selfUri);
var addressBookPersistence = mock(AddressBookPersistence.class);
when(addressBookPersistence.getAllEntries()).thenReturn(ImmutableList.of());
bind(AddressBookPersistence.class).toInstance(addressBookPersistence);
var runtimeProperties = mock(RuntimeProperties.class);
when(runtimeProperties.get(eq("api.transactions.enable"), anyBoolean())).thenReturn(true);
bind(RuntimeProperties.class).toInstance(runtimeProperties);
}
});
injector.injectMembers(this);
}
use of com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule in project radixdlt by radixdlt.
the class RadixEngineStateComputerTest method getExternalModule.
private Module getExternalModule() {
return new AbstractModule() {
@Override
public void configure() {
var validatorSet = BFTValidatorSet.from(registeredNodes.stream().map(ECKeyPair::getPublicKey).map(BFTNode::create).map(n -> BFTValidator.from(n, UInt256.ONE)));
bind(ProposerElection.class).toInstance(new WeightedRotatingLeaders(validatorSet));
bind(Serialization.class).toInstance(serialization);
bind(Hasher.class).toInstance(Sha256Hasher.withDefaultSerialization());
bind(new TypeLiteral<EngineStore<LedgerAndBFTProof>>() {
}).toInstance(engineStore);
bind(PersistentVertexStore.class).toInstance(mock(PersistentVertexStore.class));
install(MempoolConfig.asModule(10, 10));
install(new MainnetForkConfigsModule());
install(new ForksModule());
install(new RadixEngineForksLatestOnlyModule());
// HACK
bind(CommittedReader.class).toInstance(CommittedReader.mocked());
bind(LedgerAccumulator.class).to(SimpleLedgerAccumulatorAndVerifier.class);
bind(new TypeLiteral<EventDispatcher<MempoolAddSuccess>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(new TypeLiteral<EventDispatcher<InvalidProposedTxn>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(new TypeLiteral<EventDispatcher<TxnsRemovedFromMempool>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(new TypeLiteral<EventDispatcher<REOutput>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(new TypeLiteral<EventDispatcher<MempoolRelayTrigger>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(new TypeLiteral<EventDispatcher<LedgerUpdate>>() {
}).toInstance(TypedMocks.rmock(EventDispatcher.class));
bind(SystemCounters.class).to(SystemCountersImpl.class);
}
};
}
use of com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule in project radixdlt by radixdlt.
the class AbstractRadixEngineTest method setup.
@Before
public void setup() {
var injector = Guice.createInjector(MempoolConfig.asModule(mempoolMaxSize, 10), new MainnetForkConfigsModule(), new RadixEngineForksLatestOnlyModule(RERulesConfig.testingDefault().overrideFeeTable(FeeTable.create(Amount.ofSubunits(UInt256.ONE), Map.of(ValidatorRegisteredCopy.class, Amount.ofSubunits(UInt256.ONE)))).overrideMaxMessageLen(maxMessageLen)), new ForksModule(), new SingleNodeAndPeersDeterministicNetworkModule(TEST_KEY, 1), new MockedGenesisModule(Set.of(TEST_KEY.getPublicKey()), totalTokenAmount, stakeAmount), new AbstractModule() {
@Override
protected void configure() {
bind(BerkeleyRecoverableProcessedTxnStore.class).in(Scopes.SINGLETON);
Multibinder.newSetBinder(binder(), BerkeleyAdditionalStore.class).addBinding().to(BerkeleyRecoverableProcessedTxnStore.class);
bindConstant().annotatedWith(DatabaseLocation.class).to(folder.getRoot().getAbsolutePath());
bindConstant().annotatedWith(NetworkId.class).to(99);
bind(P2PConfig.class).toInstance(mock(P2PConfig.class));
bind(AddressBook.class).in(Scopes.SINGLETON);
var selfUri = RadixNodeUri.fromPubKeyAndAddress(99, TEST_KEY.getPublicKey(), "localhost", 23456);
bind(RadixNodeUri.class).annotatedWith(Self.class).toInstance(selfUri);
var addressBookPersistence = mock(AddressBookPersistence.class);
when(addressBookPersistence.getAllEntries()).thenReturn(ImmutableList.of());
bind(AddressBookPersistence.class).toInstance(addressBookPersistence);
var runtimeProperties = mock(RuntimeProperties.class);
when(runtimeProperties.get(eq("api.transactions.enable"), anyBoolean())).thenReturn(true);
bind(RuntimeProperties.class).toInstance(runtimeProperties);
}
});
injector.injectMembers(this);
}
Aggregations