Search in sources :

Example 11 with RuntimeProperties

use of com.radixdlt.properties.RuntimeProperties in project radixdlt by radixdlt.

the class MessageCentralConfigurationTest method fromRuntimeProperties.

@Test
public void fromRuntimeProperties() {
    RuntimeProperties properties = mock(RuntimeProperties.class);
    when(properties.get(eq("messaging.inbound.queue_max"), anyInt())).thenReturn(100);
    when(properties.get(eq("messaging.outbound.queue_max"), anyInt())).thenReturn(102);
    when(properties.get(eq("messaging.time_to_live"), anyLong())).thenReturn(104L);
    MessageCentralConfiguration config = MessageCentralConfiguration.fromRuntimeProperties(properties);
    assertEquals(100, config.messagingInboundQueueMax(-1));
    assertEquals(102, config.messagingOutboundQueueMax(-1));
    assertEquals(104, config.messagingTimeToLive(-1));
}
Also used : RuntimeProperties(com.radixdlt.properties.RuntimeProperties) Test(org.junit.Test)

Example 12 with RuntimeProperties

use of com.radixdlt.properties.RuntimeProperties in project radixdlt by radixdlt.

the class AbstractRadixEngineTest method setup.

@Before
public void setup() {
    var injector = Guice.createInjector(MempoolConfig.asModule(mempoolMaxSize, 10), new MainnetForksModule(), 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);
}
Also used : SingleNodeAndPeersDeterministicNetworkModule(com.radixdlt.modules.SingleNodeAndPeersDeterministicNetworkModule) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) MainnetForksModule(com.radixdlt.statecomputer.forks.modules.MainnetForksModule) AddressBookPersistence(com.radixdlt.network.p2p.addressbook.AddressBookPersistence) BerkeleyAdditionalStore(com.radixdlt.store.berkeley.BerkeleyAdditionalStore) RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) AbstractModule(com.google.inject.AbstractModule) ValidatorRegisteredCopy(com.radixdlt.application.validators.state.ValidatorRegisteredCopy) BerkeleyRecoverableProcessedTxnStore(com.radixdlt.api.core.reconstruction.BerkeleyRecoverableProcessedTxnStore) MainnetForksModule(com.radixdlt.statecomputer.forks.modules.MainnetForksModule) MockedGenesisModule(com.radixdlt.statecomputer.checkpoint.MockedGenesisModule) RadixNodeUri(com.radixdlt.network.p2p.RadixNodeUri) RuntimeProperties(com.radixdlt.properties.RuntimeProperties) Before(org.junit.Before)

Example 13 with RuntimeProperties

use of com.radixdlt.properties.RuntimeProperties in project radixdlt by radixdlt.

the class NetworkQueryHostIpTest method testPropertyNull.

@Test
public void testPropertyNull() {
    RuntimeProperties properties = mock(RuntimeProperties.class);
    when(properties.get(eq(NetworkQueryHostIp.QUERY_URLS_PROPERTY), any())).thenReturn(null);
    NetworkQueryHostIp nqhip = (NetworkQueryHostIp) NetworkQueryHostIp.create(properties);
    assertEquals(NetworkQueryHostIp.DEFAULT_QUERY_URLS.size(), nqhip.count());
}
Also used : RuntimeProperties(com.radixdlt.properties.RuntimeProperties) Test(org.junit.Test)

Aggregations

RuntimeProperties (com.radixdlt.properties.RuntimeProperties)13 JSONObject (org.json.JSONObject)5 Test (org.junit.Test)5 ParseException (org.apache.commons.cli.ParseException)4 AbstractModule (com.google.inject.AbstractModule)3 RadixNodeUri (com.radixdlt.network.p2p.RadixNodeUri)3 BerkeleyRecoverableProcessedTxnStore (com.radixdlt.api.core.reconstruction.BerkeleyRecoverableProcessedTxnStore)2 EventDispatcher (com.radixdlt.environment.EventDispatcher)2 ScheduledEventDispatcher (com.radixdlt.environment.ScheduledEventDispatcher)2 SingleNodeAndPeersDeterministicNetworkModule (com.radixdlt.modules.SingleNodeAndPeersDeterministicNetworkModule)2 PeerOutboundBootstrap (com.radixdlt.network.p2p.transport.PeerOutboundBootstrap)2 Before (org.junit.Before)2 ImmutableList (com.google.common.collect.ImmutableList)1 Guice (com.google.inject.Guice)1 Injector (com.google.inject.Injector)1 Key (com.google.inject.Key)1 Provides (com.google.inject.Provides)1 Scopes (com.google.inject.Scopes)1 Multibinder (com.google.inject.multibindings.Multibinder)1 Modules (com.google.inject.util.Modules)1