Search in sources :

Example 1 with MockedCryptoModule

use of com.radixdlt.modules.MockedCryptoModule in project radixdlt by radixdlt.

the class MempoolRunnerTest method createModule.

@SuppressWarnings(// The mock method doesn't support type-safe generics due to type erasure
"unchecked")
public Module createModule() {
    return new AbstractModule() {

        @Override
        public void configure() {
            bind(BFTNode.class).annotatedWith(Self.class).toInstance(BFTNode.random());
            bind(LedgerProof.class).annotatedWith(LastProof.class).toInstance(mock(LedgerProof.class));
            bind(StateComputer.class).toInstance(stateComputer);
            bind(SystemCounters.class).toInstance(new SystemCountersImpl());
            bind(RxRemoteEnvironment.class).toInstance(new RxRemoteEnvironment() {

                @Override
                public <T> Flowable<RemoteEvent<T>> remoteEvents(Class<T> remoteEventClass) {
                    return Flowable.never();
                }
            });
            bind(LedgerAccumulator.class).toInstance(mock(LedgerAccumulator.class));
            bind(LedgerAccumulatorVerifier.class).toInstance(mock(LedgerAccumulatorVerifier.class));
            bind(new TypeLiteral<Comparator<LedgerProof>>() {
            }).toInstance(mock(Comparator.class));
            bind(Addressing.class).toInstance(Addressing.ofNetwork(Network.LOCALNET));
            bind(TimeSupplier.class).toInstance(System::currentTimeMillis);
            Multibinder.newSetBinder(binder(), StartProcessorOnRunner.class);
            install(MempoolConfig.asModule(100, 10));
            install(new MockedKeyModule());
            install(new MockedCryptoModule());
            install(new RxEnvironmentModule());
            install(new DispatcherModule());
            install(new MempoolReceiverModule());
            install(new EventLoggerModule());
        }
    };
}
Also used : MockedKeyModule(com.radixdlt.modules.MockedKeyModule) Self(com.radixdlt.hotstuff.bft.Self) TimeSupplier(com.radixdlt.utils.TimeSupplier) Addressing(com.radixdlt.networks.Addressing) Comparator(java.util.Comparator) LedgerAccumulatorVerifier(com.radixdlt.ledger.LedgerAccumulatorVerifier) TypeLiteral(com.google.inject.TypeLiteral) LedgerProof(com.radixdlt.hotstuff.LedgerProof) StateComputer(com.radixdlt.ledger.StateComputerLedger.StateComputer) LedgerAccumulator(com.radixdlt.ledger.LedgerAccumulator) RxRemoteEnvironment(com.radixdlt.environment.rx.RxRemoteEnvironment) SystemCounters(com.radixdlt.counters.SystemCounters) MockedCryptoModule(com.radixdlt.modules.MockedCryptoModule) RxEnvironmentModule(com.radixdlt.environment.rx.RxEnvironmentModule) AbstractModule(com.google.inject.AbstractModule) LastProof(com.radixdlt.store.LastProof) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) DispatcherModule(com.radixdlt.modules.DispatcherModule) EventLoggerModule(com.radixdlt.modules.EventLoggerModule) Flowable(io.reactivex.rxjava3.core.Flowable)

Aggregations

AbstractModule (com.google.inject.AbstractModule)1 TypeLiteral (com.google.inject.TypeLiteral)1 SystemCounters (com.radixdlt.counters.SystemCounters)1 SystemCountersImpl (com.radixdlt.counters.SystemCountersImpl)1 RxEnvironmentModule (com.radixdlt.environment.rx.RxEnvironmentModule)1 RxRemoteEnvironment (com.radixdlt.environment.rx.RxRemoteEnvironment)1 LedgerProof (com.radixdlt.hotstuff.LedgerProof)1 Self (com.radixdlt.hotstuff.bft.Self)1 LedgerAccumulator (com.radixdlt.ledger.LedgerAccumulator)1 LedgerAccumulatorVerifier (com.radixdlt.ledger.LedgerAccumulatorVerifier)1 StateComputer (com.radixdlt.ledger.StateComputerLedger.StateComputer)1 DispatcherModule (com.radixdlt.modules.DispatcherModule)1 EventLoggerModule (com.radixdlt.modules.EventLoggerModule)1 MockedCryptoModule (com.radixdlt.modules.MockedCryptoModule)1 MockedKeyModule (com.radixdlt.modules.MockedKeyModule)1 Addressing (com.radixdlt.networks.Addressing)1 LastProof (com.radixdlt.store.LastProof)1 TimeSupplier (com.radixdlt.utils.TimeSupplier)1 Flowable (io.reactivex.rxjava3.core.Flowable)1 Comparator (java.util.Comparator)1