diff --git a/common/src/main/java/bisq/common/ClockWatcher.java b/common/src/main/java/bisq/common/ClockWatcher.java index 0ca0a3423b6..1b673535fad 100644 --- a/common/src/main/java/bisq/common/ClockWatcher.java +++ b/common/src/main/java/bisq/common/ClockWatcher.java @@ -17,6 +17,8 @@ package bisq.common; +import javax.inject.Singleton; + import java.util.LinkedList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -26,6 +28,7 @@ // Helps configure listener objects that are run by the `UserThread` each second // and can do per second, per minute and delayed second actions. Also detects when we were in standby, and logs it. @Slf4j +@Singleton public class ClockWatcher { public static final int IDLE_TOLERANCE_MS = 20000; diff --git a/common/src/main/java/bisq/common/crypto/KeyRing.java b/common/src/main/java/bisq/common/crypto/KeyRing.java index 4dab6ad3ac6..7f965d702ae 100644 --- a/common/src/main/java/bisq/common/crypto/KeyRing.java +++ b/common/src/main/java/bisq/common/crypto/KeyRing.java @@ -18,6 +18,7 @@ package bisq.common.crypto; import javax.inject.Inject; +import javax.inject.Singleton; import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPPublicKey; @@ -34,6 +35,7 @@ @Getter @EqualsAndHashCode @Slf4j +@Singleton public class KeyRing { private final KeyPair signatureKeyPair; private final KeyPair encryptionKeyPair; diff --git a/common/src/main/java/bisq/common/crypto/KeyStorage.java b/common/src/main/java/bisq/common/crypto/KeyStorage.java index 5a8d271acfe..82274c34d20 100644 --- a/common/src/main/java/bisq/common/crypto/KeyStorage.java +++ b/common/src/main/java/bisq/common/crypto/KeyStorage.java @@ -22,6 +22,7 @@ import com.google.inject.Inject; import javax.inject.Named; +import javax.inject.Singleton; import org.bouncycastle.openpgp.PGPKeyPair; @@ -56,6 +57,7 @@ import javax.annotation.Nullable; // TODO: use a password protection for key storage +@Singleton public class KeyStorage { private static final Logger log = LoggerFactory.getLogger(KeyStorage.class); diff --git a/common/src/main/java/bisq/common/storage/CorruptedDatabaseFilesHandler.java b/common/src/main/java/bisq/common/storage/CorruptedDatabaseFilesHandler.java index f33d8ac4bca..ac967604519 100644 --- a/common/src/main/java/bisq/common/storage/CorruptedDatabaseFilesHandler.java +++ b/common/src/main/java/bisq/common/storage/CorruptedDatabaseFilesHandler.java @@ -18,6 +18,7 @@ package bisq.common.storage; import javax.inject.Inject; +import javax.inject.Singleton; import java.util.ArrayList; import java.util.List; @@ -26,6 +27,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j +@Singleton public class CorruptedDatabaseFilesHandler { private List corruptedDatabaseFiles = new ArrayList<>(); diff --git a/core/src/main/java/bisq/core/CoreModule.java b/core/src/main/java/bisq/core/CoreModule.java index fa4d8795155..adcbf3a163e 100644 --- a/core/src/main/java/bisq/core/CoreModule.java +++ b/core/src/main/java/bisq/core/CoreModule.java @@ -19,53 +19,33 @@ import bisq.core.alert.AlertModule; import bisq.core.app.AppOptionKeys; -import bisq.core.app.AvoidStandbyModeService; import bisq.core.app.BisqEnvironment; -import bisq.core.app.BisqSetup; -import bisq.core.app.P2PNetworkSetup; -import bisq.core.app.TorSetup; -import bisq.core.app.WalletAppSetup; import bisq.core.arbitration.ArbitratorModule; import bisq.core.btc.BitcoinModule; import bisq.core.dao.DaoModule; import bisq.core.filter.FilterModule; import bisq.core.network.p2p.seed.DefaultSeedNodeRepository; -import bisq.core.notifications.MobileMessageEncryption; -import bisq.core.notifications.MobileModel; -import bisq.core.notifications.MobileNotificationService; -import bisq.core.notifications.MobileNotificationValidator; -import bisq.core.notifications.alerts.DisputeMsgEvents; -import bisq.core.notifications.alerts.MyOfferTakenEvents; -import bisq.core.notifications.alerts.TradeEvents; -import bisq.core.notifications.alerts.market.MarketAlerts; -import bisq.core.notifications.alerts.price.PriceAlert; import bisq.core.offer.OfferModule; -import bisq.core.payment.TradeLimits; import bisq.core.presentation.CorePresentationModule; import bisq.core.proto.network.CoreNetworkProtoResolver; import bisq.core.proto.persistable.CorePersistenceProtoResolver; import bisq.core.trade.TradeModule; import bisq.core.user.Preferences; -import bisq.core.user.User; import bisq.network.crypto.EncryptionServiceModule; import bisq.network.p2p.P2PModule; import bisq.network.p2p.network.BridgeAddressProvider; import bisq.network.p2p.seed.SeedNodeRepository; -import bisq.common.ClockWatcher; import bisq.common.CommonOptionKeys; import bisq.common.app.AppModule; -import bisq.common.crypto.KeyRing; import bisq.common.crypto.KeyStorage; import bisq.common.proto.network.NetworkProtoResolver; import bisq.common.proto.persistable.PersistenceProtoResolver; -import bisq.common.storage.CorruptedDatabaseFilesHandler; import bisq.common.storage.Storage; import org.springframework.core.env.Environment; -import com.google.inject.Singleton; import com.google.inject.name.Names; import java.io.File; @@ -80,25 +60,11 @@ public CoreModule(Environment environment) { @Override protected void configure() { - bind(BisqSetup.class).in(Singleton.class); - bind(TorSetup.class).in(Singleton.class); - bind(P2PNetworkSetup.class).in(Singleton.class); - bind(WalletAppSetup.class).in(Singleton.class); - bind(BisqEnvironment.class).toInstance((BisqEnvironment) environment); - bind(TradeLimits.class).in(Singleton.class); - - bind(KeyStorage.class).in(Singleton.class); - bind(KeyRing.class).in(Singleton.class); - bind(User.class).in(Singleton.class); - bind(ClockWatcher.class).in(Singleton.class); - bind(Preferences.class).in(Singleton.class); - bind(BridgeAddressProvider.class).to(Preferences.class).in(Singleton.class); - bind(CorruptedDatabaseFilesHandler.class).in(Singleton.class); - bind(AvoidStandbyModeService.class).in(Singleton.class); + bind(BridgeAddressProvider.class).to(Preferences.class); - bind(SeedNodeRepository.class).to(DefaultSeedNodeRepository.class).in(Singleton.class); + bind(SeedNodeRepository.class).to(DefaultSeedNodeRepository.class); File storageDir = new File(environment.getRequiredProperty(Storage.STORAGE_DIR)); bind(File.class).annotatedWith(named(Storage.STORAGE_DIR)).toInstance(storageDir); @@ -106,8 +72,8 @@ protected void configure() { File keyStorageDir = new File(environment.getRequiredProperty(KeyStorage.KEY_STORAGE_DIR)); bind(File.class).annotatedWith(named(KeyStorage.KEY_STORAGE_DIR)).toInstance(keyStorageDir); - bind(NetworkProtoResolver.class).to(CoreNetworkProtoResolver.class).in(Singleton.class); - bind(PersistenceProtoResolver.class).to(CorePersistenceProtoResolver.class).in(Singleton.class); + bind(NetworkProtoResolver.class).to(CoreNetworkProtoResolver.class); + bind(PersistenceProtoResolver.class).to(CorePersistenceProtoResolver.class); Boolean useDevPrivilegeKeys = environment.getProperty(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS, Boolean.class, false); bind(boolean.class).annotatedWith(Names.named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS)).toInstance(useDevPrivilegeKeys); @@ -118,15 +84,6 @@ protected void configure() { String referralId = environment.getProperty(AppOptionKeys.REFERRAL_ID, String.class, ""); bind(String.class).annotatedWith(Names.named(AppOptionKeys.REFERRAL_ID)).toInstance(referralId); - bind(MobileNotificationService.class).in(Singleton.class); - bind(MobileMessageEncryption.class).in(Singleton.class); - bind(MobileNotificationValidator.class).in(Singleton.class); - bind(MobileModel.class).in(Singleton.class); - bind(MyOfferTakenEvents.class).in(Singleton.class); - bind(TradeEvents.class).in(Singleton.class); - bind(DisputeMsgEvents.class).in(Singleton.class); - bind(PriceAlert.class).in(Singleton.class); - bind(MarketAlerts.class).in(Singleton.class); // ordering is used for shut down sequence install(tradeModule()); diff --git a/core/src/main/java/bisq/core/app/AvoidStandbyModeService.java b/core/src/main/java/bisq/core/app/AvoidStandbyModeService.java index 36badeaecd5..bf9a733718e 100644 --- a/core/src/main/java/bisq/core/app/AvoidStandbyModeService.java +++ b/core/src/main/java/bisq/core/app/AvoidStandbyModeService.java @@ -20,6 +20,7 @@ import bisq.core.user.Preferences; import javax.inject.Inject; +import javax.inject.Singleton; import org.apache.commons.io.IOUtils; @@ -40,6 +41,7 @@ import javax.sound.sampled.SourceDataLine; @Slf4j +@Singleton public class AvoidStandbyModeService { private final Preferences preferences; private volatile boolean isStopped; diff --git a/core/src/main/java/bisq/core/app/BisqSetup.java b/core/src/main/java/bisq/core/app/BisqSetup.java index d59dbd89bd7..f4c2b66839c 100644 --- a/core/src/main/java/bisq/core/app/BisqSetup.java +++ b/core/src/main/java/bisq/core/app/BisqSetup.java @@ -72,6 +72,7 @@ import org.bitcoinj.core.Coin; import javax.inject.Inject; +import javax.inject.Singleton; import com.google.common.net.InetAddresses; @@ -109,6 +110,7 @@ import javax.annotation.Nullable; @Slf4j +@Singleton public class BisqSetup { public interface BisqSetupCompleteListener { void onSetupComplete(); diff --git a/core/src/main/java/bisq/core/app/P2PNetworkSetup.java b/core/src/main/java/bisq/core/app/P2PNetworkSetup.java index cbcda4bb3af..76527919dc4 100644 --- a/core/src/main/java/bisq/core/app/P2PNetworkSetup.java +++ b/core/src/main/java/bisq/core/app/P2PNetworkSetup.java @@ -28,6 +28,7 @@ import bisq.network.p2p.network.ConnectionListener; import javax.inject.Inject; +import javax.inject.Singleton; import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.monadic.MonadicBinding; @@ -44,6 +45,7 @@ import javax.annotation.Nullable; +@Singleton @Slf4j public class P2PNetworkSetup { private final PriceFeedService priceFeedService; diff --git a/core/src/main/java/bisq/core/app/TorSetup.java b/core/src/main/java/bisq/core/app/TorSetup.java index 238e23e97a4..669f570ee1c 100644 --- a/core/src/main/java/bisq/core/app/TorSetup.java +++ b/core/src/main/java/bisq/core/app/TorSetup.java @@ -25,6 +25,7 @@ import com.google.inject.name.Named; import javax.inject.Inject; +import javax.inject.Singleton; import java.nio.file.Paths; @@ -36,6 +37,7 @@ import javax.annotation.Nullable; @Slf4j +@Singleton public class TorSetup { private File torDir; diff --git a/core/src/main/java/bisq/core/app/WalletAppSetup.java b/core/src/main/java/bisq/core/app/WalletAppSetup.java index e89df28ab85..f9ad67f2fd8 100644 --- a/core/src/main/java/bisq/core/app/WalletAppSetup.java +++ b/core/src/main/java/bisq/core/app/WalletAppSetup.java @@ -28,6 +28,7 @@ import org.bitcoinj.store.ChainFileLockedException; import javax.inject.Inject; +import javax.inject.Singleton; import org.fxmisc.easybind.EasyBind; import org.fxmisc.easybind.monadic.MonadicBinding; @@ -50,6 +51,7 @@ import javax.annotation.Nullable; @Slf4j +@Singleton public class WalletAppSetup { private final WalletsManager walletsManager; private final WalletsSetup walletsSetup; diff --git a/core/src/main/java/bisq/core/network/p2p/seed/DefaultSeedNodeRepository.java b/core/src/main/java/bisq/core/network/p2p/seed/DefaultSeedNodeRepository.java index 6b3a021789f..d8f4f039a14 100644 --- a/core/src/main/java/bisq/core/network/p2p/seed/DefaultSeedNodeRepository.java +++ b/core/src/main/java/bisq/core/network/p2p/seed/DefaultSeedNodeRepository.java @@ -25,6 +25,7 @@ import javax.inject.Inject; import javax.inject.Named; +import javax.inject.Singleton; import java.io.BufferedReader; import java.io.InputStream; @@ -43,6 +44,7 @@ // If a new BaseCurrencyNetwork type gets added we need to add the resource file for it as well! @Slf4j +@Singleton public class DefaultSeedNodeRepository implements SeedNodeRepository { //TODO add support for localhost addresses private static final Pattern pattern = Pattern.compile("^([a-z0-9]+\\.onion:\\d+)"); diff --git a/core/src/main/java/bisq/core/notifications/MobileMessageEncryption.java b/core/src/main/java/bisq/core/notifications/MobileMessageEncryption.java index 0b6195872b7..37ddfe88d41 100644 --- a/core/src/main/java/bisq/core/notifications/MobileMessageEncryption.java +++ b/core/src/main/java/bisq/core/notifications/MobileMessageEncryption.java @@ -18,6 +18,7 @@ package bisq.core.notifications; import javax.inject.Inject; +import javax.inject.Singleton; import com.google.common.base.Charsets; @@ -33,6 +34,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j +@Singleton public class MobileMessageEncryption { private SecretKeySpec keySpec; private Cipher cipher; diff --git a/core/src/main/java/bisq/core/notifications/MobileModel.java b/core/src/main/java/bisq/core/notifications/MobileModel.java index ffd015afa0b..2c212e7e4e9 100644 --- a/core/src/main/java/bisq/core/notifications/MobileModel.java +++ b/core/src/main/java/bisq/core/notifications/MobileModel.java @@ -18,6 +18,7 @@ package bisq.core.notifications; import javax.inject.Inject; +import javax.inject.Singleton; import com.google.common.annotations.VisibleForTesting; @@ -29,6 +30,7 @@ @Data @Slf4j +@Singleton public class MobileModel { public static final String PHONE_SEPARATOR_ESCAPED = "\\|"; // see https://stackoverflow.com/questions/5675704/java-string-split-not-returning-the-right-values public static final String PHONE_SEPARATOR_WRITING = "|"; diff --git a/core/src/main/java/bisq/core/notifications/MobileNotificationService.java b/core/src/main/java/bisq/core/notifications/MobileNotificationService.java index 3b80e0f8940..e93845f0a44 100644 --- a/core/src/main/java/bisq/core/notifications/MobileNotificationService.java +++ b/core/src/main/java/bisq/core/notifications/MobileNotificationService.java @@ -29,6 +29,7 @@ import com.google.gson.Gson; import com.google.inject.Inject; +import com.google.inject.Singleton; import javax.inject.Named; @@ -54,6 +55,7 @@ import static com.google.common.base.Preconditions.checkNotNull; @Slf4j +@Singleton public class MobileNotificationService { // Used in Relay app to response of a success state. We won't want a code dependency just for that string so we keep it // duplicated in relay and here. Must not be changed. diff --git a/core/src/main/java/bisq/core/notifications/MobileNotificationValidator.java b/core/src/main/java/bisq/core/notifications/MobileNotificationValidator.java index 95eab45fff7..5cf6f2aeb51 100644 --- a/core/src/main/java/bisq/core/notifications/MobileNotificationValidator.java +++ b/core/src/main/java/bisq/core/notifications/MobileNotificationValidator.java @@ -18,10 +18,12 @@ package bisq.core.notifications; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; @Slf4j +@Singleton public class MobileNotificationValidator { @Inject public MobileNotificationValidator() { diff --git a/core/src/main/java/bisq/core/notifications/alerts/DisputeMsgEvents.java b/core/src/main/java/bisq/core/notifications/alerts/DisputeMsgEvents.java index e989317f770..fc9f21e0aaf 100644 --- a/core/src/main/java/bisq/core/notifications/alerts/DisputeMsgEvents.java +++ b/core/src/main/java/bisq/core/notifications/alerts/DisputeMsgEvents.java @@ -28,6 +28,7 @@ import bisq.network.p2p.P2PService; import javax.inject.Inject; +import javax.inject.Singleton; import javafx.collections.ListChangeListener; @@ -36,6 +37,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j +@Singleton public class DisputeMsgEvents { private final P2PService p2PService; private final MobileNotificationService mobileNotificationService; diff --git a/core/src/main/java/bisq/core/notifications/alerts/MyOfferTakenEvents.java b/core/src/main/java/bisq/core/notifications/alerts/MyOfferTakenEvents.java index 2ed8a7ebb7f..842dbadacc4 100644 --- a/core/src/main/java/bisq/core/notifications/alerts/MyOfferTakenEvents.java +++ b/core/src/main/java/bisq/core/notifications/alerts/MyOfferTakenEvents.java @@ -25,6 +25,7 @@ import bisq.core.offer.OpenOfferManager; import javax.inject.Inject; +import javax.inject.Singleton; import javafx.collections.ListChangeListener; @@ -33,6 +34,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j +@Singleton public class MyOfferTakenEvents { private final OpenOfferManager openOfferManager; private final MobileNotificationService mobileNotificationService; diff --git a/core/src/main/java/bisq/core/notifications/alerts/TradeEvents.java b/core/src/main/java/bisq/core/notifications/alerts/TradeEvents.java index 43f51ec80e5..adef19d1b1c 100644 --- a/core/src/main/java/bisq/core/notifications/alerts/TradeEvents.java +++ b/core/src/main/java/bisq/core/notifications/alerts/TradeEvents.java @@ -28,6 +28,7 @@ import bisq.common.crypto.PubKeyRing; import javax.inject.Inject; +import javax.inject.Singleton; import javafx.collections.ListChangeListener; @@ -38,6 +39,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j +@Singleton public class TradeEvents { private final PubKeyRing pubKeyRing; private final TradeManager tradeManager; diff --git a/core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java b/core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java index ac2a70a4321..fad6fc2a2f1 100644 --- a/core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java +++ b/core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java @@ -38,6 +38,7 @@ import org.bitcoinj.utils.Fiat; import javax.inject.Inject; +import javax.inject.Singleton; import java.util.List; import java.util.UUID; @@ -45,6 +46,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j +@Singleton public class MarketAlerts { private final OfferBookService offerBookService; private final MobileNotificationService mobileNotificationService; diff --git a/core/src/main/java/bisq/core/notifications/alerts/price/PriceAlert.java b/core/src/main/java/bisq/core/notifications/alerts/price/PriceAlert.java index c7b21aeabaf..f52a048f60e 100644 --- a/core/src/main/java/bisq/core/notifications/alerts/price/PriceAlert.java +++ b/core/src/main/java/bisq/core/notifications/alerts/price/PriceAlert.java @@ -33,10 +33,12 @@ import org.bitcoinj.utils.Fiat; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; @Slf4j +@Singleton public class PriceAlert { private final PriceFeedService priceFeedService; private final MobileNotificationService mobileNotificationService; diff --git a/core/src/main/java/bisq/core/payment/TradeLimits.java b/core/src/main/java/bisq/core/payment/TradeLimits.java index 78edb3a944b..62e825e3eee 100644 --- a/core/src/main/java/bisq/core/payment/TradeLimits.java +++ b/core/src/main/java/bisq/core/payment/TradeLimits.java @@ -26,6 +26,7 @@ import org.bitcoinj.core.Coin; import javax.inject.Inject; +import javax.inject.Singleton; import com.google.common.annotations.VisibleForTesting; @@ -35,6 +36,7 @@ import javax.annotation.Nullable; @Slf4j +@Singleton public class TradeLimits { @Nullable @Getter diff --git a/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java b/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java index 99dbf83ca77..3d0c065fc42 100644 --- a/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java +++ b/core/src/main/java/bisq/core/proto/network/CoreNetworkProtoResolver.java @@ -79,11 +79,13 @@ import bisq.common.proto.network.NetworkProtoResolver; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; // TODO Use ProtobufferException instead of ProtobufferRuntimeException @Slf4j +@Singleton public class CoreNetworkProtoResolver extends CoreProtoResolver implements NetworkProtoResolver { @Inject diff --git a/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java b/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java index 4e4e5114c90..96e7bc9775e 100644 --- a/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java +++ b/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java @@ -56,6 +56,7 @@ import javax.inject.Inject; import javax.inject.Named; +import javax.inject.Singleton; import java.io.File; @@ -63,6 +64,7 @@ // TODO Use ProtobufferException instead of ProtobufferRuntimeException @Slf4j +@Singleton public class CorePersistenceProtoResolver extends CoreProtoResolver implements PersistenceProtoResolver { private final Provider btcWalletService; private final NetworkProtoResolver networkProtoResolver; diff --git a/core/src/main/java/bisq/core/user/Preferences.java b/core/src/main/java/bisq/core/user/Preferences.java index d8023c56098..52e96b90dad 100644 --- a/core/src/main/java/bisq/core/user/Preferences.java +++ b/core/src/main/java/bisq/core/user/Preferences.java @@ -32,8 +32,8 @@ import bisq.core.locale.GlobalSettings; import bisq.core.locale.TradeCurrency; import bisq.core.payment.PaymentAccount; -import bisq.core.setup.CoreNetworkCapabilities; import bisq.core.payment.PaymentAccountUtil; +import bisq.core.setup.CoreNetworkCapabilities; import bisq.network.p2p.network.BridgeAddressProvider; @@ -43,6 +43,7 @@ import javax.inject.Inject; import javax.inject.Named; +import javax.inject.Singleton; import javafx.beans.property.BooleanProperty; import javafx.beans.property.LongProperty; @@ -74,6 +75,7 @@ import static com.google.common.base.Preconditions.checkNotNull; @Slf4j +@Singleton public final class Preferences implements PersistedDataHost, BridgeAddressProvider { private static final ArrayList BTC_MAIN_NET_EXPLORERS = new ArrayList<>(Arrays.asList( diff --git a/core/src/main/java/bisq/core/user/User.java b/core/src/main/java/bisq/core/user/User.java index 05b99b0fe21..af8637efaae 100644 --- a/core/src/main/java/bisq/core/user/User.java +++ b/core/src/main/java/bisq/core/user/User.java @@ -34,6 +34,7 @@ import bisq.common.storage.Storage; import javax.inject.Inject; +import javax.inject.Singleton; import javafx.beans.property.ObjectProperty; import javafx.beans.property.ReadOnlyObjectProperty; @@ -64,6 +65,7 @@ */ @Slf4j @AllArgsConstructor +@Singleton public class User implements PersistedDataHost { final private Storage storage; final private KeyRing keyRing; diff --git a/desktop/src/test/java/bisq/desktop/GuiceSetupTest.java b/desktop/src/test/java/bisq/desktop/GuiceSetupTest.java index 109df3e37be..68feb00202f 100644 --- a/desktop/src/test/java/bisq/desktop/GuiceSetupTest.java +++ b/desktop/src/test/java/bisq/desktop/GuiceSetupTest.java @@ -18,11 +18,38 @@ import bisq.core.app.AvoidStandbyModeService; import bisq.core.app.BisqEnvironment; +import bisq.core.app.P2PNetworkSetup; +import bisq.core.app.TorSetup; +import bisq.core.app.WalletAppSetup; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; +import bisq.core.network.p2p.seed.DefaultSeedNodeRepository; +import bisq.core.notifications.MobileMessageEncryption; +import bisq.core.notifications.MobileModel; +import bisq.core.notifications.MobileNotificationService; +import bisq.core.notifications.MobileNotificationValidator; +import bisq.core.notifications.alerts.MyOfferTakenEvents; +import bisq.core.notifications.alerts.TradeEvents; +import bisq.core.notifications.alerts.market.MarketAlerts; +import bisq.core.notifications.alerts.price.PriceAlert; +import bisq.core.payment.TradeLimits; +import bisq.core.proto.network.CoreNetworkProtoResolver; +import bisq.core.proto.persistable.CorePersistenceProtoResolver; +import bisq.core.user.Preferences; +import bisq.core.user.User; import bisq.core.util.BSFormatter; import bisq.core.util.BsqFormatter; +import bisq.network.p2p.network.BridgeAddressProvider; +import bisq.network.p2p.seed.SeedNodeRepository; + +import bisq.common.ClockWatcher; +import bisq.common.crypto.KeyRing; +import bisq.common.crypto.KeyStorage; +import bisq.common.proto.network.NetworkProtoResolver; +import bisq.common.proto.persistable.PersistenceProtoResolver; +import bisq.common.storage.CorruptedDatabaseFilesHandler; + import org.springframework.mock.env.MockPropertySource; import com.google.inject.Guice; @@ -32,6 +59,7 @@ import org.junit.Test; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; public class GuiceSetupTest { @@ -48,6 +76,7 @@ public void setUp() { @Test public void testGuiceSetup() { injector.getInstance(AvoidStandbyModeService.class); + // desktop module assertSingleton(OfferBook.class); assertSingleton(CachingViewLoader.class); assertSingleton(Navigation.class); @@ -65,9 +94,42 @@ public void testGuiceSetup() { assertSingleton(TransactionAwareTradableFactory.class); assertSingleton(DisplayedTransactionsFactory.class); assertSingleton(BondingViewUtils.class); + + // core module +// assertSingleton(BisqSetup.class); // this is a can of worms +// assertSingleton(DisputeMsgEvents.class); + assertSingleton(TorSetup.class); + assertSingleton(P2PNetworkSetup.class); + assertSingleton(WalletAppSetup.class); + assertSingleton(TradeLimits.class); + assertSingleton(KeyStorage.class); + assertSingleton(KeyRing.class); + assertSingleton(User.class); + assertSingleton(ClockWatcher.class); + assertSingleton(Preferences.class); + assertSingleton(BridgeAddressProvider.class); + assertSingleton(CorruptedDatabaseFilesHandler.class); + assertSingleton(AvoidStandbyModeService.class); + assertSingleton(DefaultSeedNodeRepository.class); + assertSingleton(SeedNodeRepository.class); + assertTrue(injector.getInstance(SeedNodeRepository.class) instanceof DefaultSeedNodeRepository); + assertSingleton(CoreNetworkProtoResolver.class); + assertSingleton(NetworkProtoResolver.class); + assertTrue(injector.getInstance(NetworkProtoResolver.class) instanceof CoreNetworkProtoResolver); + assertSingleton(PersistenceProtoResolver.class); + assertSingleton(CorePersistenceProtoResolver.class); + assertTrue(injector.getInstance(PersistenceProtoResolver.class) instanceof CorePersistenceProtoResolver); + assertSingleton(MobileMessageEncryption.class); + assertSingleton(MobileNotificationService.class); + assertSingleton(MobileNotificationValidator.class); + assertSingleton(MobileModel.class); + assertSingleton(MyOfferTakenEvents.class); + assertSingleton(TradeEvents.class); + assertSingleton(PriceAlert.class); + assertSingleton(MarketAlerts.class); } - private void assertSingleton(Class type) { + private void assertSingleton(Class type) { assertSame(injector.getInstance(type), injector.getInstance(type)); } }