Search in sources :

Example 1 with RuntimeProperties

use of com.radixdlt.properties.RuntimeProperties 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);
}
Also used : SingleNodeAndPeersDeterministicNetworkModule(com.radixdlt.SingleNodeAndPeersDeterministicNetworkModule) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) AddressBookPersistence(com.radixdlt.network.p2p.addressbook.AddressBookPersistence) BerkeleyAdditionalStore(com.radixdlt.store.berkeley.BerkeleyAdditionalStore) RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) AbstractModule(com.google.inject.AbstractModule) BerkeleyRecoverableProcessedTxnStore(com.radixdlt.api.core.reconstruction.BerkeleyRecoverableProcessedTxnStore) MockedGenesisModule(com.radixdlt.statecomputer.checkpoint.MockedGenesisModule) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) RadixNodeUri(com.radixdlt.network.p2p.RadixNodeUri) RuntimeProperties(com.radixdlt.properties.RuntimeProperties) Before(org.junit.Before)

Example 2 with RuntimeProperties

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

the class PeerManagerStaticTest method defaultProperties.

private static RuntimeProperties defaultProperties() {
    try {
        final var props = new RuntimeProperties(new JSONObject(), new String[] {});
        props.set("network.p2p.max_inbound_channels", 10);
        props.set("network.p2p.max_outbound_channels", 10);
        return props;
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }
}
Also used : JSONObject(org.json.JSONObject) ParseException(org.apache.commons.cli.ParseException) RuntimeProperties(com.radixdlt.properties.RuntimeProperties)

Example 3 with RuntimeProperties

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

the class PeerLivenessMonitorTest method setup.

@Before
public void setup() throws ParseException {
    this.p2PConfig = P2PConfig.fromRuntimeProperties(new RuntimeProperties(new JSONObject(), new String[] {}));
    this.peersView = mock(PeersView.class);
    this.peerEventDispatcher = rmock(EventDispatcher.class);
    this.pingEventDispatcher = rmock(RemoteEventDispatcher.class);
    this.pongEventDispatcher = rmock(RemoteEventDispatcher.class);
    this.pingTimeoutEventDispatcher = rmock(ScheduledEventDispatcher.class);
    this.sut = new PeerLivenessMonitor(p2PConfig, peersView, peerEventDispatcher, pingEventDispatcher, pongEventDispatcher, pingTimeoutEventDispatcher);
}
Also used : PeersView(com.radixdlt.network.p2p.PeersView) ScheduledEventDispatcher(com.radixdlt.environment.ScheduledEventDispatcher) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) EventDispatcher(com.radixdlt.environment.EventDispatcher) JSONObject(org.json.JSONObject) RemoteEventDispatcher(com.radixdlt.environment.RemoteEventDispatcher) ScheduledEventDispatcher(com.radixdlt.environment.ScheduledEventDispatcher) RuntimeProperties(com.radixdlt.properties.RuntimeProperties) Before(org.junit.Before)

Example 4 with RuntimeProperties

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

the class NetworkQueryHostIpTest method testPropertyNotEmpty.

@Test
public void testPropertyNotEmpty() {
    RuntimeProperties properties = mock(RuntimeProperties.class);
    when(properties.get(eq(NetworkQueryHostIp.QUERY_URLS_PROPERTY), any())).thenReturn("http://localhost,http://8.8.8.8");
    NetworkQueryHostIp nqhip = (NetworkQueryHostIp) NetworkQueryHostIp.create(properties);
    assertEquals(2, nqhip.count());
}
Also used : RuntimeProperties(com.radixdlt.properties.RuntimeProperties) Test(org.junit.Test)

Example 5 with RuntimeProperties

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

the class NetworkQueryHostIpTest method testPropertyEmpty.

@Test
public void testPropertyEmpty() {
    RuntimeProperties properties = mock(RuntimeProperties.class);
    when(properties.get(eq(NetworkQueryHostIp.QUERY_URLS_PROPERTY), any())).thenReturn("");
    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)12 JSONObject (org.json.JSONObject)4 Test (org.junit.Test)4 AbstractModule (com.google.inject.AbstractModule)3 ParseException (org.apache.commons.cli.ParseException)3 Before (org.junit.Before)3 SingleNodeAndPeersDeterministicNetworkModule (com.radixdlt.SingleNodeAndPeersDeterministicNetworkModule)2 BerkeleyRecoverableProcessedTxnStore (com.radixdlt.api.core.reconstruction.BerkeleyRecoverableProcessedTxnStore)2 RadixNodeUri (com.radixdlt.network.p2p.RadixNodeUri)2 AddressBookPersistence (com.radixdlt.network.p2p.addressbook.AddressBookPersistence)2 MockedGenesisModule (com.radixdlt.statecomputer.checkpoint.MockedGenesisModule)2 ForksModule (com.radixdlt.statecomputer.forks.ForksModule)2 MainnetForkConfigsModule (com.radixdlt.statecomputer.forks.MainnetForkConfigsModule)2 RadixEngineForksLatestOnlyModule (com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule)2 BerkeleyAdditionalStore (com.radixdlt.store.berkeley.BerkeleyAdditionalStore)2 IOException (java.io.IOException)2 DispatcherModule (com.radixdlt.DispatcherModule)1 ValidatorRegisteredCopy (com.radixdlt.application.validators.state.ValidatorRegisteredCopy)1 BFTNode (com.radixdlt.consensus.bft.BFTNode)1 Self (com.radixdlt.consensus.bft.Self)1