From 60e850f44269fbb1688126d6a1261fe0ce6b8b30 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 19 Jan 2023 14:33:23 -0600 Subject: [PATCH] add mockable override option for testing purposes --- lib/services/coins/bitcoin/bitcoin_wallet.dart | 6 +++--- .../coins/bitcoincash/bitcoincash_wallet.dart | 8 +++----- .../coins/dogecoin/dogecoin_wallet.dart | 9 ++++----- .../coins/epiccash/epiccash_wallet.dart | 18 +++++++++--------- lib/services/coins/firo/firo_wallet.dart | 8 +++----- .../coins/litecoin/litecoin_wallet.dart | 8 +++----- lib/services/coins/monero/monero_wallet.dart | 6 ++++-- .../coins/namecoin/namecoin_wallet.dart | 8 +++----- lib/services/coins/particl/particl_wallet.dart | 8 +++----- lib/services/coins/wownero/wownero_wallet.dart | 5 +++-- lib/services/mixins/wallet_db.dart | 7 ++++--- lib/utilities/db_version_migration.dart | 2 +- test/pages/send_view/send_view_test.mocks.dart | 8 ++++---- .../coins/bitcoin/bitcoin_wallet_test.dart | 3 --- .../bitcoincash/bitcoincash_wallet_test.dart | 3 --- test/services/coins/manager_test.mocks.dart | 8 ++++---- .../managed_favorite_test.mocks.dart | 8 ++++---- .../table_view/table_view_row_test.mocks.dart | 8 ++++---- .../transaction_card_test.mocks.dart | 8 ++++---- test/widget_tests/wallet_card_test.mocks.dart | 8 ++++---- ...let_info_row_balance_future_test.mocks.dart | 8 ++++---- .../wallet_info_row_test.mocks.dart | 8 ++++---- 22 files changed, 75 insertions(+), 88 deletions(-) diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 3e6ae4819..21e4e44c2 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -10,6 +10,7 @@ import 'package:bs58check/bs58check.dart' as bs58check; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -659,8 +660,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2wpkhReceiveAddressArray, ...p2wpkhChangeAddressArray, @@ -1164,7 +1163,6 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await _prefs.init(); - await isarInit(); } // hack to add tx to txData before refresh completes @@ -1249,6 +1247,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1258,6 +1257,7 @@ class BitcoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 81d98ca19..9f7c6f22c 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -11,6 +11,7 @@ import 'package:bs58check/bs58check.dart' as bs58check; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -604,8 +605,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { p2shChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2pkhReceiveAddressArray, ...p2pkhChangeAddressArray, @@ -1094,7 +1093,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { } await _prefs.init(); - await isarInit(); } // hack to add tx to txData before refresh completes @@ -1206,6 +1204,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1215,6 +1214,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -1372,8 +1372,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await isarInit(); - await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index b4ae07a9b..c250a4abb 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -41,6 +41,8 @@ import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; +import '../../../db/main_db.dart'; + const int MINIMUM_CONFIRMATIONS = 1; const int DUST_LIMIT = 1000000; @@ -519,8 +521,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2pkhChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2pkhReceiveAddressArray, ...p2pkhChangeAddressArray, @@ -999,7 +999,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { } await _prefs.init(); - await isarInit(); } // hack to add tx to txData before refresh completes @@ -1084,6 +1083,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1093,6 +1093,7 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -1234,8 +1235,6 @@ class DogecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { final initialChangeAddressP2PKH = await _generateAddressForChain(1, 0, DerivePathType.bip44); - await isarInit(); - await db.putAddresses([ initialReceivingAddressP2PKH, initialChangeAddressP2PKH, diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 878f4672e..e50247bda 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -10,6 +10,7 @@ import 'package:http/http.dart'; import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; import 'package:stack_wallet_backup/generate_password.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/node_model.dart'; @@ -528,17 +529,20 @@ class EpicCashWallet extends CoinServiceAPI NodeModel? _epicNode; - EpicCashWallet( - {required String walletId, - required String walletName, - required Coin coin, - required SecureStorageInterface secureStore}) { + EpicCashWallet({ + required String walletId, + required String walletName, + required Coin coin, + required SecureStorageInterface secureStore, + MainDB? mockableOverride, + }) { _walletId = walletId; _walletName = walletName; _coin = coin; _secureStore = secureStore; initCache(walletId, coin); initEpicCashHive(walletId); + isarInit(mockableOverride: mockableOverride); Logging.instance.log("$walletName isolate length: ${isolates.length}", level: LogLevel.Info); @@ -969,7 +973,6 @@ class EpicCashWallet extends CoinServiceAPI Logging.instance.log("Opening existing ${coin.prettyName} wallet", level: LogLevel.Info); - await isarInit(); final config = await getRealConfig(); final password = await _secureStore.read(key: '${_walletId}_password'); @@ -1039,8 +1042,6 @@ class EpicCashWallet extends CoinServiceAPI String stringConfig = await getConfig(); String epicboxConfig = await getEpicBoxConfig(); - await isarInit(); - await _secureStore.write( key: '${_walletId}_mnemonic', value: mnemonicString); await _secureStore.write(key: '${_walletId}_config', value: stringConfig); @@ -1081,7 +1082,6 @@ class EpicCashWallet extends CoinServiceAPI epicUpdateChangeIndex(0), ]); - await isarInit(); final initialReceivingAddress = await _getReceivingAddressForIndex(0); await db.putAddress(initialReceivingAddress); diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index 15e408ccd..4a8994cff 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -11,6 +11,7 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; import 'package:lelantus/lelantus.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -1213,6 +1214,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1223,6 +1225,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { _secureStore = secureStore; initCache(walletId, coin); initFiroHive(walletId); + isarInit(mockableOverride: mockableOverride); Logging.instance.log("$walletName isolates length: ${isolates.length}", level: LogLevel.Info); @@ -1828,7 +1831,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(); } Future refreshIfThereIsNewData() async { @@ -2099,8 +2101,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { final initialReceivingAddress = await _generateAddressForChain(0, 0); final initialChangeAddress = await _generateAddressForChain(1, 0); - await isarInit(); - await db.putAddresses([ initialReceivingAddress, initialChangeAddress, @@ -4292,8 +4292,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive { Logging.instance .log("PROCESSORS ${Platform.numberOfProcessors}", level: LogLevel.Info); try { - await isarInit(); - final latestSetId = await getLatestSetId(); final setDataMap = getSetDataMap(latestSetId); final usedSerialNumbers = getUsedCoinSerials(); diff --git a/lib/services/coins/litecoin/litecoin_wallet.dart b/lib/services/coins/litecoin/litecoin_wallet.dart index f3d2bf44a..72a14649b 100644 --- a/lib/services/coins/litecoin/litecoin_wallet.dart +++ b/lib/services/coins/litecoin/litecoin_wallet.dart @@ -11,6 +11,7 @@ import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -677,8 +678,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2wpkhReceiveAddressArray, ...p2wpkhChangeAddressArray, @@ -1182,7 +1181,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(); } // hack to add tx to txData before refresh completes @@ -1267,6 +1265,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1276,6 +1275,7 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -1473,8 +1473,6 @@ class LitecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await isarInit(); - await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); diff --git a/lib/services/coins/monero/monero_wallet.dart b/lib/services/coins/monero/monero_wallet.dart index 689f05894..40055e953 100644 --- a/lib/services/coins/monero/monero_wallet.dart +++ b/lib/services/coins/monero/monero_wallet.dart @@ -23,6 +23,7 @@ import 'package:flutter_libmonero/monero/monero.dart'; import 'package:flutter_libmonero/view_model/send/output.dart' as monero_output; import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; @@ -83,6 +84,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { required Coin coin, required SecureStorageInterface secureStorage, Prefs? prefs, + MainDB? mockableOverride, }) { _walletId = walletId; _walletName = walletName; @@ -90,6 +92,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { _secureStorage = secureStorage; _prefs = prefs ?? Prefs.instance; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -269,7 +272,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { keysStorage = KeyService(_secureStorage); await _prefs.init(); - await isarInit(); + // final data = // DB.instance.get(boxName: walletId, key: "latest_tx_model") // as TransactionData?; @@ -389,7 +392,6 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); // final initialChangeAddress = await _generateAddressForChain(1, 0); - await isarInit(); await db.putAddress(initialReceivingAddress); diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 25ee0c590..fd7515ebc 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -11,6 +11,7 @@ import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -667,8 +668,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2wpkhReceiveAddressArray, ...p2wpkhChangeAddressArray, @@ -1171,7 +1170,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(); } // hack to add tx to txData before refresh completes @@ -1256,6 +1254,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1265,6 +1264,7 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -1450,8 +1450,6 @@ class NamecoinWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip49), ]); - await isarInit(); - await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); diff --git a/lib/services/coins/particl/particl_wallet.dart b/lib/services/coins/particl/particl_wallet.dart index 30be6f966..b7b8197f6 100644 --- a/lib/services/coins/particl/particl_wallet.dart +++ b/lib/services/coins/particl/particl_wallet.dart @@ -11,6 +11,7 @@ import 'package:crypto/crypto.dart'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/models/balance.dart'; @@ -602,8 +603,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { p2wpkhChangeAddressArray.add(address); } - await isarInit(); - await db.putAddresses([ ...p2wpkhReceiveAddressArray, ...p2wpkhChangeAddressArray, @@ -1101,7 +1100,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { "Attempted to initialize an existing wallet using an unknown wallet ID!"); } await _prefs.init(); - await isarInit(); } // TODO make sure this copied implementation from bitcoin_wallet.dart applies for particl just as well--or import it @@ -1187,6 +1185,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { required CachedElectrumX cachedClient, required TransactionNotificationTracker tracker, required SecureStorageInterface secureStore, + MainDB? mockableOverride, }) { txTracker = tracker; _walletId = walletId; @@ -1196,6 +1195,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { _cachedElectrumXClient = cachedClient; _secureStore = secureStore; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -1364,8 +1364,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB { _generateAddressForChain(1, 0, DerivePathType.bip44), ]); - await isarInit(); - await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 2d031b290..d6b8f9396 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -25,6 +25,7 @@ import 'package:flutter_libmonero/view_model/send/output.dart' import 'package:flutter_libmonero/wownero/wownero.dart'; import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; +import 'package:stackwallet/db/main_db.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/models/balance.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; @@ -85,6 +86,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { required Coin coin, required SecureStorageInterface secureStorage, Prefs? prefs, + MainDB? mockableOverride, }) { _walletId = walletId; _walletName = walletName; @@ -92,6 +94,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { _secureStorage = secureStorage; _prefs = prefs ?? Prefs.instance; initCache(walletId, coin); + isarInit(mockableOverride: mockableOverride); } @override @@ -293,7 +296,6 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { keysStorage = KeyService(_secureStorage); await _prefs.init(); - await isarInit(); String? password; try { @@ -397,7 +399,6 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB { // Generate and add addresses to relevant arrays final initialReceivingAddress = await _generateAddressForChain(0, 0); // final initialChangeAddress = await _generateAddressForChain(1, 0); - await isarInit(); await db.putAddress(initialReceivingAddress); diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart index 5d442d56f..11f1619f3 100644 --- a/lib/services/mixins/wallet_db.dart +++ b/lib/services/mixins/wallet_db.dart @@ -4,10 +4,11 @@ import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:tuple/tuple.dart'; mixin WalletDB { - MainDB get db => MainDB.instance; + MainDB? _db; + MainDB get db => _db!; - Future isarInit() async { - await db.isarInit(); + void isarInit({MainDB? mockableOverride}) async { + _db = mockableOverride ?? MainDB.instance; } Future addNewTransactionData( diff --git a/lib/utilities/db_version_migration.dart b/lib/utilities/db_version_migration.dart index 25eaf86d9..372a37997 100644 --- a/lib/utilities/db_version_migration.dart +++ b/lib/utilities/db_version_migration.dart @@ -403,7 +403,7 @@ class DbVersionMigrator with WalletDB { _parseTransactions(txnsLelantus, walletId, true, newAddresses)); // store newly parsed data in isar - await isarInit(); + isarInit(); await db.isar.writeTxn(() async { await db.isar.addresses.putAll(newAddresses); }); diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index 5cc3a41b7..b16a2a675 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -1558,14 +1558,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i21.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit() => (super.noSuchMethod( + void isarInit({_i13.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); + returnValueForMissingStub: null, + ); @override _i17.Future addNewTransactionData( List< diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.dart index 3fc19a1fe..33f40659c 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.dart @@ -3,7 +3,6 @@ import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; -import 'package:isar/isar.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; @@ -23,8 +22,6 @@ import 'bitcoin_wallet_test_parameters.dart'; @GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) void main() async { - await Isar.initializeIsarCore(download: true); - group("bitcoin constants", () { test("bitcoin minimum confirmations", () async { expect(MINIMUM_CONFIRMATIONS, 1); diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart index 258693bcb..464b5fb58 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.dart @@ -2,7 +2,6 @@ import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; -import 'package:isar/isar.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; @@ -21,8 +20,6 @@ import 'bitcoincash_wallet_test_parameters.dart'; @GenerateMocks([ElectrumX, CachedElectrumX, TransactionNotificationTracker]) void main() async { - await Isar.initializeIsarCore(download: true); - group("bitcoincash constants", () { test("bitcoincash minimum confirmations", () async { expect(MINIMUM_CONFIRMATIONS, 1); diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index f3a321238..7944c0767 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -978,14 +978,14 @@ class MockFiroWallet extends _i1.Mock implements _i9.FiroWallet { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - _i10.Future isarInit() => (super.noSuchMethod( + void isarInit({_i7.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i10.Future.value(), - returnValueForMissingStub: _i10.Future.value(), - ) as _i10.Future); + returnValueForMissingStub: null, + ); @override _i10.Future addNewTransactionData( List< diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index 8217b6d42..961777add 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -1348,14 +1348,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit() => (super.noSuchMethod( + void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); + returnValueForMissingStub: null, + ); @override _i17.Future addNewTransactionData( List< diff --git a/test/widget_tests/table_view/table_view_row_test.mocks.dart b/test/widget_tests/table_view/table_view_row_test.mocks.dart index 7c3b50370..8639ec3f6 100644 --- a/test/widget_tests/table_view/table_view_row_test.mocks.dart +++ b/test/widget_tests/table_view/table_view_row_test.mocks.dart @@ -1333,14 +1333,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i19.BitcoinWallet { returnValueForMissingStub: _i16.Future.value(), ) as _i16.Future); @override - _i16.Future isarInit() => (super.noSuchMethod( + void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i16.Future.value(), - returnValueForMissingStub: _i16.Future.value(), - ) as _i16.Future); + returnValueForMissingStub: null, + ); @override _i16.Future addNewTransactionData( List< diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 554acc38a..915942570 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -1891,14 +1891,14 @@ class MockFiroWallet extends _i1.Mock implements _i22.FiroWallet { returnValueForMissingStub: _i18.Future.value(), ) as _i18.Future); @override - _i18.Future isarInit() => (super.noSuchMethod( + void isarInit({_i13.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i18.Future.value(), - returnValueForMissingStub: _i18.Future.value(), - ) as _i18.Future); + returnValueForMissingStub: null, + ); @override _i18.Future addNewTransactionData( List< diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index 8ae43ff12..b802b64dd 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -1096,14 +1096,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i18.BitcoinWallet { returnValueForMissingStub: _i15.Future.value(), ) as _i15.Future); @override - _i15.Future isarInit() => (super.noSuchMethod( + void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i15.Future.value(), - returnValueForMissingStub: _i15.Future.value(), - ) as _i15.Future); + returnValueForMissingStub: null, + ); @override _i15.Future addNewTransactionData( List< diff --git a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart index a7acaf138..8f37d1879 100644 --- a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart +++ b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart @@ -1347,14 +1347,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit() => (super.noSuchMethod( + void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); + returnValueForMissingStub: null, + ); @override _i17.Future addNewTransactionData( List< diff --git a/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart b/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart index b5179f019..e72c999cb 100644 --- a/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart +++ b/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart @@ -1347,14 +1347,14 @@ class MockBitcoinWallet extends _i1.Mock implements _i20.BitcoinWallet { returnValueForMissingStub: _i17.Future.value(), ) as _i17.Future); @override - _i17.Future isarInit() => (super.noSuchMethod( + void isarInit({_i12.MainDB? mockableOverride}) => super.noSuchMethod( Invocation.method( #isarInit, [], + {#mockableOverride: mockableOverride}, ), - returnValue: _i17.Future.value(), - returnValueForMissingStub: _i17.Future.value(), - ) as _i17.Future); + returnValueForMissingStub: null, + ); @override _i17.Future addNewTransactionData( List<