diff --git a/test/services/coins/particl/particl_history_sample_data.dart b/test/services/coins/particl/particl_history_sample_data.dart index b2e5f9fa7..620453178 100644 --- a/test/services/coins/particl/particl_history_sample_data.dart +++ b/test/services/coins/particl/particl_history_sample_data.dart @@ -1,5 +1,3 @@ -// TODO these test vectors are valid for Namecoin: update for Particl - final Map> historyBatchArgs0 = { "k_0_0": ["29e9e6410954dea9e527a0d2cac5de4dea5fb600b719badff90d6d43518d3ed8"], "k_0_1": ["9b56ab30c7bef0e1eaa10a632c8e2dcdd11b2158d7a917c03d62936afd0015fc"], diff --git a/test/services/coins/particl/particl_wallet_test.dart b/test/services/coins/particl/particl_wallet_test.dart index 844b61461..048c8eeb1 100644 --- a/test/services/coins/particl/particl_wallet_test.dart +++ b/test/services/coins/particl/particl_wallet_test.dart @@ -1,3 +1,6 @@ +import 'dart:convert'; + +import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hive/hive.dart'; import 'package:hive_test/hive_test.dart'; @@ -11,6 +14,7 @@ import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; +import 'package:tuple/tuple.dart'; import 'particl_history_sample_data.dart'; import 'particl_wallet_test.mocks.dart'; @@ -281,215 +285,215 @@ void main() { // }); // }); - // group("basic getters, setters, and functions", () { - // final testWalletId = "NMCtestWalletID"; - // final testWalletName = "NMCWallet"; + group("basic getters, setters, and functions", () { + final testWalletId = "ParticltestWalletID"; + final testWalletName = "ParticlWallet"; - // MockElectrumX? client; - // MockCachedElectrumX? cachedClient; - // MockPriceAPI? priceAPI; - // late FakeSecureStorage secureStore; - // MockTransactionNotificationTracker? tracker; + MockElectrumX? client; + MockCachedElectrumX? cachedClient; + MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; + MockTransactionNotificationTracker? tracker; - // NamecoinWallet? nmc; + ParticlWallet? part; - // setUp(() async { - // client = MockElectrumX(); - // cachedClient = MockCachedElectrumX(); - // priceAPI = MockPriceAPI(); - // secureStore = FakeSecureStorage(); - // tracker = MockTransactionNotificationTracker(); + setUp(() async { + client = MockElectrumX(); + cachedClient = MockCachedElectrumX(); + priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); + tracker = MockTransactionNotificationTracker(); - // nmc = NamecoinWallet( - // walletId: testWalletId, - // walletName: testWalletName, - // coin: Coin.particl, - // client: client!, - // cachedClient: cachedClient!, - // tracker: tracker!, - // priceAPI: priceAPI, - // secureStore: secureStore, - // ); - // }); + part = ParticlWallet( + walletId: testWalletId, + walletName: testWalletName, + coin: Coin.particl, + client: client!, + cachedClient: cachedClient!, + tracker: tracker!, + priceAPI: priceAPI, + secureStore: secureStore, + ); + }); - // test("get networkType main", () async { - // expect(Coin.particl, Coin.particl); - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); + test("get networkType main", () async { + expect(Coin.particl, Coin.particl); + expect(secureStore.interactions, 0); + verifyNoMoreInteractions(client); + verifyNoMoreInteractions(cachedClient); + verifyNoMoreInteractions(priceAPI); + }); - // test("get networkType test", () async { - // nmc = NamecoinWallet( - // walletId: testWalletId, - // walletName: testWalletName, - // coin: Coin.particl, - // client: client!, - // cachedClient: cachedClient!, - // tracker: tracker!, - // priceAPI: priceAPI, - // secureStore: secureStore, - // ); - // expect(Coin.particl, Coin.particl); - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); + test("get networkType test", () async { + part = ParticlWallet( + walletId: testWalletId, + walletName: testWalletName, + coin: Coin.particl, + client: client!, + cachedClient: cachedClient!, + tracker: tracker!, + priceAPI: priceAPI, + secureStore: secureStore, + ); + expect(Coin.particl, Coin.particl); + expect(secureStore.interactions, 0); + verifyNoMoreInteractions(client); + verifyNoMoreInteractions(cachedClient); + verifyNoMoreInteractions(priceAPI); + }); - // test("get cryptoCurrency", () async { - // expect(Coin.particl, Coin.particl); - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); + test("get cryptoCurrency", () async { + expect(Coin.particl, Coin.particl); + expect(secureStore.interactions, 0); + verifyNoMoreInteractions(client); + verifyNoMoreInteractions(cachedClient); + verifyNoMoreInteractions(priceAPI); + }); - // test("get coinName", () async { - // expect(Coin.particl, Coin.particl); - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); + test("get coinName", () async { + expect(Coin.particl, Coin.particl); + expect(secureStore.interactions, 0); + verifyNoMoreInteractions(client); + verifyNoMoreInteractions(cachedClient); + verifyNoMoreInteractions(priceAPI); + }); - // test("get coinTicker", () async { - // expect(Coin.particl, Coin.particl); - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); + test("get coinTicker", () async { + expect(Coin.particl, Coin.particl); + expect(secureStore.interactions, 0); + verifyNoMoreInteractions(client); + verifyNoMoreInteractions(cachedClient); + verifyNoMoreInteractions(priceAPI); + }); - // test("get and set walletName", () async { - // expect(Coin.particl, Coin.particl); - // nmc?.walletName = "new name"; - // expect(nmc?.walletName, "new name"); - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); + test("get and set walletName", () async { + expect(Coin.particl, Coin.particl); + part?.walletName = "new name"; + expect(part?.walletName, "new name"); + expect(secureStore.interactions, 0); + verifyNoMoreInteractions(client); + verifyNoMoreInteractions(cachedClient); + verifyNoMoreInteractions(priceAPI); + }); - // test("estimateTxFee", () async { - // expect(nmc?.estimateTxFee(vSize: 356, feeRatePerKB: 1), 356); - // expect(nmc?.estimateTxFee(vSize: 356, feeRatePerKB: 900), 356); - // expect(nmc?.estimateTxFee(vSize: 356, feeRatePerKB: 999), 356); - // expect(nmc?.estimateTxFee(vSize: 356, feeRatePerKB: 1000), 356); - // expect(nmc?.estimateTxFee(vSize: 356, feeRatePerKB: 1001), 712); - // expect(nmc?.estimateTxFee(vSize: 356, feeRatePerKB: 1699), 712); - // expect(nmc?.estimateTxFee(vSize: 356, feeRatePerKB: 2000), 712); - // expect(nmc?.estimateTxFee(vSize: 356, feeRatePerKB: 12345), 4628); - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); + // test("estimateTxFee", () async { + // expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1), 356); + // expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 900), 356); + // expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 999), 356); + // expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1000), 356); + // expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1001), 712); + // expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1699), 712); + // expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 2000), 712); + // expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 12345), 4628); + // expect(secureStore.interactions, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); - // test("get fees succeeds", () async { - // when(client?.ping()).thenAnswer((_) async => true); - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.estimateFee(blocks: 1)) - // .thenAnswer((realInvocation) async => Decimal.zero); - // when(client?.estimateFee(blocks: 5)) - // .thenAnswer((realInvocation) async => Decimal.one); - // when(client?.estimateFee(blocks: 20)) - // .thenAnswer((realInvocation) async => Decimal.ten); + // test("get fees succeeds", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.estimateFee(blocks: 1)) + // .thenAnswer((realInvocation) async => Decimal.zero); + // when(client?.estimateFee(blocks: 5)) + // .thenAnswer((realInvocation) async => Decimal.one); + // when(client?.estimateFee(blocks: 20)) + // .thenAnswer((realInvocation) async => Decimal.ten); + // + // final fees = await part?.fees; + // expect(fees, isA()); + // expect(fees?.slow, 1000000000); + // expect(fees?.medium, 100000000); + // expect(fees?.fast, 0); + // + // verify(client?.estimateFee(blocks: 1)).called(1); + // verify(client?.estimateFee(blocks: 5)).called(1); + // verify(client?.estimateFee(blocks: 20)).called(1); + // expect(secureStore.interactions, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); - // final fees = await nmc?.fees; - // expect(fees, isA()); - // expect(fees?.slow, 1000000000); - // expect(fees?.medium, 100000000); - // expect(fees?.fast, 0); + // test("get fees fails", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.estimateFee(blocks: 1)) + // .thenAnswer((realInvocation) async => Decimal.zero); + // when(client?.estimateFee(blocks: 5)) + // .thenAnswer((realInvocation) async => Decimal.one); + // when(client?.estimateFee(blocks: 20)) + // .thenThrow(Exception("some exception")); + // + // bool didThrow = false; + // try { + // await part?.fees; + // } catch (_) { + // didThrow = true; + // } + // + // expect(didThrow, true); + // + // verify(client?.estimateFee(blocks: 1)).called(1); + // verify(client?.estimateFee(blocks: 5)).called(1); + // verify(client?.estimateFee(blocks: 20)).called(1); + // expect(secureStore.interactions, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); - // verify(client?.estimateFee(blocks: 1)).called(1); - // verify(client?.estimateFee(blocks: 5)).called(1); - // verify(client?.estimateFee(blocks: 20)).called(1); - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("get fees fails", () async { - // when(client?.ping()).thenAnswer((_) async => true); - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.estimateFee(blocks: 1)) - // .thenAnswer((realInvocation) async => Decimal.zero); - // when(client?.estimateFee(blocks: 5)) - // .thenAnswer((realInvocation) async => Decimal.one); - // when(client?.estimateFee(blocks: 20)) - // .thenThrow(Exception("some exception")); - - // bool didThrow = false; - // try { - // await nmc?.fees; - // } catch (_) { - // didThrow = true; - // } - - // expect(didThrow, true); - - // verify(client?.estimateFee(blocks: 1)).called(1); - // verify(client?.estimateFee(blocks: 5)).called(1); - // verify(client?.estimateFee(blocks: 20)).called(1); - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // // test("get maxFee", () async { - // // when(client?.ping()).thenAnswer((_) async => true); - // // when(client?.getServerFeatures()).thenAnswer((_) async => { - // // "hosts": {}, - // // "pruning": null, - // // "server_version": "Unit tests", - // // "protocol_min": "1.4", - // // "protocol_max": "1.4.2", - // // "genesis_hash": GENESIS_HASH_TESTNET, - // // "hash_function": "sha256", - // // "services": [] - // // }); - // // when(client?.estimateFee(blocks: 20)) - // // .thenAnswer((realInvocation) async => Decimal.zero); - // // when(client?.estimateFee(blocks: 5)) - // // .thenAnswer((realInvocation) async => Decimal.one); - // // when(client?.estimateFee(blocks: 1)) - // // .thenAnswer((realInvocation) async => Decimal.ten); - // // - // // final maxFee = await nmc?.maxFee; - // // expect(maxFee, 1000000000); - // // - // // verify(client?.estimateFee(blocks: 1)).called(1); - // // verify(client?.estimateFee(blocks: 5)).called(1); - // // verify(client?.estimateFee(blocks: 20)).called(1); - // // expect(secureStore.interactions, 0); - // // verifyNoMoreInteractions(client); - // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(tracker); - // // verifyNoMoreInteractions(priceAPI); - // // }); - // }); + // test("get maxFee", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_TESTNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.estimateFee(blocks: 20)) + // .thenAnswer((realInvocation) async => Decimal.zero); + // when(client?.estimateFee(blocks: 5)) + // .thenAnswer((realInvocation) async => Decimal.one); + // when(client?.estimateFee(blocks: 1)) + // .thenAnswer((realInvocation) async => Decimal.ten); + // + // final maxFee = await nmc?.maxFee; + // expect(maxFee, 1000000000); + // + // verify(client?.estimateFee(blocks: 1)).called(1); + // verify(client?.estimateFee(blocks: 5)).called(1); + // verify(client?.estimateFee(blocks: 20)).called(1); + // expect(secureStore.interactions, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // verifyNoMoreInteractions(priceAPI); + // }); + }); group("Particl service class functions that depend on shared storage", () { const testWalletId = "ParticltestWalletID"; @@ -866,486 +870,461 @@ void main() { verifyNoMoreInteractions(priceAPI); }); - // test("fullRescan succeeds", () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs1)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs2)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs3)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs4)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs5)) - // .thenAnswer((_) async => historyBatchResponse); - // when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - // .thenAnswer((realInvocation) async {}); - // - // when(client?.getBatchHistory(args: { - // "0": [ - // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // - // when(client?.getBatchHistory(args: { - // "0": [ - // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // - // when(client?.getBatchHistory(args: { - // "0": [ - // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // - // when(client?.getBatchHistory(args: { - // "0": [ - // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // when(client?.getBatchHistory(args: { - // "0": [ - // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // when(client?.getBatchHistory(args: { - // "0": [ - // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // - // final wallet = await Hive.openBox(testWalletId); - // - // // restore so we have something to rescan - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - // - // // fetch valid wallet data - // final preReceivingAddressesP2PKH = - // await wallet.get('receivingAddressesP2PKH'); - // final preReceivingAddressesP2SH = - // await wallet.get('receivingAddressesP2SH'); - // final preReceivingAddressesP2WPKH = - // await wallet.get('receivingAddressesP2WPKH'); - // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - // final preChangeAddressesP2WPKH = - // await wallet.get('changeAddressesP2WPKH'); - // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); - // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - // final preUtxoData = await wallet.get('latest_utxo_model'); - // final preReceiveDerivationsStringP2PKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2PKH"); - // final preChangeDerivationsStringP2PKH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - // final preReceiveDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - // final preChangeDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - // final preReceiveDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2WPKH"); - // final preChangeDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_changeDerivationsP2WPKH"); - // - // // destroy the data that the rescan will fix - // await wallet.put( - // 'receivingAddressesP2PKH', ["some address", "some other address"]); - // await wallet.put( - // 'receivingAddressesP2SH', ["some address", "some other address"]); - // await wallet.put( - // 'receivingAddressesP2WPKH', ["some address", "some other address"]); - // await wallet - // .put('changeAddressesP2PKH', ["some address", "some other address"]); - // await wallet - // .put('changeAddressesP2SH', ["some address", "some other address"]); - // await wallet - // .put('changeAddressesP2WPKH', ["some address", "some other address"]); - // await wallet.put('receivingIndexP2PKH', 123); - // await wallet.put('receivingIndexP2SH', 123); - // await wallet.put('receivingIndexP2WPKH', 123); - // await wallet.put('changeIndexP2PKH', 123); - // await wallet.put('changeIndexP2SH', 123); - // await wallet.put('changeIndexP2WPKH', 123); - // await secureStore.write( - // key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); - // await secureStore.write( - // key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); - // await secureStore.write( - // key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); - // await secureStore.write( - // key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); - // await secureStore.write( - // key: "${testWalletId}_receiveDerivationsP2WPKH", value: "{}"); - // await secureStore.write( - // key: "${testWalletId}_changeDerivationsP2WPKH", value: "{}"); - // - // bool hasThrown = false; - // try { - // await nmc?.fullRescan(2, 1000); - // } catch (_) { - // hasThrown = true; - // } - // expect(hasThrown, false); - // - // // fetch wallet data again - // final receivingAddressesP2PKH = - // await wallet.get('receivingAddressesP2PKH'); - // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); - // final receivingAddressesP2WPKH = - // await wallet.get('receivingAddressesP2WPKH'); - // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); - // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); - // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - // final utxoData = await wallet.get('latest_utxo_model'); - // final receiveDerivationsStringP2PKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2PKH"); - // final changeDerivationsStringP2PKH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - // final receiveDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - // final changeDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - // final receiveDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2WPKH"); - // final changeDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_changeDerivationsP2WPKH"); - // - // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); - // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); - // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - // expect(preChangeAddressesP2SH, changeAddressesP2SH); - // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); - // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - // expect(preReceivingIndexP2SH, receivingIndexP2SH); - // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); - // expect(preChangeIndexP2PKH, changeIndexP2PKH); - // expect(preChangeIndexP2SH, changeIndexP2SH); - // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); - // expect(preUtxoData, utxoData); - // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); - // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); - // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); - // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); - // - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - // ] - // })).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - // ] - // })).called(2); - // - // verify(client?.getBatchHistory(args: { - // "0": [ - // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - // ] - // })).called(2); - // - // verify(client?.getBatchHistory(args: { - // "0": [ - // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - // ] - // })).called(2); - // - // verify(client?.getBatchHistory(args: { - // "0": [ - // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - // ] - // })).called(2); - // - // verify(client?.getBatchHistory(args: { - // "0": [ - // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - // ] - // })).called(2); - // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - // .called(1); + test("fullRescan succeeds", () async { + when(client?.getServerFeatures()).thenAnswer((_) async => { + "hosts": {}, + "pruning": null, + "server_version": "Unit tests", + "protocol_min": "1.4", + "protocol_max": "1.4.2", + "genesis_hash": GENESIS_HASH_MAINNET, + "hash_function": "sha256", + "services": [] + }); + when(client?.getBatchHistory(args: historyBatchArgs0)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs1)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs2)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs3)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs4)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs5)) + .thenAnswer((_) async => historyBatchResponse); + when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + .thenAnswer((realInvocation) async {}); - // for (final arg in dynamicArgValues) { - // final map = Map>.from(arg as Map); - // Map argCount = {}; - // - // // verify(client?.getBatchHistory(args: map)).called(1); - // // expect(activeScriptHashes.contains(map.values.first.first as String), - // // true); - // } + when(client?.getBatchHistory(args: { + "0": [ + "8ba03c2c46ed4980fa1e4c84cbceeb2d5e1371a7ccbaf5f3d69c5114161a2247" + ] + })).thenAnswer((realInvocation) async => {"0": []}); - // Map argCount = {}; - // - // for (final arg in dynamicArgValues) { - // final map = Map>.from(arg as Map); - // - // final str = jsonEncode(map); - // - // if (argCount[str] == null) { - // argCount[str] = 1; - // } else { - // argCount[str] = argCount[str]! + 1; - // } - // } - // - // argCount.forEach((key, value) => print("arg: $key\ncount: $value")); + when(client?.getBatchHistory(args: { + "0": [ + "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" + ] + })).thenAnswer((realInvocation) async => {"0": []}); - // expect(secureStore.writes, 25); - // expect(secureStore.reads, 32); - // expect(secureStore.deletes, 6); - // - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); + when(client?.getBatchHistory(args: { + "0": [ + "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" + ] + })).thenAnswer((realInvocation) async => {"0": []}); - // test("fullRescan fails", () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs1)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs2)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs3)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs4)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs5)) - // .thenAnswer((_) async => historyBatchResponse); - // - // when(client?.getBatchHistory(args: { - // "0": [ - // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // - // when(client?.getBatchHistory(args: { - // "0": [ - // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // - // when(client?.getBatchHistory(args: { - // "0": [ - // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // - // when(client?.getBatchHistory(args: { - // "0": [ - // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // - // when(client?.getBatchHistory(args: { - // "0": [ - // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // - // when(client?.getBatchHistory(args: { - // "0": [ - // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // - // when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - // .thenAnswer((realInvocation) async {}); - // - // final wallet = await Hive.openBox(testWalletId); - // - // // restore so we have something to rescan - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - // - // // fetch wallet data - // final preReceivingAddressesP2PKH = - // await wallet.get('receivingAddressesP2PKH'); - // final preReceivingAddressesP2SH = - // await wallet.get('receivingAddressesP2SH'); - // final preReceivingAddressesP2WPKH = - // await wallet.get('receivingAddressesP2WPKH'); - // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - // final preChangeAddressesP2WPKH = - // await wallet.get('changeAddressesP2WPKH'); - // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); - // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - // final preUtxoData = await wallet.get('latest_utxo_model'); - // final preReceiveDerivationsStringP2PKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2PKH"); - // final preChangeDerivationsStringP2PKH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - // final preReceiveDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - // final preChangeDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - // final preReceiveDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2WPKH"); - // final preChangeDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_changeDerivationsP2WPKH"); - // - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenThrow(Exception("fake exception")); - // - // bool hasThrown = false; - // try { - // await nmc?.fullRescan(2, 1000); - // } catch (_) { - // hasThrown = true; - // } - // expect(hasThrown, true); - // - // // fetch wallet data again - // final receivingAddressesP2PKH = - // await wallet.get('receivingAddressesP2PKH'); - // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); - // final receivingAddressesP2WPKH = - // await wallet.get('receivingAddressesP2WPKH'); - // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); - // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); - // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - // final utxoData = await wallet.get('latest_utxo_model'); - // final receiveDerivationsStringP2PKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2PKH"); - // final changeDerivationsStringP2PKH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - // final receiveDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - // final changeDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - // final receiveDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2WPKH"); - // final changeDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_changeDerivationsP2WPKH"); - // - // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); - // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); - // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - // expect(preChangeAddressesP2SH, changeAddressesP2SH); - // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); - // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - // expect(preReceivingIndexP2SH, receivingIndexP2SH); - // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); - // expect(preChangeIndexP2PKH, changeIndexP2PKH); - // expect(preChangeIndexP2SH, changeIndexP2SH); - // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); - // expect(preUtxoData, utxoData); - // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); - // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); - // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); - // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); - // - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); - // - // verify(client?.getBatchHistory(args: { - // "0": [ - // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - // ] - // })).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - // ] - // })).called(1); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - // ] - // })).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - // ] - // })).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - // ] - // })).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - // ] - // })).called(2); - // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - // .called(1); - // - // expect(secureStore.writes, 19); - // expect(secureStore.reads, 32); - // expect(secureStore.deletes, 12); - // - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); + when(client?.getBatchHistory(args: { + "0": [ + "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" + ] + })).thenAnswer((realInvocation) async => {"0": []}); + when(client?.getBatchHistory(args: { + "0": [ + "9b56ab30c7bef0e1eaa10a632c8e2dcdd11b2158d7a917c03d62936afd0015fc" + ] + })).thenAnswer((realInvocation) async => {"0": []}); + when(client?.getBatchHistory(args: { + "0": [ + "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" + ] + })).thenAnswer((realInvocation) async => {"0": []}); + + final wallet = await Hive.openBox(testWalletId); + + // restore so we have something to rescan + await part?.recoverFromMnemonic( + mnemonic: TEST_MNEMONIC, + maxUnusedAddressGap: 2, + maxNumberOfIndexesToCheck: 1000, + height: 4000); + + // fetch valid wallet data + final preReceivingAddressesP2PKH = + await wallet.get('receivingAddressesP2PKH'); + final preReceivingAddressesP2SH = + await wallet.get('receivingAddressesP2SH'); + final preReceivingAddressesP2WPKH = + await wallet.get('receivingAddressesP2WPKH'); + final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + final preChangeAddressesP2WPKH = + await wallet.get('changeAddressesP2WPKH'); + final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); + final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + final preUtxoData = await wallet.get('latest_utxo_model'); + final preReceiveDerivationsStringP2PKH = await secureStore.read( + key: "${testWalletId}_receiveDerivationsP2PKH"); + final preChangeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + final preReceiveDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + final preChangeDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + final preReceiveDerivationsStringP2WPKH = await secureStore.read( + key: "${testWalletId}_receiveDerivationsP2WPKH"); + final preChangeDerivationsStringP2WPKH = await secureStore.read( + key: "${testWalletId}_changeDerivationsP2WPKH"); + + // destroy the data that the rescan will fix + await wallet.put( + 'receivingAddressesP2PKH', ["some address", "some other address"]); + await wallet.put( + 'receivingAddressesP2SH', ["some address", "some other address"]); + await wallet.put( + 'receivingAddressesP2WPKH', ["some address", "some other address"]); + await wallet + .put('changeAddressesP2PKH', ["some address", "some other address"]); + await wallet + .put('changeAddressesP2SH', ["some address", "some other address"]); + await wallet + .put('changeAddressesP2WPKH', ["some address", "some other address"]); + await wallet.put('receivingIndexP2PKH', 123); + await wallet.put('receivingIndexP2SH', 123); + await wallet.put('receivingIndexP2WPKH', 123); + await wallet.put('changeIndexP2PKH', 123); + await wallet.put('changeIndexP2SH', 123); + await wallet.put('changeIndexP2WPKH', 123); + await secureStore.write( + key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); + await secureStore.write( + key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); + await secureStore.write( + key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); + await secureStore.write( + key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); + await secureStore.write( + key: "${testWalletId}_receiveDerivationsP2WPKH", value: "{}"); + await secureStore.write( + key: "${testWalletId}_changeDerivationsP2WPKH", value: "{}"); + + bool hasThrown = false; + try { + await part?.fullRescan(2, 1000); + } catch (_) { + hasThrown = true; + } + expect(hasThrown, false); + + // fetch wallet data again + final receivingAddressesP2PKH = + await wallet.get('receivingAddressesP2PKH'); + final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); + final receivingAddressesP2WPKH = + await wallet.get('receivingAddressesP2WPKH'); + final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); + final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + final changeIndexP2SH = await wallet.get('changeIndexP2SH'); + final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + final utxoData = await wallet.get('latest_utxo_model'); + final receiveDerivationsStringP2PKH = await secureStore.read( + key: "${testWalletId}_receiveDerivationsP2PKH"); + final changeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + final receiveDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + final changeDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + final receiveDerivationsStringP2WPKH = await secureStore.read( + key: "${testWalletId}_receiveDerivationsP2WPKH"); + final changeDerivationsStringP2WPKH = await secureStore.read( + key: "${testWalletId}_changeDerivationsP2WPKH"); + + expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + expect(preReceivingAddressesP2SH, receivingAddressesP2SH); + expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); + expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + expect(preChangeAddressesP2SH, changeAddressesP2SH); + expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); + expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + expect(preReceivingIndexP2SH, receivingIndexP2SH); + expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); + expect(preChangeIndexP2PKH, changeIndexP2PKH); + expect(preChangeIndexP2SH, changeIndexP2SH); + expect(preChangeIndexP2WPKH, changeIndexP2WPKH); + expect(preUtxoData, utxoData); + expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); + expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); + expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); + expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); + + verify(client?.getServerFeatures()).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); + verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); + verify(client?.getBatchHistory(args: { + "0": [ + "8ba03c2c46ed4980fa1e4c84cbceeb2d5e1371a7ccbaf5f3d69c5114161a2247" + ] + })).called(2); + verify(client?.getBatchHistory(args: { + "0": [ + "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" + ] + })).called(2); + + verify(client?.getBatchHistory(args: { + "0": [ + "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" + ] + })).called(2); + + verify(client?.getBatchHistory(args: { + "0": [ + "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" + ] + })).called(2); + + verify(client?.getBatchHistory(args: { + "0": [ + "9b56ab30c7bef0e1eaa10a632c8e2dcdd11b2158d7a917c03d62936afd0015fc" + ] + })).called(2); + + verify(client?.getBatchHistory(args: { + "0": [ + "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" + ] + })).called(2); + verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + .called(1); + + expect(secureStore.writes, 25); + expect(secureStore.reads, 32); + expect(secureStore.deletes, 6); + + verifyNoMoreInteractions(client); + verifyNoMoreInteractions(cachedClient); + verifyNoMoreInteractions(priceAPI); + }); + + test("fullRescan fails", () async { + when(client?.getServerFeatures()).thenAnswer((_) async => { + "hosts": {}, + "pruning": null, + "server_version": "Unit tests", + "protocol_min": "1.4", + "protocol_max": "1.4.2", + "genesis_hash": GENESIS_HASH_MAINNET, + "hash_function": "sha256", + "services": [] + }); + + when(client?.getBatchHistory(args: historyBatchArgs0)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs1)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs2)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs3)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs4)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs5)) + .thenAnswer((_) async => historyBatchResponse); + + when(client?.getBatchHistory(args: { + "0": [ + "8ba03c2c46ed4980fa1e4c84cbceeb2d5e1371a7ccbaf5f3d69c5114161a2247" + ] + })).thenAnswer((realInvocation) async => {"0": []}); + + when(client?.getBatchHistory(args: { + "0": [ + "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" + ] + })).thenAnswer((realInvocation) async => {"0": []}); + + when(client?.getBatchHistory(args: { + "0": [ + "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" + ] + })).thenAnswer((realInvocation) async => {"0": []}); + + when(client?.getBatchHistory(args: { + "0": [ + "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" + ] + })).thenAnswer((realInvocation) async => {"0": []}); + + when(client?.getBatchHistory(args: { + "0": [ + "9b56ab30c7bef0e1eaa10a632c8e2dcdd11b2158d7a917c03d62936afd0015fc" + ] + })).thenAnswer((realInvocation) async => {"0": []}); + + when(client?.getBatchHistory(args: { + "0": [ + "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" + ] + })).thenAnswer((realInvocation) async => {"0": []}); + + when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + .thenAnswer((realInvocation) async {}); + + final wallet = await Hive.openBox(testWalletId); + + // restore so we have something to rescan + await part?.recoverFromMnemonic( + mnemonic: TEST_MNEMONIC, + maxUnusedAddressGap: 2, + maxNumberOfIndexesToCheck: 1000, + height: 4000); + + // fetch wallet data + final preReceivingAddressesP2PKH = + await wallet.get('receivingAddressesP2PKH'); + final preReceivingAddressesP2SH = + await wallet.get('receivingAddressesP2SH'); + final preReceivingAddressesP2WPKH = + await wallet.get('receivingAddressesP2WPKH'); + final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + final preChangeAddressesP2WPKH = + await wallet.get('changeAddressesP2WPKH'); + final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); + final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + final preUtxoData = await wallet.get('latest_utxo_model'); + final preReceiveDerivationsStringP2PKH = await secureStore.read( + key: "${testWalletId}_receiveDerivationsP2PKH"); + final preChangeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + final preReceiveDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + final preChangeDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + final preReceiveDerivationsStringP2WPKH = await secureStore.read( + key: "${testWalletId}_receiveDerivationsP2WPKH"); + final preChangeDerivationsStringP2WPKH = await secureStore.read( + key: "${testWalletId}_changeDerivationsP2WPKH"); + + when(client?.getBatchHistory(args: historyBatchArgs0)) + .thenThrow(Exception("fake exception")); + + bool hasThrown = false; + try { + await part?.fullRescan(2, 1000); + } catch (_) { + hasThrown = true; + } + expect(hasThrown, true); + + // fetch wallet data again + final receivingAddressesP2PKH = + await wallet.get('receivingAddressesP2PKH'); + final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); + final receivingAddressesP2WPKH = + await wallet.get('receivingAddressesP2WPKH'); + final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); + final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + final changeIndexP2SH = await wallet.get('changeIndexP2SH'); + final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + final utxoData = await wallet.get('latest_utxo_model'); + final receiveDerivationsStringP2PKH = await secureStore.read( + key: "${testWalletId}_receiveDerivationsP2PKH"); + final changeDerivationsStringP2PKH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + final receiveDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + final changeDerivationsStringP2SH = + await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + final receiveDerivationsStringP2WPKH = await secureStore.read( + key: "${testWalletId}_receiveDerivationsP2WPKH"); + final changeDerivationsStringP2WPKH = await secureStore.read( + key: "${testWalletId}_changeDerivationsP2WPKH"); + + expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + expect(preReceivingAddressesP2SH, receivingAddressesP2SH); + expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); + expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + expect(preChangeAddressesP2SH, changeAddressesP2SH); + expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); + expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + expect(preReceivingIndexP2SH, receivingIndexP2SH); + expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); + expect(preChangeIndexP2PKH, changeIndexP2PKH); + expect(preChangeIndexP2SH, changeIndexP2SH); + expect(preChangeIndexP2WPKH, changeIndexP2WPKH); + expect(preUtxoData, utxoData); + expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); + expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); + expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); + expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); + + verify(client?.getServerFeatures()).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); + verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); + + verify(client?.getBatchHistory(args: { + "0": [ + "8ba03c2c46ed4980fa1e4c84cbceeb2d5e1371a7ccbaf5f3d69c5114161a2247" + ] + })).called(2); + verify(client?.getBatchHistory(args: { + "0": [ + "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339" + ] + })).called(2); + verify(client?.getBatchHistory(args: { + "0": [ + "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3" + ] + })).called(2); + verify(client?.getBatchHistory(args: { + "0": [ + "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a" + ] + })).called(2); + verify(client?.getBatchHistory(args: { + "0": [ + "9b56ab30c7bef0e1eaa10a632c8e2dcdd11b2158d7a917c03d62936afd0015fc" + ] + })).called(1); + verify(client?.getBatchHistory(args: { + "0": [ + "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" + ] + })).called(2); + verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + .called(1); + + expect(secureStore.writes, 19); + expect(secureStore.reads, 32); + expect(secureStore.deletes, 12); + + verifyNoMoreInteractions(client); + verifyNoMoreInteractions(cachedClient); + verifyNoMoreInteractions(priceAPI); + }); // test("prepareSend fails", () async { // when(client?.getServerFeatures()).thenAnswer((_) async => { @@ -1636,150 +1615,149 @@ void main() { // // verifyNoMoreInteractions(priceAPI); // // }); - // test("refresh wallet mutex locked", () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs1)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs2)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs3)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs4)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs5)) - // .thenAnswer((_) async => historyBatchResponse); - // - // List dynamicArgValues = []; - // - // when(client?.getBatchHistory(args: anyNamed("args"))) - // .thenAnswer((realInvocation) async { - // if (realInvocation.namedArguments.values.first.length == 1) { - // dynamicArgValues.add(realInvocation.namedArguments.values.first); - // } - // - // return historyBatchResponse; - // }); - // - // await Hive.openBox(testWalletId); - // - // // recover to fill data - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - // - // nmc?.refreshMutex = true; - // - // await nmc?.refresh(); - // - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - // - // for (final arg in dynamicArgValues) { - // final map = Map>.from(arg as Map); - // - // verify(client?.getBatchHistory(args: map)).called(1); - // expect(activeScriptHashes.contains(map.values.first.first as String), - // true); - // } - // - // expect(secureStore.interactions, 14); - // expect(secureStore.writes, 7); - // expect(secureStore.reads, 7); - // expect(secureStore.deletes, 0); - // - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(tracker); - // verifyNoMoreInteractions(priceAPI); - // }); - // - // test("refresh wallet normally", () async { - // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => - // {"height": 520481, "hex": "some block hex"}); - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.getHistory(scripthash: anyNamed("scripthash"))) - // .thenAnswer((_) async => []); - // when(client?.estimateFee(blocks: anyNamed("blocks"))) - // .thenAnswer((_) async => Decimal.one); - // - // when(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")) - // .thenAnswer((_) async => {Coin.particl: Tuple2(Decimal.one, 0.3)}); - // - // final List dynamicArgValues = []; - // - // when(client?.getBatchHistory(args: anyNamed("args"))) - // .thenAnswer((realInvocation) async { - // dynamicArgValues.add(realInvocation.namedArguments.values.first); - // return historyBatchResponse; - // }); - // - // await Hive.openBox(testWalletId); - // - // // recover to fill data - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - // - // when(client?.getBatchHistory(args: anyNamed("args"))) - // .thenAnswer((_) async => {}); - // when(client?.getBatchUTXOs(args: anyNamed("args"))) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // - // await nmc?.refresh(); - // - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(4); - // verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); - // verify(client?.getBlockHeadTip()).called(1); - // verify(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")).called(2); - // - // for (final arg in dynamicArgValues) { - // final map = Map>.from(arg as Map); - // - // verify(client?.getBatchHistory(args: map)).called(1); - // } - // - // expect(secureStore.interactions, 14); - // expect(secureStore.writes, 7); - // expect(secureStore.reads, 7); - // expect(secureStore.deletes, 0); - // - // // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - // - // tearDown(() async { - // await tearDownTestHive(); - // }); + test("refresh wallet mutex locked", () async { + when(client?.getServerFeatures()).thenAnswer((_) async => { + "hosts": {}, + "pruning": null, + "server_version": "Unit tests", + "protocol_min": "1.4", + "protocol_max": "1.4.2", + "genesis_hash": GENESIS_HASH_MAINNET, + "hash_function": "sha256", + "services": [] + }); + when(client?.getBatchHistory(args: historyBatchArgs0)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs1)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs2)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs3)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs4)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs5)) + .thenAnswer((_) async => historyBatchResponse); + + List dynamicArgValues = []; + + when(client?.getBatchHistory(args: anyNamed("args"))) + .thenAnswer((realInvocation) async { + if (realInvocation.namedArguments.values.first.length == 1) { + dynamicArgValues.add(realInvocation.namedArguments.values.first); + } + + return historyBatchResponse; + }); + + await Hive.openBox(testWalletId); + + // recover to fill data + await part?.recoverFromMnemonic( + mnemonic: TEST_MNEMONIC, + maxUnusedAddressGap: 2, + maxNumberOfIndexesToCheck: 1000, + height: 4000); + + part?.refreshMutex = true; + + await part?.refresh(); + + verify(client?.getServerFeatures()).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + + for (final arg in dynamicArgValues) { + final map = Map>.from(arg as Map); + + verify(client?.getBatchHistory(args: map)).called(1); + expect(activeScriptHashes.contains(map.values.first.first as String), + true); + } + + expect(secureStore.interactions, 14); + expect(secureStore.writes, 7); + expect(secureStore.reads, 7); + expect(secureStore.deletes, 0); + + verifyNoMoreInteractions(client); + verifyNoMoreInteractions(cachedClient); + verifyNoMoreInteractions(tracker); + verifyNoMoreInteractions(priceAPI); + }); + + test("refresh wallet normally", () async { + when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => + {"height": 520481, "hex": "some block hex"}); + when(client?.getServerFeatures()).thenAnswer((_) async => { + "hosts": {}, + "pruning": null, + "server_version": "Unit tests", + "protocol_min": "1.4", + "protocol_max": "1.4.2", + "genesis_hash": GENESIS_HASH_MAINNET, + "hash_function": "sha256", + "services": [] + }); + when(client?.getHistory(scripthash: anyNamed("scripthash"))) + .thenAnswer((_) async => []); + when(client?.estimateFee(blocks: anyNamed("blocks"))) + .thenAnswer((_) async => Decimal.one); + + when(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")) + .thenAnswer((_) async => {Coin.particl: Tuple2(Decimal.one, 0.3)}); + + final List dynamicArgValues = []; + + when(client?.getBatchHistory(args: anyNamed("args"))) + .thenAnswer((realInvocation) async { + dynamicArgValues.add(realInvocation.namedArguments.values.first); + return historyBatchResponse; + }); + + await Hive.openBox(testWalletId); + + // recover to fill data + await part?.recoverFromMnemonic( + mnemonic: TEST_MNEMONIC, + maxUnusedAddressGap: 2, + maxNumberOfIndexesToCheck: 1000, + height: 4000); + + when(client?.getBatchHistory(args: anyNamed("args"))) + .thenAnswer((_) async => {}); + when(client?.getBatchUTXOs(args: anyNamed("args"))) + .thenAnswer((_) async => emptyHistoryBatchResponse); + + await part?.refresh(); + + verify(client?.getServerFeatures()).called(1); + verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(4); + verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); + verify(client?.getBlockHeadTip()).called(1); + verify(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")).called(2); + + for (final arg in dynamicArgValues) { + final map = Map>.from(arg as Map); + + verify(client?.getBatchHistory(args: map)).called(1); + } + + expect(secureStore.interactions, 14); + expect(secureStore.writes, 7); + expect(secureStore.reads, 7); + expect(secureStore.deletes, 0); + + verifyNoMoreInteractions(cachedClient); + verifyNoMoreInteractions(priceAPI); + }); + + tearDown(() async { + await tearDownTestHive(); + }); }); }