coin tests linter warnings and clean up

This commit is contained in:
julian 2023-01-19 13:24:16 -06:00
parent aafca9289d
commit 35f6ffd4fc
8 changed files with 417 additions and 477 deletions

View file

@ -494,14 +494,14 @@ void main() async {
test("get fees succeeds", () async { test("get fees succeeds", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 1)) when(client?.estimateFee(blocks: 1))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -527,14 +527,14 @@ void main() async {
test("get fees fails", () async { test("get fees fails", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 1)) when(client?.estimateFee(blocks: 1))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -563,14 +563,14 @@ void main() async {
// test("get maxFee", () async { // test("get maxFee", () async {
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.estimateFee(blocks: 20)) // when(client?.estimateFee(blocks: 20))
// .thenAnswer((realInvocation) async => Decimal.zero); // .thenAnswer((realInvocation) async => Decimal.zero);
@ -657,7 +657,7 @@ void main() async {
// test("initializeWallet no network exception", () async { // test("initializeWallet no network exception", () async {
// when(client?.ping()).thenThrow(Exception("Network connection failed")); // when(client?.ping()).thenThrow(Exception("Network connection failed"));
// final wallets = await Hive.openBox(testWalletId); // final wallets = await Hive.openBox<dynamic> (testWalletId);
// expect(await btc?.initializeExisting(), false); // expect(await btc?.initializeExisting(), false);
// expect(secureStore?.interactions, 0); // expect(secureStore?.interactions, 0);
// verify(client?.ping()).called(1); // verify(client?.ping()).called(1);
@ -669,17 +669,17 @@ void main() async {
test("initializeWallet mainnet throws bad network", () async { test("initializeWallet mainnet throws bad network", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
// await btc?.initializeNew(); // await btc?.initializeNew();
final wallets = await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
await expectLater( await expectLater(
() => btc?.initializeExisting(), throwsA(isA<Exception>())) () => btc?.initializeExisting(), throwsA(isA<Exception>()))
@ -695,20 +695,21 @@ void main() async {
test("initializeWallet throws mnemonic overwrite exception", () async { test("initializeWallet throws mnemonic overwrite exception", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await secureStore.write( await secureStore.write(
key: "${testWalletId}_mnemonic", value: "some mnemonic"); key: "${testWalletId}_mnemonic", value: "some mnemonic");
final wallets = await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
expectLater(() => btc?.initializeExisting(), throwsA(isA<Exception>())) await expectLater(
() => btc?.initializeExisting(), throwsA(isA<Exception>()))
.then((_) { .then((_) {
expect(secureStore.interactions, 1); expect(secureStore.interactions, 1);
// verify(client?.ping()).called(1); // verify(client?.ping()).called(1);
@ -721,14 +722,14 @@ void main() async {
// test("initializeWallet testnet throws bad network", () async { // test("initializeWallet testnet throws bad network", () async {
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// btc = BitcoinWallet( // btc = BitcoinWallet(
@ -758,14 +759,14 @@ void main() async {
// // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // // .thenAnswer((realInvocation) async => Decimal.fromInt(10));
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// expect(await btc?.initializeWallet(), true); // expect(await btc?.initializeWallet(), true);
// //
@ -779,7 +780,7 @@ void main() async {
// expect(didThrow, true); // expect(didThrow, true);
// //
// // set node // // set node
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put("nodes", { // await wallet.put("nodes", {
// "default": { // "default": {
// "id": "some nodeID", // "id": "some nodeID",
@ -807,18 +808,18 @@ void main() async {
// // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // // .thenAnswer((realInvocation) async => Decimal.fromInt(10));
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// expect(await btc?.initializeWallet(), true); // expect(await btc?.initializeWallet(), true);
// //
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// //
// expect(await wallet.get("addressBookEntries"), {}); // expect(await wallet.get("addressBookEntries"), {});
// expect(await wallet.get('notes'), null); // expect(await wallet.get('notes'), null);
@ -892,20 +893,20 @@ void main() async {
// when(client?.getBatchHistory(args: anyNamed("args"))) // when(client?.getBatchHistory(args: anyNamed("args")))
// .thenAnswer((_) async => {}); // .thenAnswer((_) async => {});
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// // init new wallet // // init new wallet
// expect(await btc?.initializeWallet(), true); // expect(await btc?.initializeWallet(), true);
// //
// // fetch data to compare later // // fetch data to compare later
// final newWallet = await Hive.openBox(testWalletId); // final newWallet = await Hive.openBox<dynamic> (testWalletId);
// //
// final addressBookEntries = await newWallet.get("addressBookEntries"); // final addressBookEntries = await newWallet.get("addressBookEntries");
// final notes = await newWallet.get('notes'); // final notes = await newWallet.get('notes');
@ -964,7 +965,7 @@ void main() async {
// expect(await btc?.initializeWallet(), true); // expect(await btc?.initializeWallet(), true);
// //
// // compare data to ensure state matches state of previously closed wallet // // compare data to ensure state matches state of previously closed wallet
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// //
// expect(await wallet.get("addressBookEntries"), addressBookEntries); // expect(await wallet.get("addressBookEntries"), addressBookEntries);
// expect(await wallet.get('notes'), notes); // expect(await wallet.get('notes'), notes);
@ -1029,7 +1030,7 @@ void main() async {
// // test("get fiatPrice", () async { // // test("get fiatPrice", () async {
// // // when(priceAPI.getBitcoinPrice(baseCurrency: "USD")) // // // when(priceAPI.getBitcoinPrice(baseCurrency: "USD"))
// // // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // // // .thenAnswer((realInvocation) async => Decimal.fromInt(10));
// // await Hive.openBox(testWalletId); // // await Hive.openBox<dynamic> (testWalletId);
// // expect(await btc.basePrice, Decimal.fromInt(10)); // // expect(await btc.basePrice, Decimal.fromInt(10));
// // verify(priceAPI.getBitcoinPrice(baseCurrency: "USD")).called(1); // // verify(priceAPI.getBitcoinPrice(baseCurrency: "USD")).called(1);
// // verifyNoMoreInteractions(client); // // verifyNoMoreInteractions(client);
@ -1050,14 +1051,14 @@ void main() async {
// ); // );
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// await btc?.initializeWallet(); // await btc?.initializeWallet();
// expect( // expect(
@ -1092,14 +1093,14 @@ void main() async {
// ); // );
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// await btc?.initializeWallet(); // await btc?.initializeWallet();
// final addresses = await btc?.allOwnAddresses; // final addresses = await btc?.allOwnAddresses;
@ -1130,14 +1131,14 @@ void main() async {
// ); // );
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// when(client?.getBatchUTXOs(args: anyNamed("args"))) // when(client?.getBatchUTXOs(args: anyNamed("args")))
@ -1242,14 +1243,14 @@ void main() async {
// ); // );
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// when(client?.getBatchUTXOs(args: anyNamed("args"))) // when(client?.getBatchUTXOs(args: anyNamed("args")))
@ -1307,14 +1308,14 @@ void main() async {
// ); // );
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// when(client?.getBatchUTXOs(args: anyNamed("args"))) // when(client?.getBatchUTXOs(args: anyNamed("args")))
@ -1352,14 +1353,14 @@ void main() async {
// ); // );
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// await btc?.initializeWallet(); // await btc?.initializeWallet();
// //
@ -1468,14 +1469,14 @@ void main() async {
// test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { // test("_checkCurrentReceivingAddressesForTransactions succeeds", () async {
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getHistory(scripthash: anyNamed("scripthash"))) // when(client?.getHistory(scripthash: anyNamed("scripthash")))
// .thenAnswer((realInvocation) async => [ // .thenAnswer((realInvocation) async => [
@ -1517,18 +1518,18 @@ void main() async {
// test("_checkCurrentReceivingAddressesForTransactions fails", () async { // test("_checkCurrentReceivingAddressesForTransactions fails", () async {
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getHistory(scripthash: anyNamed("scripthash"))) // when(client?.getHistory(scripthash: anyNamed("scripthash")))
// .thenThrow(Exception("some exception")); // .thenThrow(Exception("some exception"));
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// //
// await btc?.initializeNew(); // await btc?.initializeNew();
// await btc?.initializeExisting(); // await btc?.initializeExisting();
@ -1557,14 +1558,14 @@ void main() async {
// test("_checkCurrentChangeAddressesForTransactions succeeds", () async { // test("_checkCurrentChangeAddressesForTransactions succeeds", () async {
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getHistory(scripthash: anyNamed("scripthash"))) // when(client?.getHistory(scripthash: anyNamed("scripthash")))
// .thenAnswer((realInvocation) async => [ // .thenAnswer((realInvocation) async => [
@ -1606,14 +1607,14 @@ void main() async {
// test("_checkCurrentChangeAddressesForTransactions fails", () async { // test("_checkCurrentChangeAddressesForTransactions fails", () async {
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getHistory(scripthash: anyNamed("scripthash"))) // when(client?.getHistory(scripthash: anyNamed("scripthash")))
// .thenThrow(Exception("some exception")); // .thenThrow(Exception("some exception"));
@ -1689,7 +1690,7 @@ void main() async {
// //
// secureStore: secureStore, // secureStore: secureStore,
// ); // );
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2PKH', []);
// await wallet.put('receivingAddressesP2SH', [ // await wallet.put('receivingAddressesP2SH', [
// "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT", // "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT",
@ -1827,7 +1828,7 @@ void main() async {
// //
// secureStore: secureStore, // secureStore: secureStore,
// ); // );
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2PKH', []);
// await wallet.put('receivingAddressesP2SH', [ // await wallet.put('receivingAddressesP2SH', [
// "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT", // "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT",
@ -1968,7 +1969,7 @@ void main() async {
// //
// secureStore: secureStore, // secureStore: secureStore,
// ); // );
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2PKH', []);
// await wallet.put('receivingAddressesP2SH', [ // await wallet.put('receivingAddressesP2SH', [
// "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT", // "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT",
@ -2027,7 +2028,7 @@ void main() async {
// //
// secureStore: secureStore, // secureStore: secureStore,
// ); // );
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2PKH', []);
// await wallet.put('receivingAddressesP2SH', [ // await wallet.put('receivingAddressesP2SH', [
// "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT", // "2Mv83bPh2HzPRXptuQg9ejbKpSp87Zi52zT",
@ -2068,14 +2069,14 @@ void main() async {
"recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
bool hasThrown = false; bool hasThrown = false;
@ -2110,14 +2111,14 @@ void main() async {
secureStore: secureStore, secureStore: secureStore,
); );
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
bool hasThrown = false; bool hasThrown = false;
@ -2143,14 +2144,14 @@ void main() async {
"recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await secureStore.write( await secureStore.write(
@ -2177,14 +2178,14 @@ void main() async {
test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { test("recoverFromMnemonic using empty seed on mainnet succeeds", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
@ -2199,7 +2200,7 @@ void main() async {
when(client?.getBatchHistory(args: historyBatchArgs5)) when(client?.getBatchHistory(args: historyBatchArgs5))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
// await DB.instance.init(); // await DB.instance.init();
final wallet = await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
bool hasThrown = false; bool hasThrown = false;
try { try {
await btc?.recoverFromMnemonic( await btc?.recoverFromMnemonic(
@ -2231,14 +2232,14 @@ void main() async {
test("get mnemonic list", () async { test("get mnemonic list", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
@ -2253,7 +2254,7 @@ void main() async {
when(client?.getBatchHistory(args: historyBatchArgs5)) when(client?.getBatchHistory(args: historyBatchArgs5))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
final wallet = await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
await btc?.recoverFromMnemonic( await btc?.recoverFromMnemonic(
mnemonic: TEST_MNEMONIC, mnemonic: TEST_MNEMONIC,
@ -2278,14 +2279,14 @@ void main() async {
test("recoverFromMnemonic using non empty seed on mainnet succeeds", test("recoverFromMnemonic using non empty seed on mainnet succeeds",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -2352,14 +2353,14 @@ void main() async {
test("fullRescan succeeds", () async { test("fullRescan succeeds", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -2587,14 +2588,14 @@ void main() async {
test("fullRescan fails", () async { test("fullRescan fails", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
@ -2794,14 +2795,14 @@ void main() async {
// test("fetchBuildTxData succeeds", () async { // test("fetchBuildTxData succeeds", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -2996,14 +2997,14 @@ void main() async {
// //
// test("fetchBuildTxData throws", () async { // test("fetchBuildTxData throws", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -3076,14 +3077,14 @@ void main() async {
// //
// test("build transaction succeeds", () async { // test("build transaction succeeds", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -3181,14 +3182,14 @@ void main() async {
// //
// test("build transaction fails", () async { // test("build transaction fails", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -3292,14 +3293,14 @@ void main() async {
// //
// test("two output coinSelection succeeds", () async { // test("two output coinSelection succeeds", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -3397,14 +3398,14 @@ void main() async {
// //
// test("one output option A coinSelection", () async { // test("one output option A coinSelection", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -3501,14 +3502,14 @@ void main() async {
// //
// test("one output option B coinSelection", () async { // test("one output option B coinSelection", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -3605,14 +3606,14 @@ void main() async {
// //
// test("insufficient funds option A coinSelection", () async { // test("insufficient funds option A coinSelection", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -3668,14 +3669,14 @@ void main() async {
// //
// test("insufficient funds option B coinSelection", () async { // test("insufficient funds option B coinSelection", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -3731,14 +3732,14 @@ void main() async {
// //
// test("insufficient funds option C coinSelection", () async { // test("insufficient funds option C coinSelection", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -3830,14 +3831,14 @@ void main() async {
// //
// test("check for more outputs coinSelection", () async { // test("check for more outputs coinSelection", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -3936,14 +3937,14 @@ void main() async {
// //
// test("prepareSend and confirmSend succeed", () async { // test("prepareSend and confirmSend succeed", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -4053,14 +4054,14 @@ void main() async {
test("prepareSend fails", () async { test("prepareSend fails", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -4113,21 +4114,21 @@ void main() async {
// modify addresses to properly mock data to build a tx // modify addresses to properly mock data to build a tx
final rcv44 = await secureStore.read( final rcv44 = await secureStore.read(
key: testWalletId + "_receiveDerivationsP2PKH"); key: "${testWalletId}_receiveDerivationsP2PKH");
await secureStore.write( await secureStore.write(
key: testWalletId + "_receiveDerivationsP2PKH", key: "${testWalletId}_receiveDerivationsP2PKH",
value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw",
"16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ"));
final rcv49 = final rcv49 =
await secureStore.read(key: testWalletId + "_receiveDerivationsP2SH"); await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH");
await secureStore.write( await secureStore.write(
key: testWalletId + "_receiveDerivationsP2SH", key: "${testWalletId}_receiveDerivationsP2SH",
value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk", value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk",
"36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g")); "36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g"));
final rcv84 = await secureStore.read( final rcv84 = await secureStore.read(
key: testWalletId + "_receiveDerivationsP2WPKH"); key: "${testWalletId}_receiveDerivationsP2WPKH");
await secureStore.write( await secureStore.write(
key: testWalletId + "_receiveDerivationsP2WPKH", key: "${testWalletId}_receiveDerivationsP2WPKH",
value: rcv84?.replaceFirst( value: rcv84?.replaceFirst(
"bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0", "bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0",
"bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc")); "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc"));
@ -4300,7 +4301,7 @@ void main() async {
// // ); // // );
// // // //
// // // set node // // // set node
// // final wallet = await Hive.openBox(testWalletId); // // final wallet = await Hive.openBox<dynamic> (testWalletId);
// // await wallet.put("nodes", { // // await wallet.put("nodes", {
// // "default": { // // "default": {
// // "id": "some nodeID", // // "id": "some nodeID",
@ -4336,14 +4337,14 @@ void main() async {
test("refresh wallet mutex locked", () async { test("refresh wallet mutex locked", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -4412,14 +4413,14 @@ void main() async {
when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async =>
{"height": 520481, "hex": "some block hex"}); {"height": 520481, "hex": "some block hex"});
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenAnswer((_) async => []); .thenAnswer((_) async => []);

View file

@ -459,14 +459,14 @@ void main() {
test("get fees succeeds", () async { test("get fees succeeds", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 1)) when(client?.estimateFee(blocks: 1))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -493,14 +493,14 @@ void main() {
test("get fees fails", () async { test("get fees fails", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 1)) when(client?.estimateFee(blocks: 1))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -530,14 +530,14 @@ void main() {
test("get maxFee", () async { test("get maxFee", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 20)) when(client?.estimateFee(blocks: 20))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -592,7 +592,7 @@ void main() {
Hive.registerAdapter(UtxoObjectAdapter()); Hive.registerAdapter(UtxoObjectAdapter());
Hive.registerAdapter(StatusAdapter()); Hive.registerAdapter(StatusAdapter());
final wallets = await Hive.openBox('wallets'); final wallets = await Hive.openBox<dynamic>('wallets');
await wallets.put('currentWalletName', testWalletName); await wallets.put('currentWalletName', testWalletName);
} }
@ -638,14 +638,14 @@ void main() {
// test("initializeNew mainnet throws bad network", () async { // test("initializeNew mainnet throws bad network", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// await Hive.openBox<dynamic>(testWalletId); // await Hive.openBox<dynamic>(testWalletId);
@ -664,14 +664,14 @@ void main() {
test("initializeNew throws mnemonic overwrite exception", () async { test("initializeNew throws mnemonic overwrite exception", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await secureStore.write( await secureStore.write(
key: "${testWalletId}_mnemonic", value: "some mnemonic"); key: "${testWalletId}_mnemonic", value: "some mnemonic");
@ -692,14 +692,14 @@ void main() {
// test("initializeExisting testnet throws bad network", () async { // test("initializeExisting testnet throws bad network", () async {
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// bch = BitcoinCashWallet( // bch = BitcoinCashWallet(
@ -732,14 +732,14 @@ void main() {
// // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // // .thenAnswer((realInvocation) async => Decimal.fromInt(10));
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// // await DebugService.instance.init(); // // await DebugService.instance.init();
// expect(bch?.initializeExisting(), true); // expect(bch?.initializeExisting(), true);
@ -754,7 +754,7 @@ void main() {
// expect(didThrow, true); // expect(didThrow, true);
// //
// // set node // // set node
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put("nodes", { // await wallet.put("nodes", {
// "default": { // "default": {
// "id": "some nodeID", // "id": "some nodeID",
@ -782,18 +782,18 @@ void main() {
// .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // .thenAnswer((realInvocation) async => Decimal.fromInt(10));
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// expect(await bch?.initializeWallet(), true); // expect(await bch?.initializeWallet(), true);
// //
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// //
// expect(await wallet.get("addressBookEntries"), {}); // expect(await wallet.get("addressBookEntries"), {});
// expect(await wallet.get('notes'), null); // expect(await wallet.get('notes'), null);
@ -838,20 +838,20 @@ void main() {
// // when(client?.getBatchHistory(args: anyNamed("args"))) // // when(client?.getBatchHistory(args: anyNamed("args")))
// // .thenAnswer((_) async => {}); // // .thenAnswer((_) async => {});
// // when(client?.getServerFeatures()).thenAnswer((_) async => { // // when(client?.getServerFeatures()).thenAnswer((_) async => {
// // "hosts": {}, // // "hosts": <dynamic, dynamic>{},
// // "pruning": null, // // "pruning": null,
// // "server_version": "Unit tests", // // "server_version": "Unit tests",
// // "protocol_min": "1.4", // // "protocol_min": "1.4",
// // "protocol_max": "1.4.2", // // "protocol_max": "1.4.2",
// // "genesis_hash": GENESIS_HASH_MAINNET, // // "genesis_hash": GENESIS_HASH_MAINNET,
// // "hash_function": "sha256", // // "hash_function": "sha256",
// // "services": [] // // "services": <dynamic>[]
// // }); // // });
// // // init new wallet // // // init new wallet
// // expect(bch?.initializeNew(), true); // // expect(bch?.initializeNew(), true);
// // // //
// // // fetch data to compare later // // // fetch data to compare later
// // final newWallet = await Hive.openBox(testWalletId); // // final newWallet = await Hive.openBox<dynamic> (testWalletId);
// // // //
// // final addressBookEntries = await newWallet.get("addressBookEntries"); // // final addressBookEntries = await newWallet.get("addressBookEntries");
// // final notes = await newWallet.get('notes'); // // final notes = await newWallet.get('notes');
@ -890,7 +890,7 @@ void main() {
// // expect(bch?.initializeExisting(), true); // // expect(bch?.initializeExisting(), true);
// // // //
// // // compare data to ensure state matches state of previously closed wallet // // // compare data to ensure state matches state of previously closed wallet
// // final wallet = await Hive.openBox(testWalletId); // // final wallet = await Hive.openBox<dynamic> (testWalletId);
// // // //
// // expect(await wallet.get("addressBookEntries"), addressBookEntries); // // expect(await wallet.get("addressBookEntries"), addressBookEntries);
// // expect(await wallet.get('notes'), notes); // // expect(await wallet.get('notes'), notes);
@ -938,14 +938,14 @@ void main() {
); );
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
@ -976,14 +976,14 @@ void main() {
// ); // );
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// await Hive.openBox<dynamic>(testWalletId); // await Hive.openBox<dynamic>(testWalletId);
@ -1080,14 +1080,14 @@ void main() {
// // ); // // );
// // when(client?.ping()).thenAnswer((_) async => true); // // when(client?.ping()).thenAnswer((_) async => true);
// // when(client?.getServerFeatures()).thenAnswer((_) async => { // // when(client?.getServerFeatures()).thenAnswer((_) async => {
// // "hosts": {}, // // "hosts": <dynamic, dynamic>{},
// // "pruning": null, // // "pruning": null,
// // "server_version": "Unit tests", // // "server_version": "Unit tests",
// // "protocol_min": "1.4", // // "protocol_min": "1.4",
// // "protocol_max": "1.4.2", // // "protocol_max": "1.4.2",
// // "genesis_hash": GENESIS_HASH_TESTNET, // // "genesis_hash": GENESIS_HASH_TESTNET,
// // "hash_function": "sha256", // // "hash_function": "sha256",
// // "services": [] // // "services": <dynamic>[]
// // }); // // });
// // // //
// // when(client?.getBatchUTXOs(args: anyNamed("args"))) // // when(client?.getBatchUTXOs(args: anyNamed("args")))
@ -1099,7 +1099,7 @@ void main() {
// // await bch?.initializeWallet(); // // await bch?.initializeWallet();
// // // //
// // // add some extra addresses to make sure we have more than the single batch size of 10 // // // add some extra addresses to make sure we have more than the single batch size of 10
// // final wallet = await Hive.openBox(testWalletId); // // final wallet = await Hive.openBox<dynamic> (testWalletId);
// // final addresses = await wallet.get("receivingAddressesP2PKH"); // // final addresses = await wallet.get("receivingAddressesP2PKH");
// // addresses.add("DQaAi9R58GXMpDyhePys6hHCuif4fhc1sN"); // // addresses.add("DQaAi9R58GXMpDyhePys6hHCuif4fhc1sN");
// // addresses.add("DBVhuF8QgeuxU2pssxzMgJqPhGCx5qyVkD"); // // addresses.add("DBVhuF8QgeuxU2pssxzMgJqPhGCx5qyVkD");
@ -1143,14 +1143,14 @@ void main() {
); );
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
@ -1191,14 +1191,14 @@ void main() {
); );
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
@ -1208,7 +1208,7 @@ void main() {
await bch?.initializeExisting(); await bch?.initializeExisting();
// get stored // get stored
expect(await bch?.storedChainHeight, 0); expect(bch?.storedChainHeight, 0);
// fetch fails // fetch fails
when(client?.getBlockHeadTip()).thenThrow(Exception("Some exception")); when(client?.getBlockHeadTip()).thenThrow(Exception("Some exception"));
@ -1222,10 +1222,10 @@ void main() {
expect(await bch?.chainHeight, 100); expect(await bch?.chainHeight, 100);
// update // update
await bch?.updateStoredChainHeight(newHeight: 1000); await bch?.updateCachedChainHeight(1000);
// fetch updated // fetch updated
expect(await bch?.storedChainHeight, 1000); expect(bch?.storedChainHeight, 1000);
verifyNever(client?.ping()).called(0); verifyNever(client?.ping()).called(0);
verify(client?.getServerFeatures()).called(1); verify(client?.getServerFeatures()).called(1);
@ -1296,14 +1296,14 @@ void main() {
test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { test("_checkCurrentReceivingAddressesForTransactions succeeds", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenAnswer((realInvocation) async => [ .thenAnswer((realInvocation) async => [
@ -1348,14 +1348,14 @@ void main() {
test("_checkCurrentReceivingAddressesForTransactions fails", () async { test("_checkCurrentReceivingAddressesForTransactions fails", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenThrow(Exception("some exception")); .thenThrow(Exception("some exception"));
@ -1389,14 +1389,14 @@ void main() {
test("_checkCurrentChangeAddressesForTransactions succeeds", () async { test("_checkCurrentChangeAddressesForTransactions succeeds", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenAnswer((realInvocation) async => [ .thenAnswer((realInvocation) async => [
@ -1442,14 +1442,14 @@ void main() {
test("_checkCurrentChangeAddressesForTransactions fails", () async { test("_checkCurrentChangeAddressesForTransactions fails", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenThrow(Exception("some exception")); .thenThrow(Exception("some exception"));
@ -1527,7 +1527,7 @@ void main() {
// //
// secureStore: secureStore, // secureStore: secureStore,
// ); // );
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2PKH', []);
// //
// await wallet.put('changeAddressesP2PKH', []); // await wallet.put('changeAddressesP2PKH', []);
@ -1656,7 +1656,7 @@ void main() {
// //
// secureStore: secureStore, // secureStore: secureStore,
// ); // );
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2PKH', []);
// //
// await wallet.put('changeAddressesP2PKH', []); // await wallet.put('changeAddressesP2PKH', []);
@ -1789,7 +1789,7 @@ void main() {
// //
// secureStore: secureStore, // secureStore: secureStore,
// ); // );
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2PKH', []);
// //
// await wallet.put('changeAddressesP2PKH', []); // await wallet.put('changeAddressesP2PKH', []);
@ -1841,7 +1841,7 @@ void main() {
// // // //
// // secureStore: secureStore, // // secureStore: secureStore,
// // ); // // );
// // final wallet = await Hive.openBox(testWalletId); // // final wallet = await Hive.openBox<dynamic> (testWalletId);
// // await wallet.put('receivingAddressesP2PKH', []); // // await wallet.put('receivingAddressesP2PKH', []);
// // // //
// // await wallet.put('changeAddressesP2PKH', []); // // await wallet.put('changeAddressesP2PKH', []);
@ -1868,14 +1868,14 @@ void main() {
test("get mnemonic list", () async { test("get mnemonic list", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
// when(client?.getBatchHistory(args: anyNamed("args"))) // when(client?.getBatchHistory(args: anyNamed("args")))
@ -1893,7 +1893,7 @@ void main() {
when(client?.getBatchHistory(args: historyBatchArgs3)) when(client?.getBatchHistory(args: historyBatchArgs3))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
final wallet = await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
// add maxNumberOfIndexesToCheck and height // add maxNumberOfIndexesToCheck and height
await bch?.recoverFromMnemonic( await bch?.recoverFromMnemonic(
@ -1919,14 +1919,14 @@ void main() {
"recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
bool hasThrown = false; bool hasThrown = false;
@ -1961,14 +1961,14 @@ void main() {
secureStore: secureStore, secureStore: secureStore,
); );
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
bool hasThrown = false; bool hasThrown = false;
@ -1994,14 +1994,14 @@ void main() {
"recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await secureStore.write( await secureStore.write(
@ -2029,14 +2029,14 @@ void main() {
test("recoverFromMnemonic using non empty seed on mainnet succeeds", test("recoverFromMnemonic using non empty seed on mainnet succeeds",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -2058,7 +2058,7 @@ void main() {
return historyBatchResponse; return historyBatchResponse;
}); });
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
bool hasThrown = false; bool hasThrown = false;
@ -2099,14 +2099,14 @@ void main() {
test("fullRescan succeeds", () async { test("fullRescan succeeds", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -2140,7 +2140,7 @@ void main() {
] ]
})).thenAnswer((_) async => {"0": []}); })).thenAnswer((_) async => {"0": []});
final wallet = await Hive.openBox(testWalletId); final wallet = await Hive.openBox<dynamic>(testWalletId);
// restore so we have something to rescan // restore so we have something to rescan
await bch?.recoverFromMnemonic( await bch?.recoverFromMnemonic(
@ -2289,14 +2289,14 @@ void main() {
test("fullRescan fails", () async { test("fullRescan fails", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
@ -2331,7 +2331,7 @@ void main() {
] ]
})).thenAnswer((_) async => {"0": []}); })).thenAnswer((_) async => {"0": []});
final wallet = await Hive.openBox(testWalletId); final wallet = await Hive.openBox<dynamic>(testWalletId);
// restore so we have something to rescan // restore so we have something to rescan
await bch?.recoverFromMnemonic( await bch?.recoverFromMnemonic(
@ -2421,14 +2421,14 @@ void main() {
// // test("fetchBuildTxData succeeds", () async { // // test("fetchBuildTxData succeeds", () async {
// // when(client.getServerFeatures()).thenAnswer((_) async => { // // when(client.getServerFeatures()).thenAnswer((_) async => {
// // "hosts": {}, // // "hosts": <dynamic, dynamic>{},
// // "pruning": null, // // "pruning": null,
// // "server_version": "Unit tests", // // "server_version": "Unit tests",
// // "protocol_min": "1.4", // // "protocol_min": "1.4",
// // "protocol_max": "1.4.2", // // "protocol_max": "1.4.2",
// // "genesis_hash": GENESIS_HASH_MAINNET, // // "genesis_hash": GENESIS_HASH_MAINNET,
// // "hash_function": "sha256", // // "hash_function": "sha256",
// // "services": [] // // "services": <dynamic>[]
// // }); // // });
// // when(client.getBatchHistory(args: historyBatchArgs0)) // // when(client.getBatchHistory(args: historyBatchArgs0))
// // .thenAnswer((_) async => historyBatchResponse); // // .thenAnswer((_) async => historyBatchResponse);
@ -2598,14 +2598,14 @@ void main() {
// test("fetchBuildTxData throws", () async { // test("fetchBuildTxData throws", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -2679,14 +2679,14 @@ void main() {
// test("build transaction succeeds", () async { // test("build transaction succeeds", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -2882,14 +2882,14 @@ void main() {
test("refresh wallet mutex locked", () async { test("refresh wallet mutex locked", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -2920,7 +2920,7 @@ void main() {
] ]
})).thenAnswer((realInvocation) async => {"0": []}); })).thenAnswer((realInvocation) async => {"0": []});
final wallet = await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
// recover to fill data // recover to fill data
await bch?.recoverFromMnemonic( await bch?.recoverFromMnemonic(
mnemonic: TEST_MNEMONIC, mnemonic: TEST_MNEMONIC,
@ -2972,14 +2972,14 @@ void main() {
test("refresh wallet throws", () async { test("refresh wallet throws", () async {
when(client?.getBlockHeadTip()).thenThrow(Exception("some exception")); when(client?.getBlockHeadTip()).thenThrow(Exception("some exception"));
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -3014,7 +3014,7 @@ void main() {
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenThrow(Exception("some exception")); .thenThrow(Exception("some exception"));
final wallet = await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
// recover to fill data // recover to fill data
await bch?.recoverFromMnemonic( await bch?.recoverFromMnemonic(
@ -3069,14 +3069,14 @@ void main() {
// when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async =>
// {"height": 520481, "hex": "some block hex"}); // {"height": 520481, "hex": "some block hex"});
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);

View file

@ -244,10 +244,10 @@ void main() {
}); });
group("basic getters, setters, and functions", () { group("basic getters, setters, and functions", () {
final dcoin = Coin.dogecoin; const dcoin = Coin.dogecoin;
final dtestcoin = Coin.dogecoinTestNet; const dtestcoin = Coin.dogecoinTestNet;
final testWalletId = "DOGEtestWalletID"; const testWalletId = "DOGEtestWalletID";
final testWalletName = "DOGEWallet"; const testWalletName = "DOGEWallet";
MockElectrumX? client; MockElectrumX? client;
MockCachedElectrumX? cachedClient; MockCachedElectrumX? cachedClient;
@ -352,14 +352,14 @@ void main() {
test("get fees succeeds", () async { test("get fees succeeds", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 1)) when(client?.estimateFee(blocks: 1))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -386,14 +386,14 @@ void main() {
test("get fees fails", () async { test("get fees fails", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 1)) when(client?.estimateFee(blocks: 1))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -423,14 +423,14 @@ void main() {
test("get maxFee", () async { test("get maxFee", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 20)) when(client?.estimateFee(blocks: 20))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -453,10 +453,10 @@ void main() {
}); });
group("DogeWallet service class functions that depend on shared storage", () { group("DogeWallet service class functions that depend on shared storage", () {
final dcoin = Coin.dogecoin; const dcoin = Coin.dogecoin;
final dtestcoin = Coin.dogecoinTestNet; const dtestcoin = Coin.dogecoinTestNet;
final testWalletId = "DOGEtestWalletID"; const testWalletId = "DOGEtestWalletID";
final testWalletName = "DOGEWallet"; const testWalletName = "DOGEWallet";
bool hiveAdaptersRegistered = false; bool hiveAdaptersRegistered = false;
@ -485,7 +485,7 @@ void main() {
Hive.registerAdapter(UtxoObjectAdapter()); Hive.registerAdapter(UtxoObjectAdapter());
Hive.registerAdapter(StatusAdapter()); Hive.registerAdapter(StatusAdapter());
final wallets = await Hive.openBox('wallets'); final wallets = await Hive.openBox<dynamic>('wallets');
await wallets.put('currentWalletName', testWalletName); await wallets.put('currentWalletName', testWalletName);
} }
@ -531,14 +531,14 @@ void main() {
// test("initializeNew mainnet throws bad network", () async { // test("initializeNew mainnet throws bad network", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// await Hive.openBox<dynamic>(testWalletId); // await Hive.openBox<dynamic>(testWalletId);
@ -557,14 +557,14 @@ void main() {
test("initializeNew throws mnemonic overwrite exception", () async { test("initializeNew throws mnemonic overwrite exception", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await secureStore.write( await secureStore.write(
key: "${testWalletId}_mnemonic", value: "some mnemonic"); key: "${testWalletId}_mnemonic", value: "some mnemonic");
@ -572,7 +572,7 @@ void main() {
await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
await Hive.openBox<dynamic>(DB.boxNamePrefs); await Hive.openBox<dynamic>(DB.boxNamePrefs);
expectLater(() => doge?.initializeNew(), throwsA(isA<Exception>())) await expectLater(() => doge?.initializeNew(), throwsA(isA<Exception>()))
.then((_) { .then((_) {
expect(secureStore.interactions, 2); expect(secureStore.interactions, 2);
verifyNever(client?.ping()).called(0); verifyNever(client?.ping()).called(0);
@ -585,14 +585,14 @@ void main() {
// test("initializeExisting testnet throws bad network", () async { // test("initializeExisting testnet throws bad network", () async {
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// doge = DogecoinWallet( // doge = DogecoinWallet(
@ -625,14 +625,14 @@ void main() {
// // .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // // .thenAnswer((realInvocation) async => Decimal.fromInt(10));
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// // await DebugService.instance.init(); // // await DebugService.instance.init();
// expect(doge?.initializeExisting(), true); // expect(doge?.initializeExisting(), true);
@ -647,7 +647,7 @@ void main() {
// expect(didThrow, true); // expect(didThrow, true);
// //
// // set node // // set node
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put("nodes", { // await wallet.put("nodes", {
// "default": { // "default": {
// "id": "some nodeID", // "id": "some nodeID",
@ -675,18 +675,18 @@ void main() {
// .thenAnswer((realInvocation) async => Decimal.fromInt(10)); // .thenAnswer((realInvocation) async => Decimal.fromInt(10));
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// expect(await doge?.initializeWallet(), true); // expect(await doge?.initializeWallet(), true);
// //
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// //
// expect(await wallet.get("addressBookEntries"), {}); // expect(await wallet.get("addressBookEntries"), {});
// expect(await wallet.get('notes'), null); // expect(await wallet.get('notes'), null);
@ -731,20 +731,20 @@ void main() {
// // when(client?.getBatchHistory(args: anyNamed("args"))) // // when(client?.getBatchHistory(args: anyNamed("args")))
// // .thenAnswer((_) async => {}); // // .thenAnswer((_) async => {});
// // when(client?.getServerFeatures()).thenAnswer((_) async => { // // when(client?.getServerFeatures()).thenAnswer((_) async => {
// // "hosts": {}, // // "hosts": <dynamic, dynamic>{},
// // "pruning": null, // // "pruning": null,
// // "server_version": "Unit tests", // // "server_version": "Unit tests",
// // "protocol_min": "1.4", // // "protocol_min": "1.4",
// // "protocol_max": "1.4.2", // // "protocol_max": "1.4.2",
// // "genesis_hash": GENESIS_HASH_MAINNET, // // "genesis_hash": GENESIS_HASH_MAINNET,
// // "hash_function": "sha256", // // "hash_function": "sha256",
// // "services": [] // // "services": <dynamic>[]
// // }); // // });
// // // init new wallet // // // init new wallet
// // expect(doge?.initializeNew(), true); // // expect(doge?.initializeNew(), true);
// // // //
// // // fetch data to compare later // // // fetch data to compare later
// // final newWallet = await Hive.openBox(testWalletId); // // final newWallet = await Hive.openBox<dynamic> (testWalletId);
// // // //
// // final addressBookEntries = await newWallet.get("addressBookEntries"); // // final addressBookEntries = await newWallet.get("addressBookEntries");
// // final notes = await newWallet.get('notes'); // // final notes = await newWallet.get('notes');
@ -783,7 +783,7 @@ void main() {
// // expect(doge?.initializeExisting(), true); // // expect(doge?.initializeExisting(), true);
// // // //
// // // compare data to ensure state matches state of previously closed wallet // // // compare data to ensure state matches state of previously closed wallet
// // final wallet = await Hive.openBox(testWalletId); // // final wallet = await Hive.openBox<dynamic> (testWalletId);
// // // //
// // expect(await wallet.get("addressBookEntries"), addressBookEntries); // // expect(await wallet.get("addressBookEntries"), addressBookEntries);
// // expect(await wallet.get('notes'), notes); // // expect(await wallet.get('notes'), notes);
@ -831,14 +831,14 @@ void main() {
); );
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
@ -878,14 +878,14 @@ void main() {
// ); // );
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// await Hive.openBox<dynamic>(testWalletId); // await Hive.openBox<dynamic>(testWalletId);
@ -982,14 +982,14 @@ void main() {
// // ); // // );
// // when(client?.ping()).thenAnswer((_) async => true); // // when(client?.ping()).thenAnswer((_) async => true);
// // when(client?.getServerFeatures()).thenAnswer((_) async => { // // when(client?.getServerFeatures()).thenAnswer((_) async => {
// // "hosts": {}, // // "hosts": <dynamic, dynamic>{},
// // "pruning": null, // // "pruning": null,
// // "server_version": "Unit tests", // // "server_version": "Unit tests",
// // "protocol_min": "1.4", // // "protocol_min": "1.4",
// // "protocol_max": "1.4.2", // // "protocol_max": "1.4.2",
// // "genesis_hash": GENESIS_HASH_TESTNET, // // "genesis_hash": GENESIS_HASH_TESTNET,
// // "hash_function": "sha256", // // "hash_function": "sha256",
// // "services": [] // // "services": <dynamic>[]
// // }); // // });
// // // //
// // when(client?.getBatchUTXOs(args: anyNamed("args"))) // // when(client?.getBatchUTXOs(args: anyNamed("args")))
@ -1001,7 +1001,7 @@ void main() {
// // await doge?.initializeWallet(); // // await doge?.initializeWallet();
// // // //
// // // add some extra addresses to make sure we have more than the single batch size of 10 // // // add some extra addresses to make sure we have more than the single batch size of 10
// // final wallet = await Hive.openBox(testWalletId); // // final wallet = await Hive.openBox<dynamic> (testWalletId);
// // final addresses = await wallet.get("receivingAddressesP2PKH"); // // final addresses = await wallet.get("receivingAddressesP2PKH");
// // addresses.add("DQaAi9R58GXMpDyhePys6hHCuif4fhc1sN"); // // addresses.add("DQaAi9R58GXMpDyhePys6hHCuif4fhc1sN");
// // addresses.add("DBVhuF8QgeuxU2pssxzMgJqPhGCx5qyVkD"); // // addresses.add("DBVhuF8QgeuxU2pssxzMgJqPhGCx5qyVkD");
@ -1045,14 +1045,14 @@ void main() {
); );
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
@ -1093,14 +1093,14 @@ void main() {
); );
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
@ -1110,7 +1110,7 @@ void main() {
await doge?.initializeExisting(); await doge?.initializeExisting();
// get stored // get stored
expect(await doge?.storedChainHeight, 0); expect(doge?.storedChainHeight, 0);
// fetch fails // fetch fails
when(client?.getBlockHeadTip()).thenThrow(Exception("Some exception")); when(client?.getBlockHeadTip()).thenThrow(Exception("Some exception"));
@ -1124,10 +1124,10 @@ void main() {
expect(await doge?.chainHeight, 100); expect(await doge?.chainHeight, 100);
// update // update
await doge?.updateStoredChainHeight(newHeight: 1000); await doge?.updateCachedChainHeight(1000);
// fetch updated // fetch updated
expect(await doge?.storedChainHeight, 1000); expect(doge?.storedChainHeight, 1000);
verifyNever(client?.ping()).called(0); verifyNever(client?.ping()).called(0);
verify(client?.getServerFeatures()).called(1); verify(client?.getServerFeatures()).called(1);
@ -1198,14 +1198,14 @@ void main() {
test("_checkCurrentReceivingAddressesForTransactions succeeds", () async { test("_checkCurrentReceivingAddressesForTransactions succeeds", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenAnswer((realInvocation) async => [ .thenAnswer((realInvocation) async => [
@ -1250,14 +1250,14 @@ void main() {
test("_checkCurrentReceivingAddressesForTransactions fails", () async { test("_checkCurrentReceivingAddressesForTransactions fails", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenThrow(Exception("some exception")); .thenThrow(Exception("some exception"));
@ -1291,14 +1291,14 @@ void main() {
test("_checkCurrentChangeAddressesForTransactions succeeds", () async { test("_checkCurrentChangeAddressesForTransactions succeeds", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenAnswer((realInvocation) async => [ .thenAnswer((realInvocation) async => [
@ -1344,14 +1344,14 @@ void main() {
test("_checkCurrentChangeAddressesForTransactions fails", () async { test("_checkCurrentChangeAddressesForTransactions fails", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenThrow(Exception("some exception")); .thenThrow(Exception("some exception"));
@ -1429,7 +1429,7 @@ void main() {
// //
// secureStore: secureStore, // secureStore: secureStore,
// ); // );
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2PKH', []);
// //
// await wallet.put('changeAddressesP2PKH', []); // await wallet.put('changeAddressesP2PKH', []);
@ -1558,7 +1558,7 @@ void main() {
// //
// secureStore: secureStore, // secureStore: secureStore,
// ); // );
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2PKH', []);
// //
// await wallet.put('changeAddressesP2PKH', []); // await wallet.put('changeAddressesP2PKH', []);
@ -1691,7 +1691,7 @@ void main() {
// //
// secureStore: secureStore, // secureStore: secureStore,
// ); // );
// final wallet = await Hive.openBox(testWalletId); // final wallet = await Hive.openBox<dynamic> (testWalletId);
// await wallet.put('receivingAddressesP2PKH', []); // await wallet.put('receivingAddressesP2PKH', []);
// //
// await wallet.put('changeAddressesP2PKH', []); // await wallet.put('changeAddressesP2PKH', []);
@ -1743,7 +1743,7 @@ void main() {
// // // //
// // secureStore: secureStore, // // secureStore: secureStore,
// // ); // // );
// // final wallet = await Hive.openBox(testWalletId); // // final wallet = await Hive.openBox<dynamic> (testWalletId);
// // await wallet.put('receivingAddressesP2PKH', []); // // await wallet.put('receivingAddressesP2PKH', []);
// // // //
// // await wallet.put('changeAddressesP2PKH', []); // // await wallet.put('changeAddressesP2PKH', []);
@ -1770,21 +1770,21 @@ void main() {
test("get mnemonic list", () async { test("get mnemonic list", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
when(client?.getBatchHistory(args: historyBatchArgs1)) when(client?.getBatchHistory(args: historyBatchArgs1))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
final wallet = await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
// add maxNumberOfIndexesToCheck and height // add maxNumberOfIndexesToCheck and height
await doge?.recoverFromMnemonic( await doge?.recoverFromMnemonic(
@ -1808,14 +1808,14 @@ void main() {
"recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
bool hasThrown = false; bool hasThrown = false;
@ -1850,14 +1850,14 @@ void main() {
secureStore: secureStore, secureStore: secureStore,
); );
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
bool hasThrown = false; bool hasThrown = false;
@ -1883,14 +1883,14 @@ void main() {
"recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await secureStore.write( await secureStore.write(
@ -1918,14 +1918,14 @@ void main() {
test("recoverFromMnemonic using non empty seed on mainnet succeeds", test("recoverFromMnemonic using non empty seed on mainnet succeeds",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -1944,7 +1944,7 @@ void main() {
] ]
})).thenAnswer((realInvocation) async => {"0": []}); })).thenAnswer((realInvocation) async => {"0": []});
final wallet = await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
bool hasThrown = false; bool hasThrown = false;
try { try {
@ -1984,14 +1984,14 @@ void main() {
test("fullRescan succeeds", () async { test("fullRescan succeeds", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -2101,14 +2101,14 @@ void main() {
test("fullRescan fails", () async { test("fullRescan fails", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
@ -2130,7 +2130,7 @@ void main() {
when(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin)) when(cachedClient?.clearSharedTransactionCache(coin: Coin.dogecoin))
.thenAnswer((realInvocation) async {}); .thenAnswer((realInvocation) async {});
final wallet = await Hive.openBox(testWalletId); final wallet = await Hive.openBox<dynamic>(testWalletId);
// restore so we have something to rescan // restore so we have something to rescan
await doge?.recoverFromMnemonic( await doge?.recoverFromMnemonic(
@ -2211,14 +2211,14 @@ void main() {
// // test("fetchBuildTxData succeeds", () async { // // test("fetchBuildTxData succeeds", () async {
// // when(client.getServerFeatures()).thenAnswer((_) async => { // // when(client.getServerFeatures()).thenAnswer((_) async => {
// // "hosts": {}, // // "hosts": <dynamic, dynamic>{},
// // "pruning": null, // // "pruning": null,
// // "server_version": "Unit tests", // // "server_version": "Unit tests",
// // "protocol_min": "1.4", // // "protocol_min": "1.4",
// // "protocol_max": "1.4.2", // // "protocol_max": "1.4.2",
// // "genesis_hash": GENESIS_HASH_MAINNET, // // "genesis_hash": GENESIS_HASH_MAINNET,
// // "hash_function": "sha256", // // "hash_function": "sha256",
// // "services": [] // // "services": <dynamic>[]
// // }); // // });
// // when(client.getBatchHistory(args: historyBatchArgs0)) // // when(client.getBatchHistory(args: historyBatchArgs0))
// // .thenAnswer((_) async => historyBatchResponse); // // .thenAnswer((_) async => historyBatchResponse);
@ -2388,14 +2388,14 @@ void main() {
// test("fetchBuildTxData throws", () async { // test("fetchBuildTxData throws", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -2469,14 +2469,14 @@ void main() {
// test("build transaction succeeds", () async { // test("build transaction succeeds", () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);
@ -2672,14 +2672,14 @@ void main() {
test("refresh wallet mutex locked", () async { test("refresh wallet mutex locked", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -2697,7 +2697,7 @@ void main() {
] ]
})).thenAnswer((realInvocation) async => {"0": []}); })).thenAnswer((realInvocation) async => {"0": []});
final wallet = await Hive.openBox(testWalletId); final wallet = await Hive.openBox<dynamic>(testWalletId);
// recover to fill data // recover to fill data
await doge?.recoverFromMnemonic( await doge?.recoverFromMnemonic(
@ -2737,14 +2737,14 @@ void main() {
test("refresh wallet throws", () async { test("refresh wallet throws", () async {
when(client?.getBlockHeadTip()).thenThrow(Exception("some exception")); when(client?.getBlockHeadTip()).thenThrow(Exception("some exception"));
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -2764,7 +2764,7 @@ void main() {
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenThrow(Exception("some exception")); .thenThrow(Exception("some exception"));
final wallet = await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
// recover to fill data // recover to fill data
await doge?.recoverFromMnemonic( await doge?.recoverFromMnemonic(
@ -2805,14 +2805,14 @@ void main() {
// when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async =>
// {"height": 520481, "hex": "some block hex"}); // {"height": 520481, "hex": "some block hex"});
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.getBatchHistory(args: historyBatchArgs0)) // when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse); // .thenAnswer((_) async => historyBatchResponse);

View file

@ -1,6 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data';
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';
import 'package:decimal/decimal.dart'; import 'package:decimal/decimal.dart';
@ -20,7 +19,6 @@ import 'package:stackwallet/utilities/address_utils.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/format.dart';
import 'package:tuple/tuple.dart';
import 'firo_wallet_test.mocks.dart'; import 'firo_wallet_test.mocks.dart';
import 'firo_wallet_test_parameters.dart'; import 'firo_wallet_test_parameters.dart';
@ -44,7 +42,7 @@ void main() {
test("isolateRestore success", () async { test("isolateRestore success", () async {
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final txData = TransactionData.fromJson(dateTimeChunksJson); final txData = TransactionData.fromJson(dateTimeChunksJson);
final Map setData = {}; final Map<dynamic, dynamic> setData = {};
setData[1] = GetAnonymitySetSampleData.data; setData[1] = GetAnonymitySetSampleData.data;
final usedSerials = GetUsedSerialsSampleData.serials["serials"] as List; final usedSerials = GetUsedSerialsSampleData.serials["serials"] as List;
@ -87,8 +85,8 @@ void main() {
}); });
test("isolateRestore throws", () async { test("isolateRestore throws", () async {
final Map setData = {}; final Map<dynamic, dynamic> setData = {};
final usedSerials = []; final usedSerials = <dynamic>[];
expect( expect(
() => isolateRestore( () => isolateRestore(
@ -109,13 +107,11 @@ void main() {
false, false,
TEST_MNEMONIC, TEST_MNEMONIC,
2, 2,
Decimal.ten,
[], [],
459185, 459185,
Coin.firo, Coin.firo,
firoNetwork, firoNetwork,
[GetAnonymitySetSampleData.data], [GetAnonymitySetSampleData.data],
"en_US",
); );
expect(result, 1); expect(result, 1);
@ -208,7 +204,7 @@ void main() {
// "getJMintTransactions throws Error due to some invalid transactions passed to this function", // "getJMintTransactions throws Error due to some invalid transactions passed to this function",
// () { // () {
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final priceAPI = MockPriceAPI(); //
// //
// // mock price calls // // mock price calls
// when(priceAPI.getPricesAnd24hChange( baseCurrency: "USD")) // when(priceAPI.getPricesAnd24hChange( baseCurrency: "USD"))
@ -269,7 +265,7 @@ void main() {
// //
// test("getJMintTransactions success", () async { // test("getJMintTransactions success", () async {
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final priceAPI = MockPriceAPI(); //
// //
// // mock price calls // // mock price calls
// when(priceAPI.getPricesAnd24hChange( baseCurrency: "USD")) // when(priceAPI.getPricesAnd24hChange( baseCurrency: "USD"))
@ -532,7 +528,7 @@ void main() {
Hive.registerAdapter(LelantusCoinAdapter()); Hive.registerAdapter(LelantusCoinAdapter());
} }
final wallets = await Hive.openBox('wallets'); final wallets = await Hive.openBox<dynamic>('wallets');
await wallets.put('currentWalletName', testWalletName); await wallets.put('currentWalletName', testWalletName);
}); });
@ -540,7 +536,7 @@ void main() {
// final client = MockElectrumX(); // final client = MockElectrumX();
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final secureStore = FakeSecureStorage(); // final secureStore = FakeSecureStorage();
// final priceAPI = MockPriceAPI(); //
// //
// when(client.getServerFeatures()).thenAnswer((_) async => false); // when(client.getServerFeatures()).thenAnswer((_) async => false);
// //
@ -561,7 +557,7 @@ void main() {
// final client = MockElectrumX(); // final client = MockElectrumX();
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final secureStore = FakeSecureStorage(); // final secureStore = FakeSecureStorage();
// final priceAPI = MockPriceAPI(); //
// //
// when(client.ping()).thenThrow(Exception("Network connection failed")); // when(client.ping()).thenThrow(Exception("Network connection failed"));
// //
@ -583,19 +579,19 @@ void main() {
// final client = MockElectrumX(); // final client = MockElectrumX();
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final secureStore = FakeSecureStorage(); // final secureStore = FakeSecureStorage();
// final priceAPI = MockPriceAPI(); //
// //
// when(client.ping()).thenAnswer((_) async => true); // when(client.ping()).thenAnswer((_) async => true);
// //
// when(client.getServerFeatures()).thenAnswer((_) async => { // when(client.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// final firo = FiroWallet( // final firo = FiroWallet(
@ -616,19 +612,19 @@ void main() {
// final client = MockElectrumX(); // final client = MockElectrumX();
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final secureStore = FakeSecureStorage(); // final secureStore = FakeSecureStorage();
// final priceAPI = MockPriceAPI(); //
// //
// when(client.ping()).thenAnswer((_) async => true); // when(client.ping()).thenAnswer((_) async => true);
// //
// when(client.getServerFeatures()).thenAnswer((_) async => { // when(client.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// final firo = FiroWallet( // final firo = FiroWallet(
@ -652,21 +648,21 @@ void main() {
// final client = MockElectrumX(); // final client = MockElectrumX();
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final secureStore = FakeSecureStorage(); // final secureStore = FakeSecureStorage();
// final priceAPI = MockPriceAPI(); //
// when(priceAPI.getPrice(ticker: "tFIRO", baseCurrency: "USD")) // when(priceAPI.getPrice(ticker: "tFIRO", baseCurrency: "USD"))
// .thenAnswer((_) async => Decimal.fromInt(-1)); // .thenAnswer((_) async => Decimal.fromInt(-1));
// //
// when(client.ping()).thenAnswer((_) async => true); // when(client.ping()).thenAnswer((_) async => true);
// //
// when(client.getServerFeatures()).thenAnswer((_) async => { // when(client.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// final List<Map<String, dynamic>> emptyList = []; // final List<Map<String, dynamic>> emptyList = [];
@ -723,21 +719,21 @@ void main() {
// final client = MockElectrumX(); // final client = MockElectrumX();
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final secureStore = FakeSecureStorage(); // final secureStore = FakeSecureStorage();
// final priceAPI = MockPriceAPI(); //
// // when(priceAPI.getPrice(ticker: "tFIRO", baseCurrency: "USD")) // // when(priceAPI.getPrice(ticker: "tFIRO", baseCurrency: "USD"))
// // .thenAnswer((_) async => Decimal.fromInt(-1)); // // .thenAnswer((_) async => Decimal.fromInt(-1));
// //
// when(client.ping()).thenAnswer((_) async => true); // when(client.ping()).thenAnswer((_) async => true);
// //
// when(client.getServerFeatures()).thenAnswer((_) async => { // when(client.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// final List<Map<String, dynamic>> emptyList = []; // final List<Map<String, dynamic>> emptyList = [];
@ -828,7 +824,7 @@ void main() {
// final client = MockElectrumX(); // final client = MockElectrumX();
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final secureStore = FakeSecureStorage(); // final secureStore = FakeSecureStorage();
// final priceAPI = MockPriceAPI(); //
// // mock price calls // // mock price calls
// when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer( // when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
// (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)}); // (_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
@ -836,14 +832,14 @@ void main() {
// when(client.ping()).thenAnswer((_) async => true); // when(client.ping()).thenAnswer((_) async => true);
// //
// when(client.getServerFeatures()).thenAnswer((_) async => { // when(client.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// final List<Map<String, dynamic>> emptyList = []; // final List<Map<String, dynamic>> emptyList = [];
@ -905,7 +901,7 @@ void main() {
// final client = MockElectrumX(); // final client = MockElectrumX();
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final secureStore = FakeSecureStorage(); // final secureStore = FakeSecureStorage();
// final priceAPI = MockPriceAPI(); //
// final tracker = MockTransactionNotificationTracker(); // final tracker = MockTransactionNotificationTracker();
// //
// await Hive.openBox<dynamic>(DB.boxNamePrefs); // await Hive.openBox<dynamic>(DB.boxNamePrefs);
@ -971,12 +967,8 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
final tracker = MockTransactionNotificationTracker();
// mock price calls final tracker = MockTransactionNotificationTracker();
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
when(tracker.pendings).thenAnswer((realInvocation) => [ when(tracker.pendings).thenAnswer((realInvocation) => [
"51576e2230c2911a508aabb85bb50045f04b8dc958790ce2372986c3ebbe7d3e", "51576e2230c2911a508aabb85bb50045f04b8dc958790ce2372986c3ebbe7d3e",
@ -1048,8 +1040,8 @@ void main() {
// firo.unconfirmedTxs = {}; // firo.unconfirmedTxs = {};
final wallet = final wallet = await Hive.openBox<dynamic>(
await Hive.openBox("${testWalletId}refreshIfThereIsNewData"); "${testWalletId}refreshIfThereIsNewData");
await wallet.put('receivingAddresses', [ await wallet.put('receivingAddresses', [
"a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg",
"aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh", "aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh",
@ -1070,7 +1062,7 @@ void main() {
// final client = MockElectrumX(); // final client = MockElectrumX();
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final secureStore = FakeSecureStorage(); // final secureStore = FakeSecureStorage();
// final priceAPI = MockPriceAPI(); //
// final tracker = MockTransactionNotificationTracker(); // final tracker = MockTransactionNotificationTracker();
// //
// when(client.getTransaction(txHash: SampleGetTransactionData.txHash6)) // when(client.getTransaction(txHash: SampleGetTransactionData.txHash6))
@ -1126,7 +1118,6 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
when(client.broadcastTransaction( when(client.broadcastTransaction(
rawTx: rawTx:
@ -1155,7 +1146,6 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
final firo = FiroWallet( final firo = FiroWallet(
walletName: testWalletName, walletName: testWalletName,
@ -1225,11 +1215,6 @@ void main() {
when(client.getBlockHeadTip()).thenAnswer( when(client.getBlockHeadTip()).thenAnswer(
(_) async => {"height": 455873, "hex": "this value not used here"}); (_) async => {"height": 455873, "hex": "this value not used here"});
final priceAPI = MockPriceAPI();
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
final firo = FiroWallet( final firo = FiroWallet(
walletName: testWalletName, walletName: testWalletName,
walletId: "${testWalletId}buildMintTransaction", walletId: "${testWalletId}buildMintTransaction",
@ -1240,7 +1225,8 @@ void main() {
tracker: MockTransactionNotificationTracker(), tracker: MockTransactionNotificationTracker(),
); );
final wallet = await Hive.openBox("${testWalletId}buildMintTransaction"); final wallet =
await Hive.openBox<dynamic>("${testWalletId}buildMintTransaction");
await wallet.put("mintIndex", 0); await wallet.put("mintIndex", 0);
@ -1268,18 +1254,17 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
// mock electrumx client calls // mock electrumx client calls
when(client.getServerFeatures()).thenAnswer((_) async => { when(client.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client.getLatestCoinId()).thenAnswer((_) async => 1); when(client.getLatestCoinId()).thenAnswer((_) async => 1);
@ -1356,10 +1341,6 @@ void main() {
return SampleGetTransactionData.txData7; return SampleGetTransactionData.txData7;
}); });
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
final firo = FiroWallet( final firo = FiroWallet(
walletName: testWalletName, walletName: testWalletName,
walletId: "${testWalletId}recoverFromMnemonic", walletId: "${testWalletId}recoverFromMnemonic",
@ -1507,7 +1488,6 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
await secureStore.write( await secureStore.write(
key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC); key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC);
@ -1529,10 +1509,6 @@ void main() {
when(cachedClient.clearSharedTransactionCache(coin: Coin.firo)) when(cachedClient.clearSharedTransactionCache(coin: Coin.firo))
.thenAnswer((_) async => {}); .thenAnswer((_) async => {});
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
final firo = FiroWallet( final firo = FiroWallet(
walletName: testWalletName, walletName: testWalletName,
walletId: "${testWalletId}fullRescan", walletId: "${testWalletId}fullRescan",
@ -1545,7 +1521,7 @@ void main() {
// pre grab derivations in order to set up mock calls needed later on // pre grab derivations in order to set up mock calls needed later on
await firo.fillAddresses(TEST_MNEMONIC); await firo.fillAddresses(TEST_MNEMONIC);
final wallet = await Hive.openBox("${testWalletId}fullRescan"); final wallet = await Hive.openBox<dynamic>("${testWalletId}fullRescan");
final rcv = await secureStore.read( final rcv = await secureStore.read(
key: "${testWalletId}fullRescan_receiveDerivations"); key: "${testWalletId}fullRescan_receiveDerivations");
@ -1721,7 +1697,6 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
await secureStore.write( await secureStore.write(
key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC); key: '${testWalletId}fullRescan_mnemonic', value: TEST_MNEMONIC);
@ -1736,10 +1711,6 @@ void main() {
when(cachedClient.clearSharedTransactionCache(coin: Coin.firo)) when(cachedClient.clearSharedTransactionCache(coin: Coin.firo))
.thenAnswer((_) async => {}); .thenAnswer((_) async => {});
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
final firo = FiroWallet( final firo = FiroWallet(
walletName: testWalletName, walletName: testWalletName,
walletId: "${testWalletId}fullRescan", walletId: "${testWalletId}fullRescan",
@ -1864,18 +1835,17 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
// mock electrumx client calls // mock electrumx client calls
when(client.getServerFeatures()).thenAnswer((_) async => { when(client.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client.getLatestCoinId()).thenAnswer((_) async => 1); when(client.getLatestCoinId()).thenAnswer((_) async => 1);
@ -1893,9 +1863,6 @@ void main() {
when(cachedClient.getUsedCoinSerials(startNumber: 0, coin: Coin.firo)) when(cachedClient.getUsedCoinSerials(startNumber: 0, coin: Coin.firo))
.thenAnswer( .thenAnswer(
(_) async => GetUsedSerialsSampleData.serials['serials'] as List); (_) async => GetUsedSerialsSampleData.serials['serials'] as List);
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
final firo = FiroWallet( final firo = FiroWallet(
walletName: testWalletName, walletName: testWalletName,
@ -2142,18 +2109,17 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
// mock electrumx client calls // mock electrumx client calls
when(client.getServerFeatures()).thenAnswer((_) async => { when(client.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
final firo = FiroWallet( final firo = FiroWallet(
@ -2179,18 +2145,17 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
// mock electrumx client calls // mock electrumx client calls
when(client.getServerFeatures()).thenAnswer((_) async => { when(client.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
final firo = FiroWallet( final firo = FiroWallet(
@ -2343,7 +2308,6 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
// set mnemonic // set mnemonic
await secureStore.write( await secureStore.write(
@ -2367,14 +2331,14 @@ void main() {
// mock electrumx client calls // mock electrumx client calls
when(client.getServerFeatures()).thenAnswer((_) async => { when(client.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client.getLatestCoinId()).thenAnswer((_) async => 1); when(client.getLatestCoinId()).thenAnswer((_) async => 1);
@ -2434,10 +2398,6 @@ void main() {
when(client.getUTXOs(scripthash: anyNamed("scripthash"))) when(client.getUTXOs(scripthash: anyNamed("scripthash")))
.thenAnswer((_) async => []); .thenAnswer((_) async => []);
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
final firo = FiroWallet( final firo = FiroWallet(
walletName: testWalletName, walletName: testWalletName,
walletId: "${testWalletId}refresh", walletId: "${testWalletId}refresh",
@ -2469,7 +2429,7 @@ void main() {
// final client = MockElectrumX(); // final client = MockElectrumX();
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final secureStore = FakeSecureStorage(); // final secureStore = FakeSecureStorage();
// final priceAPI = MockPriceAPI(); //
// //
// String expectedTxid = "-1"; // String expectedTxid = "-1";
// when(client.getLatestCoinId()).thenAnswer((_) async => 1); // when(client.getLatestCoinId()).thenAnswer((_) async => 1);
@ -2651,7 +2611,7 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
when(client.getLatestCoinId()).thenAnswer((_) async => 1); when(client.getLatestCoinId()).thenAnswer((_) async => 1);
when(client.getBlockHeadTip()).thenAnswer( when(client.getBlockHeadTip()).thenAnswer(
(_) async => {"height": 459185, "hex": "... some block hex ..."}); (_) async => {"height": 459185, "hex": "... some block hex ..."});
@ -2679,10 +2639,6 @@ void main() {
coin: Coin.firo, coin: Coin.firo,
)).thenAnswer((_) async => GetAnonymitySetSampleData.data); )).thenAnswer((_) async => GetAnonymitySetSampleData.data);
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
// mock transaction calls // mock transaction calls
when(cachedClient.getTransaction( when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash0, txHash: SampleGetTransactionData.txHash0,
@ -2805,8 +2761,8 @@ void main() {
.thenAnswer((_) async => data); .thenAnswer((_) async => data);
} }
await wallet.put('_lelantus_coins', []); await wallet.put('_lelantus_coins', <dynamic>[]);
await wallet.put('jindex', []); await wallet.put('jindex', <dynamic>[]);
await wallet.put('mintIndex', 0); await wallet.put('mintIndex', 0);
await wallet.put('receivingAddresses', [ await wallet.put('receivingAddresses', [
"a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg", "a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg",
@ -2831,7 +2787,7 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
when(client.getLatestCoinId()).thenAnswer((_) async => 1); when(client.getLatestCoinId()).thenAnswer((_) async => 1);
when(client.getBlockHeadTip()).thenAnswer( when(client.getBlockHeadTip()).thenAnswer(
(_) async => {"height": 459185, "hex": "... some block hex ..."}); (_) async => {"height": 459185, "hex": "... some block hex ..."});
@ -2849,10 +2805,6 @@ void main() {
coin: Coin.firo, coin: Coin.firo,
)).thenAnswer((_) async => GetAnonymitySetSampleData.data); )).thenAnswer((_) async => GetAnonymitySetSampleData.data);
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
// mock transaction calls // mock transaction calls
when(cachedClient.getTransaction( when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash0, txHash: SampleGetTransactionData.txHash0,
@ -2985,11 +2937,6 @@ void main() {
]); ]);
await wallet await wallet
.put('changeAddresses', ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]); .put('changeAddresses', ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]);
expect(
() async => await firo.send(
toAddress: "aHZJsucDrhr4Uzzx6XXrKnaTgLxsEAokvV", amount: 100),
throwsA(isA<Exception>()));
}, timeout: const Timeout(Duration(minutes: 3))); }, timeout: const Timeout(Duration(minutes: 3)));
test("wallet balances", () async { test("wallet balances", () async {
@ -2999,10 +2946,6 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final priceAPI = MockPriceAPI();
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
// mock history calls // mock history calls
when(client.getHistory(scripthash: SampleGetHistoryData.scripthash0)) when(client.getHistory(scripthash: SampleGetHistoryData.scripthash0))
@ -3084,7 +3027,6 @@ void main() {
final client = MockElectrumX(); final client = MockElectrumX();
final cachedClient = MockCachedElectrumX(); final cachedClient = MockCachedElectrumX();
final secureStore = FakeSecureStorage(); final secureStore = FakeSecureStorage();
final priceAPI = MockPriceAPI();
// set mnemonic // set mnemonic
await secureStore.write( await secureStore.write(
@ -3093,14 +3035,14 @@ void main() {
// mock electrumx client calls // mock electrumx client calls
when(client.getServerFeatures()).thenAnswer((_) async => { when(client.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client.getLatestCoinId()).thenAnswer((_) async => 1); when(client.getLatestCoinId()).thenAnswer((_) async => 1);
@ -3160,10 +3102,6 @@ void main() {
when(client.getUTXOs(scripthash: anyNamed("scripthash"))) when(client.getUTXOs(scripthash: anyNamed("scripthash")))
.thenAnswer((_) async => []); .thenAnswer((_) async => []);
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
final firo = FiroWallet( final firo = FiroWallet(
walletName: testWalletName, walletName: testWalletName,
walletId: "${testWalletId}transactionData", walletId: "${testWalletId}transactionData",
@ -3174,7 +3112,8 @@ void main() {
tracker: MockTransactionNotificationTracker(), tracker: MockTransactionNotificationTracker(),
); );
final wallet = await Hive.openBox("${testWalletId}transactionData"); final wallet =
await Hive.openBox<dynamic>("${testWalletId}transactionData");
await wallet.put( await wallet.put(
'receivingAddresses', RefreshTestParams.receivingAddresses); 'receivingAddresses', RefreshTestParams.receivingAddresses);
await wallet.put('changeAddresses', RefreshTestParams.changeAddresses); await wallet.put('changeAddresses', RefreshTestParams.changeAddresses);
@ -3195,18 +3134,18 @@ void main() {
// final client = MockElectrumX(); // final client = MockElectrumX();
// final cachedClient = MockCachedElectrumX(); // final cachedClient = MockCachedElectrumX();
// final secureStore = FakeSecureStorage(); // final secureStore = FakeSecureStorage();
// final priceAPI = MockPriceAPI(); //
// //
// // mock electrumx client calls // // mock electrumx client calls
// when(client.getServerFeatures()).thenAnswer((_) async => { // when(client.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET, // "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// when(client.getBlockHeadTip()).thenAnswer( // when(client.getBlockHeadTip()).thenAnswer(
@ -3515,7 +3454,7 @@ void main() {
test("fetch and convert properly stored mnemonic to list of words", test("fetch and convert properly stored mnemonic to list of words",
() async { () async {
final store = FakeSecureStorage(); final store = FakeSecureStorage();
store.write( await store.write(
key: "some id_mnemonic", key: "some id_mnemonic",
value: "some test mnemonic string of words"); value: "some test mnemonic string of words");
@ -3543,7 +3482,7 @@ void main() {
test("attempt fetch and convert non existent mnemonic to list of words", test("attempt fetch and convert non existent mnemonic to list of words",
() async { () async {
final store = FakeSecureStorage(); final store = FakeSecureStorage();
store.write( await store.write(
key: "some id_mnemonic", key: "some id_mnemonic",
value: "some test mnemonic string of words"); value: "some test mnemonic string of words");

View file

@ -68,7 +68,7 @@ void main() async {
Hive.registerAdapter(WalletTypeAdapter()); Hive.registerAdapter(WalletTypeAdapter());
Hive.registerAdapter(UnspentCoinsInfoAdapter()); Hive.registerAdapter(UnspentCoinsInfoAdapter());
final wallets = await Hive.openBox('wallets'); final wallets = await Hive.openBox<dynamic>('wallets');
await wallets.put('currentWalletName', name); await wallets.put('currentWalletName', name);
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName); _walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);

View file

@ -225,8 +225,8 @@ void main() {
}); });
group("basic getters, setters, and functions", () { group("basic getters, setters, and functions", () {
final testWalletId = "NMCtestWalletID"; const testWalletId = "NMCtestWalletID";
final testWalletName = "NMCWallet"; const testWalletName = "NMCWallet";
MockElectrumX? client; MockElectrumX? client;
MockCachedElectrumX? cachedClient; MockCachedElectrumX? cachedClient;
@ -324,14 +324,14 @@ void main() {
test("get fees succeeds", () async { test("get fees succeeds", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 1)) when(client?.estimateFee(blocks: 1))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -357,14 +357,14 @@ void main() {
test("get fees fails", () async { test("get fees fails", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 1)) when(client?.estimateFee(blocks: 1))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -393,14 +393,14 @@ void main() {
// test("get maxFee", () async { // test("get maxFee", () async {
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.estimateFee(blocks: 20)) // when(client?.estimateFee(blocks: 20))
// .thenAnswer((realInvocation) async => Decimal.zero); // .thenAnswer((realInvocation) async => Decimal.zero);
@ -424,8 +424,8 @@ void main() {
}); });
group("Namecoin service class functions that depend on shared storage", () { group("Namecoin service class functions that depend on shared storage", () {
final testWalletId = "NMCtestWalletID"; const testWalletId = "NMCtestWalletID";
final testWalletName = "NMCWallet"; const testWalletName = "NMCWallet";
bool hiveAdaptersRegistered = false; bool hiveAdaptersRegistered = false;
@ -454,7 +454,7 @@ void main() {
Hive.registerAdapter(UtxoObjectAdapter()); Hive.registerAdapter(UtxoObjectAdapter());
Hive.registerAdapter(StatusAdapter()); Hive.registerAdapter(StatusAdapter());
final wallets = await Hive.openBox('wallets'); final wallets = await Hive.openBox<dynamic>('wallets');
await wallets.put('currentWalletName', testWalletName); await wallets.put('currentWalletName', testWalletName);
} }
@ -499,17 +499,17 @@ void main() {
test("initializeWallet mainnet throws bad network", () async { test("initializeWallet mainnet throws bad network", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
// await nmc?.initializeNew(); // await nmc?.initializeNew();
final wallets = await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
await expectLater( await expectLater(
() => nmc?.initializeExisting(), throwsA(isA<Exception>())) () => nmc?.initializeExisting(), throwsA(isA<Exception>()))
@ -525,19 +525,19 @@ void main() {
test("initializeWallet throws mnemonic overwrite exception", () async { test("initializeWallet throws mnemonic overwrite exception", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await secureStore.write( await secureStore.write(
key: "${testWalletId}_mnemonic", value: "some mnemonic"); key: "${testWalletId}_mnemonic", value: "some mnemonic");
final wallets = await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
await expectLater( await expectLater(
() => nmc?.initializeExisting(), throwsA(isA<Exception>())) () => nmc?.initializeExisting(), throwsA(isA<Exception>()))
.then((_) { .then((_) {
@ -553,14 +553,14 @@ void main() {
// "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", // "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match",
// () async { // () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// //
// bool hasThrown = false; // bool hasThrown = false;
@ -587,14 +587,14 @@ void main() {
"recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await secureStore.write( await secureStore.write(
@ -621,14 +621,14 @@ void main() {
test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { test("recoverFromMnemonic using empty seed on mainnet succeeds", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
@ -643,7 +643,7 @@ void main() {
when(client?.getBatchHistory(args: historyBatchArgs5)) when(client?.getBatchHistory(args: historyBatchArgs5))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
await DB.instance.init(); await DB.instance.init();
final wallet = await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
bool hasThrown = false; bool hasThrown = false;
try { try {
await nmc?.recoverFromMnemonic( await nmc?.recoverFromMnemonic(
@ -675,14 +675,14 @@ void main() {
test("get mnemonic list", () async { test("get mnemonic list", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
@ -697,7 +697,7 @@ void main() {
when(client?.getBatchHistory(args: historyBatchArgs5)) when(client?.getBatchHistory(args: historyBatchArgs5))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
final wallet = await Hive.openBox<dynamic>(testWalletId); await Hive.openBox<dynamic>(testWalletId);
await nmc?.recoverFromMnemonic( await nmc?.recoverFromMnemonic(
mnemonic: TEST_MNEMONIC, mnemonic: TEST_MNEMONIC,
@ -722,14 +722,14 @@ void main() {
test("recoverFromMnemonic using non empty seed on mainnet succeeds", test("recoverFromMnemonic using non empty seed on mainnet succeeds",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -796,14 +796,14 @@ void main() {
test("fullRescan succeeds", () async { test("fullRescan succeeds", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -1062,14 +1062,14 @@ void main() {
test("fullRescan fails", () async { test("fullRescan fails", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
@ -1275,14 +1275,14 @@ void main() {
test("prepareSend fails", () async { test("prepareSend fails", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -1558,14 +1558,14 @@ void main() {
test("refresh wallet mutex locked", () async { test("refresh wallet mutex locked", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -1634,14 +1634,14 @@ void main() {
when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async =>
{"height": 520481, "hex": "some block hex"}); {"height": 520481, "hex": "some block hex"});
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenAnswer((_) async => []); .thenAnswer((_) async => []);

View file

@ -272,8 +272,8 @@ void main() {
}); });
group("basic getters, setters, and functions", () { group("basic getters, setters, and functions", () {
final testWalletId = "ParticltestWalletID"; const testWalletId = "ParticltestWalletID";
final testWalletName = "ParticlWallet"; const testWalletName = "ParticlWallet";
MockElectrumX? client; MockElectrumX? client;
MockCachedElectrumX? cachedClient; MockCachedElectrumX? cachedClient;
@ -371,14 +371,14 @@ void main() {
test("get fees succeeds", () async { test("get fees succeeds", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 1)) when(client?.estimateFee(blocks: 1))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -404,14 +404,14 @@ void main() {
test("get fees fails", () async { test("get fees fails", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.estimateFee(blocks: 1)) when(client?.estimateFee(blocks: 1))
.thenAnswer((realInvocation) async => Decimal.zero); .thenAnswer((realInvocation) async => Decimal.zero);
@ -440,14 +440,14 @@ void main() {
// test("get maxFee", () async { // test("get maxFee", () async {
// when(client?.ping()).thenAnswer((_) async => true); // when(client?.ping()).thenAnswer((_) async => true);
// when(client?.getServerFeatures()).thenAnswer((_) async => { // when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {}, // "hosts": <dynamic, dynamic>{},
// "pruning": null, // "pruning": null,
// "server_version": "Unit tests", // "server_version": "Unit tests",
// "protocol_min": "1.4", // "protocol_min": "1.4",
// "protocol_max": "1.4.2", // "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_TESTNET, // "genesis_hash": GENESIS_HASH_TESTNET,
// "hash_function": "sha256", // "hash_function": "sha256",
// "services": [] // "services": <dynamic>[]
// }); // });
// when(client?.estimateFee(blocks: 20)) // when(client?.estimateFee(blocks: 20))
// .thenAnswer((realInvocation) async => Decimal.zero); // .thenAnswer((realInvocation) async => Decimal.zero);
@ -501,7 +501,7 @@ void main() {
Hive.registerAdapter(UtxoObjectAdapter()); Hive.registerAdapter(UtxoObjectAdapter());
Hive.registerAdapter(StatusAdapter()); Hive.registerAdapter(StatusAdapter());
final wallets = await Hive.openBox('wallets'); final wallets = await Hive.openBox<dynamic>('wallets');
await wallets.put('currentWalletName', testWalletName); await wallets.put('currentWalletName', testWalletName);
} }
@ -534,7 +534,7 @@ void main() {
// test("initializeWallet no network exception", () async { // test("initializeWallet no network exception", () async {
// when(client?.ping()).thenThrow(Exception("Network connection failed")); // when(client?.ping()).thenThrow(Exception("Network connection failed"));
// final wallets = await Hive.openBox(testWalletId); // final wallets = await Hive.openBox<dynamic> (testWalletId);
// expect(await nmc?.initializeExisting(), false); // expect(await nmc?.initializeExisting(), false);
// expect(secureStore.interactions, 0); // expect(secureStore.interactions, 0);
// verify(client?.ping()).called(1); // verify(client?.ping()).called(1);
@ -546,16 +546,16 @@ void main() {
test("initializeWallet mainnet throws bad network", () async { test("initializeWallet mainnet throws bad network", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
await expectLater( await expectLater(
() => part?.initializeExisting(), throwsA(isA<Exception>())) () => part?.initializeExisting(), throwsA(isA<Exception>()))
@ -569,19 +569,19 @@ void main() {
test("initializeWallet throws mnemonic overwrite exception", () async { test("initializeWallet throws mnemonic overwrite exception", () async {
when(client?.ping()).thenAnswer((_) async => true); when(client?.ping()).thenAnswer((_) async => true);
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await secureStore.write( await secureStore.write(
key: "${testWalletId}_mnemonic", value: "some mnemonic"); key: "${testWalletId}_mnemonic", value: "some mnemonic");
await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
await expectLater( await expectLater(
() => part?.initializeExisting(), throwsA(isA<Exception>())) () => part?.initializeExisting(), throwsA(isA<Exception>()))
.then((_) { .then((_) {
@ -595,14 +595,14 @@ void main() {
"recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_TESTNET, "genesis_hash": GENESIS_HASH_TESTNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
bool hasThrown = false; bool hasThrown = false;
@ -628,14 +628,14 @@ void main() {
"recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
await secureStore.write( await secureStore.write(
@ -662,14 +662,14 @@ void main() {
test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { test("recoverFromMnemonic using empty seed on mainnet succeeds", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
@ -681,7 +681,7 @@ void main() {
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
// await DB.instance.init(); // await DB.instance.init();
final wallet = await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
bool hasThrown = false; bool hasThrown = false;
try { try {
await part?.recoverFromMnemonic( await part?.recoverFromMnemonic(
@ -711,14 +711,14 @@ void main() {
test("get mnemonic list", () async { test("get mnemonic list", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
@ -729,7 +729,7 @@ void main() {
when(client?.getBatchHistory(args: historyBatchArgs3)) when(client?.getBatchHistory(args: historyBatchArgs3))
.thenAnswer((_) async => emptyHistoryBatchResponse); .thenAnswer((_) async => emptyHistoryBatchResponse);
await Hive.openBox(testWalletId); await Hive.openBox<dynamic>(testWalletId);
await part?.recoverFromMnemonic( await part?.recoverFromMnemonic(
mnemonic: TEST_MNEMONIC, mnemonic: TEST_MNEMONIC,
@ -752,14 +752,14 @@ void main() {
test("recoverFromMnemonic using non empty seed on mainnet succeeds", test("recoverFromMnemonic using non empty seed on mainnet succeeds",
() async { () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -819,14 +819,14 @@ void main() {
test("fullRescan succeeds", () async { test("fullRescan succeeds", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -1011,14 +1011,14 @@ void main() {
test("fullRescan fails", () async { test("fullRescan fails", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
@ -1213,14 +1213,14 @@ void main() {
test("prepareSend fails", () async { test("prepareSend fails", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -1269,15 +1269,15 @@ void main() {
// modify addresses to properly mock data to build a tx // modify addresses to properly mock data to build a tx
final rcv44 = await secureStore.read( final rcv44 = await secureStore.read(
key: testWalletId + "_receiveDerivationsP2PKH"); key: "${testWalletId}_receiveDerivationsP2PKH");
await secureStore.write( await secureStore.write(
key: testWalletId + "_receiveDerivationsP2PKH", key: "${testWalletId}_receiveDerivationsP2PKH",
value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw",
"16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ"));
final rcv84 = await secureStore.read( final rcv84 = await secureStore.read(
key: testWalletId + "_receiveDerivationsP2WPKH"); key: "${testWalletId}_receiveDerivationsP2WPKH");
await secureStore.write( await secureStore.write(
key: testWalletId + "_receiveDerivationsP2WPKH", key: "${testWalletId}_receiveDerivationsP2WPKH",
value: rcv84?.replaceFirst( value: rcv84?.replaceFirst(
"pw1qvr6ehcm44vvqe96mxy9zw9aa5sa5yezvr2r94s", "pw1qvr6ehcm44vvqe96mxy9zw9aa5sa5yezvr2r94s",
"pw1q66xtkhqzcue808nlg8tp48uq7fshmaddljtkpy")); "pw1q66xtkhqzcue808nlg8tp48uq7fshmaddljtkpy"));
@ -1448,7 +1448,7 @@ void main() {
// // ); // // );
// // // //
// // // set node // // // set node
// // final wallet = await Hive.openBox(testWalletId); // // final wallet = await Hive.openBox<dynamic> (testWalletId);
// // await wallet.put("nodes", { // // await wallet.put("nodes", {
// // "default": { // // "default": {
// // "id": "some nodeID", // // "id": "some nodeID",
@ -1484,14 +1484,14 @@ void main() {
test("refresh wallet mutex locked", () async { test("refresh wallet mutex locked", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getBatchHistory(args: historyBatchArgs0)) when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse); .thenAnswer((_) async => historyBatchResponse);
@ -1553,14 +1553,14 @@ void main() {
when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async =>
{"height": 520481, "hex": "some block hex"}); {"height": 520481, "hex": "some block hex"});
when(client?.getServerFeatures()).thenAnswer((_) async => { when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {}, "hosts": <dynamic, dynamic>{},
"pruning": null, "pruning": null,
"server_version": "Unit tests", "server_version": "Unit tests",
"protocol_min": "1.4", "protocol_min": "1.4",
"protocol_max": "1.4.2", "protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET, "genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256", "hash_function": "sha256",
"services": [] "services": <dynamic>[]
}); });
when(client?.getHistory(scripthash: anyNamed("scripthash"))) when(client?.getHistory(scripthash: anyNamed("scripthash")))
.thenAnswer((_) async => []); .thenAnswer((_) async => []);

View file

@ -66,7 +66,7 @@ void main() async {
Hive.registerAdapter(WalletTypeAdapter()); Hive.registerAdapter(WalletTypeAdapter());
Hive.registerAdapter(UnspentCoinsInfoAdapter()); Hive.registerAdapter(UnspentCoinsInfoAdapter());
final wallets = await Hive.openBox('wallets'); final wallets = await Hive.openBox<dynamic>('wallets');
await wallets.put('currentWalletName', name); await wallets.put('currentWalletName', name);
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName); _walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);