WIP test fixing

This commit is contained in:
julian 2023-01-19 13:07:20 -06:00
parent e2b7c07b78
commit aafca9289d
6 changed files with 503 additions and 1191 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -75,7 +75,8 @@ void main() {
usedSerials,
firoNetwork,
);
final result = await staticProcessRestore(txData, message);
const currentHeight = 100000000000;
final result = await staticProcessRestore(txData, message, currentHeight);
expect(result, isA<Map<String, dynamic>>());
expect(result["mintIndex"], 8);
@ -371,7 +372,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -386,7 +386,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -401,7 +400,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -416,7 +414,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -431,7 +428,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -446,7 +442,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -466,7 +461,6 @@ void main() {
client: client,
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
final bool result = await firo.testNetworkConnection();
@ -485,7 +479,6 @@ void main() {
client: client,
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
final bool result = await firo.testNetworkConnection();
@ -504,7 +497,6 @@ void main() {
client: client,
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
final bool result = await firo.testNetworkConnection();
@ -558,7 +550,7 @@ void main() {
// client: client,coin: Coin.firo,
// cachedClient: cachedClient,
// secureStore: secureStore,
// priceAPI: priceAPI,
//
// tracker: MockTransactionNotificationTracker(),
// );
//
@ -580,7 +572,7 @@ void main() {
// coin: Coin.firo,
// cachedClient: cachedClient,
// secureStore: secureStore,
// priceAPI: priceAPI,
//
// tracker: MockTransactionNotificationTracker(),
// );
//
@ -613,7 +605,7 @@ void main() {
// client: client,
// cachedClient: cachedClient,
// secureStore: secureStore,
// priceAPI: priceAPI,
//
// tracker: MockTransactionNotificationTracker(),
// );
//
@ -645,7 +637,7 @@ void main() {
// client: client,
// cachedClient: cachedClient,
// secureStore: secureStore,
// priceAPI: priceAPI,
//
// tracker: MockTransactionNotificationTracker(),
// );
//
@ -691,7 +683,7 @@ void main() {
// client: client,
// cachedClient: cachedClient,
// secureStore: secureStore,
// priceAPI: priceAPI,
//
// tracker: MockTransactionNotificationTracker(),
// );
//
@ -762,7 +754,7 @@ void main() {
// client: client,
// cachedClient: cachedClient,
// secureStore: secureStore,
// priceAPI: priceAPI,
//
// tracker: MockTransactionNotificationTracker(),
// );
//
@ -868,7 +860,7 @@ void main() {
// client: client,
// cachedClient: cachedClient,
// secureStore: secureStore,
// priceAPI: priceAPI,
//
// tracker: MockTransactionNotificationTracker(),
// );
//
@ -954,7 +946,7 @@ void main() {
// client: client,
// cachedClient: cachedClient,
// secureStore: secureStore,
// priceAPI: priceAPI,
//
// tracker: tracker,
// );
//
@ -1051,14 +1043,13 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: tracker,
);
// firo.unconfirmedTxs = {};
final wallet =
await Hive.openBox(testWalletId + "refreshIfThereIsNewData");
await Hive.openBox("${testWalletId}refreshIfThereIsNewData");
await wallet.put('receivingAddresses', [
"a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg",
"aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh",
@ -1119,7 +1110,7 @@ void main() {
// client: client,
// cachedClient: cachedClient,
// secureStore: secureStore,
// priceAPI: priceAPI,
//
// tracker: tracker,
// );
//
@ -1150,7 +1141,6 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -1174,7 +1164,6 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -1248,7 +1237,6 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -1379,7 +1367,6 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -1553,13 +1540,12 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
// pre grab derivations in order to set up mock calls needed later on
await firo.fillAddresses(TEST_MNEMONIC);
final wallet = await Hive.openBox(testWalletId + "fullRescan");
final wallet = await Hive.openBox("${testWalletId}fullRescan");
final rcv = await secureStore.read(
key: "${testWalletId}fullRescan_receiveDerivations");
@ -1761,7 +1747,6 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -1919,7 +1904,6 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -2179,7 +2163,6 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -2212,12 +2195,11 @@ void main() {
final firo = FiroWallet(
walletName: testWalletName,
walletId: testWalletId + "recoverFromMnemonic fails mainnet",
walletId: "${testWalletId}recoverFromMnemonic fails mainnet",
coin: Coin.firo,
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -2230,98 +2212,6 @@ void main() {
throwsA(isA<Exception>()));
});
test("incrementAddressIndexForChain receiving", () async {
final firo = FiroWallet(
walletId: "${testWalletId}incrementAddressIndexForChain receiving",
walletName: testWalletName,
coin: Coin.firo,
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
final wallet = await Hive.openBox<dynamic>(
"${testWalletId}incrementAddressIndexForChain receiving");
await wallet.put("receivingIndex", 1);
await expectLater(() async => await firo.incrementAddressIndexForChain(0),
returnsNormally);
expect(wallet.get("receivingIndex"), 2);
});
test("incrementAddressIndexForChain change", () async {
final firo = FiroWallet(
walletId: "${testWalletId}incrementAddressIndexForChain change",
walletName: testWalletName,
coin: Coin.firo,
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
final wallet = await Hive.openBox(
"${testWalletId}incrementAddressIndexForChain change");
await wallet.put("changeIndex", 1);
await expectLater(() async => await firo.incrementAddressIndexForChain(1),
returnsNormally);
expect(wallet.get("changeIndex"), 2);
});
test("addToAddressesArrayForChain receiving", () async {
final firo = FiroWallet(
walletId: "${testWalletId}addToAddressesArrayForChain receiving",
walletName: testWalletName,
coin: Coin.firo,
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
final wallet = await Hive.openBox<dynamic>(
"${testWalletId}addToAddressesArrayForChain receiving");
await expectLater(
() async =>
await firo.addToAddressesArrayForChain("Some Address String", 0),
returnsNormally);
expect(wallet.get("receivingAddresses"), ["Some Address String"]);
});
test("addToAddressesArrayForChain change", () async {
final firo = FiroWallet(
walletId: "${testWalletId}addToAddressesArrayForChain change",
walletName: testWalletName,
coin: Coin.firo,
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
final wallet = await Hive.openBox<dynamic>(
"${testWalletId}addToAddressesArrayForChain change");
await wallet.put("changeAddresses", ["some address A"]);
await expectLater(
() async =>
await firo.addToAddressesArrayForChain("Some Address B", 1),
returnsNormally);
expect(
wallet.get("changeAddresses"), ["some address A", "Some Address B"]);
});
test("checkReceivingAddressForTransactions fails", () async {
final firo = FiroWallet(
walletId: "${testWalletId}checkReceivingAddressForTransactions fails",
@ -2330,7 +2220,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -2358,7 +2247,6 @@ void main() {
client: client,
cachedClient: MockCachedElectrumX(),
secureStore: secureStore,
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -2385,13 +2273,12 @@ void main() {
when(client.getLatestCoinId()).thenAnswer((_) async => 1);
final firo = FiroWallet(
walletId: testWalletId + "exit",
walletId: "${testWalletId}exit",
walletName: testWalletName,
coin: Coin.firo,
client: client,
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -2412,7 +2299,7 @@ void main() {
// client: client,
// cachedClient: MockCachedElectrumX(),
// secureStore: FakeSecureStorage(),
// priceAPI: MockPriceAPI(),
//
// tracker: MockTransactionNotificationTracker(),
// );
//
@ -2435,13 +2322,12 @@ void main() {
(_) async => GetUsedSerialsSampleData.serials['serials'] as List);
final firo = FiroWallet(
walletId: testWalletId + "getUsedCoinSerials",
walletId: "${testWalletId}getUsedCoinSerials",
walletName: testWalletName,
coin: Coin.firo,
client: client,
cachedClient: cachedClient,
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -2559,7 +2445,6 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -2669,7 +2554,7 @@ void main() {
// client: client,
// cachedClient: cachedClient,
// secureStore: secureStore,
// priceAPI: priceAPI,
//
// tracker: MockTransactionNotificationTracker(),
// );
//
@ -2758,7 +2643,7 @@ void main() {
// expect(result.length, 64);
// }, timeout: const Timeout(Duration(minutes: 3)));
test("send fails due to insufficient balance", () async {
test("prepareSend fails due to insufficient balance", () async {
TestWidgetsFlutterBinding.ensureInitialized();
const MethodChannel('uk.spiralarm.flutter/devicelocale')
.setMockMethodCallHandler((methodCall) async => 'en_US');
@ -2851,7 +2736,6 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -2933,8 +2817,9 @@ void main() {
.put('changeAddresses', ["a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w"]);
expect(
() async => await firo.send(
toAddress: "aHZJsucDrhr4Uzzx6XXrKnaTgLxsEAokvV", amount: 100),
() async => await firo.prepareSend(
address: "aHZJsucDrhr4Uzzx6XXrKnaTgLxsEAokvV",
satoshiAmount: 100),
throwsA(isA<Exception>()));
}, timeout: const Timeout(Duration(minutes: 3)));
@ -3021,7 +2906,6 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -3173,7 +3057,6 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: FakeSecureStorage(),
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
@ -3192,211 +3075,9 @@ void main() {
"a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w",
]);
expect(await firo.pendingBalance, Decimal.zero);
expect(await firo.availableBalance, Decimal.parse("0.00021594"));
expect(await firo.totalBalance, Decimal.parse("0.00021594"));
});
test("wallet balance minus maxfee - wallet balance is zero", () async {
TestWidgetsFlutterBinding.ensureInitialized();
const MethodChannel('uk.spiralarm.flutter/devicelocale')
.setMockMethodCallHandler((methodCall) async => 'en_US');
final client = MockElectrumX();
final cachedClient = MockCachedElectrumX();
final priceAPI = MockPriceAPI();
final secureStore = FakeSecureStorage();
when(client.getBatchHistory(args: batchHistoryRequest0))
.thenAnswer((realInvocation) async => batchHistoryResponse0);
when(client.getBatchUTXOs(args: batchUtxoRequest))
.thenAnswer((realInvocation) async => {});
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
// mock history calls
when(client.getHistory(scripthash: SampleGetHistoryData.scripthash0))
.thenAnswer((_) async => SampleGetHistoryData.data0);
when(client.getHistory(scripthash: SampleGetHistoryData.scripthash1))
.thenAnswer((_) async => SampleGetHistoryData.data1);
when(client.getHistory(scripthash: SampleGetHistoryData.scripthash2))
.thenAnswer((_) async => SampleGetHistoryData.data2);
when(client.getHistory(scripthash: SampleGetHistoryData.scripthash3))
.thenAnswer((_) async => SampleGetHistoryData.data3);
// mock transaction calls
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash0,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData0);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash1,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData1);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash2,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData2);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash3,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData3);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash4,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData4);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash5,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData5);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash6,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData6);
final firo = FiroWallet(
walletId: "${testWalletId}wallet balance minus maxfee",
walletName: "pendingBalance wallet name",
coin: Coin.firo,
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
await secureStore.write(
key: "${testWalletId}wallet balance minus maxfee_mnemonic",
value: TEST_MNEMONIC);
final wallet = await Hive.openBox<dynamic>(
"${testWalletId}wallet balance minus maxfee");
await wallet.put('receivingAddresses', [
"a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg",
"aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh",
"aKmXfS7nEZdqWBGRdAXcyMoEoKhZQDPBoq",
]);
await wallet.put('changeAddresses', [
"a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w",
]);
expect(await firo.maxFee, 0); // ???
expect(await firo.balanceMinusMaxFee, Decimal.parse("0"));
});
test("wallet balance minus maxfee - wallet balance is not zero", () async {
TestWidgetsFlutterBinding.ensureInitialized();
const MethodChannel('uk.spiralarm.flutter/devicelocale')
.setMockMethodCallHandler((methodCall) async => 'en_US');
final client = MockElectrumX();
final cachedClient = MockCachedElectrumX();
final priceAPI = MockPriceAPI();
final secureStore = FakeSecureStorage();
// mock price calls
when(priceAPI.getPricesAnd24hChange(baseCurrency: "USD")).thenAnswer(
(_) async => {Coin.firo: Tuple2(Decimal.fromInt(10), 1.0)});
// mock history calls
when(client.getHistory(scripthash: SampleGetHistoryData.scripthash0))
.thenAnswer((_) async => SampleGetHistoryData.data0);
when(client.getHistory(scripthash: SampleGetHistoryData.scripthash1))
.thenAnswer((_) async => SampleGetHistoryData.data1);
when(client.getHistory(scripthash: SampleGetHistoryData.scripthash2))
.thenAnswer((_) async => SampleGetHistoryData.data2);
when(client.getHistory(scripthash: SampleGetHistoryData.scripthash3))
.thenAnswer((_) async => SampleGetHistoryData.data3);
when(client.getBatchHistory(args: batchHistoryRequest0))
.thenAnswer((realInvocation) async => batchHistoryResponse0);
when(client.getBatchUTXOs(args: batchUtxoRequest))
.thenAnswer((realInvocation) async => {});
// mock transaction calls
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash0,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData0);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash1,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData1);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash2,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData2);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash3,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData3);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash4,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData4);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash5,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData5);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash6,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData6);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash7,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData7);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash8,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData8);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash9,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData9);
when(cachedClient.getTransaction(
txHash: SampleGetTransactionData.txHash10,
coin: Coin.firo,
)).thenAnswer((_) async => SampleGetTransactionData.txData10);
final firo = FiroWallet(
walletId: "${testWalletId}wallet balance minus maxfee",
walletName: "pendingBalance wallet name",
client: client,
coin: Coin.firo,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
await secureStore.write(
key: "${testWalletId}wallet balance minus maxfee_mnemonic",
value: TEST_MNEMONIC);
final wallet = await Hive.openBox<dynamic>(
"${testWalletId}wallet balance minus maxfee");
await wallet.put('_lelantus_coins', SampleLelantus.lelantusCoins);
await wallet.put('jindex', [2, 4, 6]);
await wallet.put('mintIndex', 8);
await wallet.put('receivingAddresses', [
"a8VV7vMzJdTQj1eLEJNskhLEBUxfNWhpAg",
"aPjLWDTPQsoPHUTxKBNRzoebDALj3eTcfh",
"aKmXfS7nEZdqWBGRdAXcyMoEoKhZQDPBoq",
]);
await wallet.put('changeAddresses', [
"a5V5r6We6mNZzWJwGwEeRML3mEYLjvK39w",
]);
expect(await firo.maxFee, 8914);
expect(await firo.balanceMinusMaxFee, Decimal.parse("0.0001268"));
expect(firo.balance.getPending(), Decimal.zero);
expect(firo.balance.getSpendable(), Decimal.parse("0.00021594"));
expect(firo.balance.getTotal(), Decimal.parse("0.00021594"));
});
test("get transactionData", () async {
@ -3490,11 +3171,10 @@ void main() {
client: client,
cachedClient: cachedClient,
secureStore: secureStore,
priceAPI: priceAPI,
tracker: MockTransactionNotificationTracker(),
);
final wallet = await Hive.openBox(testWalletId + "transactionData");
final wallet = await Hive.openBox("${testWalletId}transactionData");
await wallet.put(
'receivingAddresses', RefreshTestParams.receivingAddresses);
await wallet.put('changeAddresses', RefreshTestParams.changeAddresses);
@ -3634,7 +3314,7 @@ void main() {
// client: client,
// cachedClient: cachedClient,
// secureStore: secureStore,
// priceAPI: priceAPI,
//
// tracker: MockTransactionNotificationTracker(),
// );
//
@ -3734,7 +3414,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -3774,7 +3453,6 @@ void main() {
client: client,
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -3796,7 +3474,6 @@ void main() {
client: client,
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -3813,7 +3490,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -3828,7 +3504,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -3851,7 +3526,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: store,
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
final List<String> result = await firo.mnemonic;
@ -3880,7 +3554,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: store,
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
final mnemonic = await firo.mnemonic;
@ -3896,7 +3569,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);
@ -3914,7 +3586,6 @@ void main() {
client: MockElectrumX(),
cachedClient: MockCachedElectrumX(),
secureStore: FakeSecureStorage(),
priceAPI: MockPriceAPI(),
tracker: MockTransactionNotificationTracker(),
);

View file

@ -15,7 +15,6 @@ import 'package:stackwallet/services/price.dart';
import 'package:stackwallet/services/transaction_notification_tracker.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:tuple/tuple.dart';
import 'namecoin_history_sample_data.dart';
import 'namecoin_transaction_data_samples.dart';
@ -102,7 +101,6 @@ void main() {
group("validate mainnet namecoin addresses", () {
MockElectrumX? client;
MockCachedElectrumX? cachedClient;
MockPriceAPI? priceAPI;
late FakeSecureStorage secureStore;
MockTransactionNotificationTracker? tracker;
@ -111,7 +109,6 @@ void main() {
setUp(() {
client = MockElectrumX();
cachedClient = MockCachedElectrumX();
priceAPI = MockPriceAPI();
secureStore = FakeSecureStorage();
tracker = MockTransactionNotificationTracker();
@ -122,7 +119,6 @@ void main() {
client: client!,
cachedClient: cachedClient!,
tracker: tracker!,
priceAPI: priceAPI,
secureStore: secureStore,
);
});
@ -136,7 +132,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
test("valid mainnet bech32 p2wpkh address type", () {
@ -148,7 +143,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
test("invalid bech32 address type", () {
@ -160,7 +154,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
test("address has no matching script", () {
@ -172,14 +165,12 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
});
group("testNetworkConnection", () {
MockElectrumX? client;
MockCachedElectrumX? cachedClient;
MockPriceAPI? priceAPI;
late FakeSecureStorage secureStore;
MockTransactionNotificationTracker? tracker;
@ -188,7 +179,6 @@ void main() {
setUp(() {
client = MockElectrumX();
cachedClient = MockCachedElectrumX();
priceAPI = MockPriceAPI();
secureStore = FakeSecureStorage();
tracker = MockTransactionNotificationTracker();
@ -199,7 +189,6 @@ void main() {
client: client!,
cachedClient: cachedClient!,
tracker: tracker!,
priceAPI: priceAPI,
secureStore: secureStore,
);
});
@ -212,7 +201,6 @@ void main() {
verify(client?.ping()).called(1);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("attempted connection fails due to exception", () async {
@ -223,7 +211,6 @@ void main() {
verify(client?.ping()).called(1);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("attempted connection test success", () async {
@ -234,7 +221,6 @@ void main() {
verify(client?.ping()).called(1);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
});
@ -244,7 +230,7 @@ void main() {
MockElectrumX? client;
MockCachedElectrumX? cachedClient;
MockPriceAPI? priceAPI;
late FakeSecureStorage secureStore;
MockTransactionNotificationTracker? tracker;
@ -253,7 +239,7 @@ void main() {
setUp(() async {
client = MockElectrumX();
cachedClient = MockCachedElectrumX();
priceAPI = MockPriceAPI();
secureStore = FakeSecureStorage();
tracker = MockTransactionNotificationTracker();
@ -264,7 +250,6 @@ void main() {
client: client!,
cachedClient: cachedClient!,
tracker: tracker!,
priceAPI: priceAPI,
secureStore: secureStore,
);
});
@ -274,7 +259,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get networkType test", () async {
@ -285,14 +269,12 @@ void main() {
client: client!,
cachedClient: cachedClient!,
tracker: tracker!,
priceAPI: priceAPI,
secureStore: secureStore,
);
expect(Coin.namecoin, Coin.namecoin);
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get cryptoCurrency", () async {
@ -300,7 +282,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get coinName", () async {
@ -308,7 +289,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get coinTicker", () async {
@ -316,7 +296,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get and set walletName", () async {
@ -326,7 +305,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("estimateTxFee", () async {
@ -341,7 +319,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get fees succeeds", () async {
@ -375,7 +352,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get fees fails", () async {
@ -412,7 +388,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
// test("get maxFee", () async {
@ -444,7 +419,7 @@ void main() {
// verifyNoMoreInteractions(client);
// verifyNoMoreInteractions(cachedClient);
// verifyNoMoreInteractions(tracker);
// verifyNoMoreInteractions(priceAPI);
//
// });
});
@ -456,7 +431,7 @@ void main() {
MockElectrumX? client;
MockCachedElectrumX? cachedClient;
MockPriceAPI? priceAPI;
late FakeSecureStorage secureStore;
MockTransactionNotificationTracker? tracker;
@ -485,7 +460,7 @@ void main() {
client = MockElectrumX();
cachedClient = MockCachedElectrumX();
priceAPI = MockPriceAPI();
secureStore = FakeSecureStorage();
tracker = MockTransactionNotificationTracker();
@ -496,7 +471,6 @@ void main() {
client: client!,
cachedClient: cachedClient!,
tracker: tracker!,
priceAPI: priceAPI,
secureStore: secureStore,
);
});
@ -508,18 +482,18 @@ void main() {
// verify(client?.ping()).called(1);
// verifyNoMoreInteractions(client);
// verifyNoMoreInteractions(cachedClient);
// verifyNoMoreInteractions(priceAPI);
//
// });
// test("initializeWallet no network exception", () async {
// 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(secureStore.interactions, 0);
// verify(client?.ping()).called(1);
// verifyNoMoreInteractions(client);
// verifyNoMoreInteractions(cachedClient);
// verifyNoMoreInteractions(priceAPI);
//
// });
test("initializeWallet mainnet throws bad network", () async {
@ -535,16 +509,16 @@ void main() {
"services": []
});
// await nmc?.initializeNew();
final wallets = await Hive.openBox(testWalletId);
final wallets = await Hive.openBox<dynamic>(testWalletId);
expectLater(() => nmc?.initializeExisting(), throwsA(isA<Exception>()))
await expectLater(
() => nmc?.initializeExisting(), throwsA(isA<Exception>()))
.then((_) {
expect(secureStore.interactions, 0);
// verify(client?.ping()).called(1);
// verify(client?.getServerFeatures()).called(1);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
});
@ -563,15 +537,15 @@ void main() {
await secureStore.write(
key: "${testWalletId}_mnemonic", value: "some mnemonic");
final wallets = await Hive.openBox(testWalletId);
expectLater(() => nmc?.initializeExisting(), throwsA(isA<Exception>()))
final wallets = await Hive.openBox<dynamic>(testWalletId);
await expectLater(
() => nmc?.initializeExisting(), throwsA(isA<Exception>()))
.then((_) {
expect(secureStore.interactions, 1);
// verify(client?.ping()).called(1);
// verify(client?.getServerFeatures()).called(1);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
});
@ -606,7 +580,7 @@ void main() {
// expect(secureStore.interactions, 0);
// verifyNoMoreInteractions(client);
// verifyNoMoreInteractions(cachedClient);
// verifyNoMoreInteractions(priceAPI);
//
// });
test(
@ -643,7 +617,6 @@ void main() {
expect(secureStore.interactions, 2);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("recoverFromMnemonic using empty seed on mainnet succeeds", () async {
@ -670,7 +643,7 @@ void main() {
when(client?.getBatchHistory(args: historyBatchArgs5))
.thenAnswer((_) async => emptyHistoryBatchResponse);
await DB.instance.init();
final wallet = await Hive.openBox(testWalletId);
final wallet = await Hive.openBox<dynamic>(testWalletId);
bool hasThrown = false;
try {
await nmc?.recoverFromMnemonic(
@ -698,7 +671,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get mnemonic list", () async {
@ -725,7 +697,7 @@ void main() {
when(client?.getBatchHistory(args: historyBatchArgs5))
.thenAnswer((_) async => emptyHistoryBatchResponse);
final wallet = await Hive.openBox(testWalletId);
final wallet = await Hive.openBox<dynamic>(testWalletId);
await nmc?.recoverFromMnemonic(
mnemonic: TEST_MNEMONIC,
@ -745,7 +717,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("recoverFromMnemonic using non empty seed on mainnet succeeds",
@ -821,7 +792,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("fullRescan succeeds", () async {
@ -1088,7 +1058,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("fullRescan fails", () async {
@ -1302,7 +1271,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("prepareSend fails", () async {
@ -1367,21 +1335,21 @@ void main() {
// modify addresses to properly mock data to build a tx
final rcv44 = await secureStore.read(
key: testWalletId + "_receiveDerivationsP2PKH");
key: "${testWalletId}_receiveDerivationsP2PKH");
await secureStore.write(
key: testWalletId + "_receiveDerivationsP2PKH",
key: "${testWalletId}_receiveDerivationsP2PKH",
value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw",
"16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ"));
final rcv49 =
await secureStore.read(key: testWalletId + "_receiveDerivationsP2SH");
await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH");
await secureStore.write(
key: testWalletId + "_receiveDerivationsP2SH",
key: "${testWalletId}_receiveDerivationsP2SH",
value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk",
"36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g"));
final rcv84 = await secureStore.read(
key: testWalletId + "_receiveDerivationsP2WPKH");
key: "${testWalletId}_receiveDerivationsP2WPKH");
await secureStore.write(
key: testWalletId + "_receiveDerivationsP2WPKH",
key: "${testWalletId}_receiveDerivationsP2WPKH",
value: rcv84?.replaceFirst(
"bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0",
"bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc"));
@ -1443,7 +1411,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("confirmSend no hex", () async {
@ -1459,7 +1426,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("confirmSend hex is not string", () async {
@ -1475,7 +1441,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("confirmSend hex is string but missing other data", () async {
@ -1495,7 +1460,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("confirmSend fails due to vSize being greater than fee", () async {
@ -1516,7 +1480,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("confirmSend fails when broadcast transactions throws", () async {
@ -1542,7 +1505,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
//
// // this test will create a non mocked electrumx client that will try to connect
@ -1555,12 +1517,12 @@ void main() {
// // networkType: BasicNetworkType.test,
// // client: client,
// // cachedClient: cachedClient,
// // priceAPI: priceAPI,
// //
// // secureStore: secureStore,
// // );
// //
// // // set node
// // final wallet = await Hive.openBox(testWalletId);
// // final wallet = await Hive.openBox<dynamic>(testWalletId);
// // await wallet.put("nodes", {
// // "default": {
// // "id": "some nodeID",
@ -1591,7 +1553,7 @@ void main() {
// // expect(secureStore.interactions, 0);
// // verifyNoMoreInteractions(client);
// // verifyNoMoreInteractions(cachedClient);
// // verifyNoMoreInteractions(priceAPI);
// //
// // });
test("refresh wallet mutex locked", () async {
@ -1666,7 +1628,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
test("refresh wallet normally", () async {
@ -1687,9 +1648,6 @@ void main() {
when(client?.estimateFee(blocks: anyNamed("blocks")))
.thenAnswer((_) async => Decimal.one);
when(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD"))
.thenAnswer((_) async => {Coin.namecoin: Tuple2(Decimal.one, 0.3)});
final List<dynamic> dynamicArgValues = [];
when(client?.getBatchHistory(args: anyNamed("args")))
@ -1718,7 +1676,6 @@ void main() {
verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(4);
verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3);
verify(client?.getBlockHeadTip()).called(1);
verify(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")).called(2);
for (final arg in dynamicArgValues) {
final map = Map<String, List<dynamic>>.from(arg as Map);
@ -1733,7 +1690,6 @@ void main() {
// verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
tearDown(() async {

View file

@ -12,7 +12,6 @@ import 'package:stackwallet/services/price.dart';
import 'package:stackwallet/services/transaction_notification_tracker.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:tuple/tuple.dart';
import 'particl_history_sample_data.dart';
import 'particl_transaction_data_samples.dart';
@ -100,7 +99,7 @@ void main() {
group("validate mainnet particl addresses", () {
MockElectrumX? client;
MockCachedElectrumX? cachedClient;
MockPriceAPI? priceAPI;
late FakeSecureStorage secureStore;
MockTransactionNotificationTracker? tracker;
@ -110,7 +109,7 @@ void main() {
setUp(() {
client = MockElectrumX();
cachedClient = MockCachedElectrumX();
priceAPI = MockPriceAPI();
secureStore = FakeSecureStorage();
tracker = MockTransactionNotificationTracker();
@ -121,7 +120,6 @@ void main() {
client: client!,
cachedClient: cachedClient!,
tracker: tracker!,
priceAPI: priceAPI,
secureStore: secureStore,
);
});
@ -133,7 +131,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("valid mainnet particl legacy/p2pkh address type", () {
@ -145,7 +142,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
test("valid mainnet particl p2wpkh address", () {
@ -160,7 +156,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("valid mainnet particl legacy/p2pkh address", () {
@ -170,7 +165,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("invalid mainnet particl legacy/p2pkh address", () {
@ -183,7 +177,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("invalid mainnet particl p2wpkh address", () {
@ -195,7 +188,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
test("invalid bech32 address type", () {
@ -207,7 +199,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
test("address has no matching script", () {
@ -219,14 +210,13 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
});
group("testNetworkConnection", () {
MockElectrumX? client;
MockCachedElectrumX? cachedClient;
MockPriceAPI? priceAPI;
late FakeSecureStorage secureStore;
MockTransactionNotificationTracker? tracker;
@ -235,7 +225,7 @@ void main() {
setUp(() {
client = MockElectrumX();
cachedClient = MockCachedElectrumX();
priceAPI = MockPriceAPI();
secureStore = FakeSecureStorage();
tracker = MockTransactionNotificationTracker();
@ -246,7 +236,6 @@ void main() {
client: client!,
cachedClient: cachedClient!,
tracker: tracker!,
priceAPI: priceAPI,
secureStore: secureStore,
);
});
@ -259,7 +248,6 @@ void main() {
verify(client?.ping()).called(1);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("attempted connection fails due to exception", () async {
@ -270,7 +258,6 @@ void main() {
verify(client?.ping()).called(1);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("attempted connection test success", () async {
@ -281,7 +268,6 @@ void main() {
verify(client?.ping()).called(1);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
});
@ -291,7 +277,7 @@ void main() {
MockElectrumX? client;
MockCachedElectrumX? cachedClient;
MockPriceAPI? priceAPI;
late FakeSecureStorage secureStore;
MockTransactionNotificationTracker? tracker;
@ -300,7 +286,7 @@ void main() {
setUp(() async {
client = MockElectrumX();
cachedClient = MockCachedElectrumX();
priceAPI = MockPriceAPI();
secureStore = FakeSecureStorage();
tracker = MockTransactionNotificationTracker();
@ -311,7 +297,6 @@ void main() {
client: client!,
cachedClient: cachedClient!,
tracker: tracker!,
priceAPI: priceAPI,
secureStore: secureStore,
);
});
@ -321,7 +306,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get networkType test", () async {
@ -332,14 +316,12 @@ void main() {
client: client!,
cachedClient: cachedClient!,
tracker: tracker!,
priceAPI: priceAPI,
secureStore: secureStore,
);
expect(Coin.particl, Coin.particl);
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get cryptoCurrency", () async {
@ -347,7 +329,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get coinName", () async {
@ -355,7 +336,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get coinTicker", () async {
@ -363,7 +343,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get and set walletName", () async {
@ -373,7 +352,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("estimateTxFee", () async {
@ -388,7 +366,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get fees succeeds", () async {
@ -422,7 +399,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get fees fails", () async {
@ -459,7 +435,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
// test("get maxFee", () async {
@ -491,7 +466,7 @@ void main() {
// verifyNoMoreInteractions(client);
// verifyNoMoreInteractions(cachedClient);
// verifyNoMoreInteractions(tracker);
// verifyNoMoreInteractions(priceAPI);
//
// });
});
@ -503,7 +478,7 @@ void main() {
MockElectrumX? client;
MockCachedElectrumX? cachedClient;
MockPriceAPI? priceAPI;
late FakeSecureStorage secureStore;
MockTransactionNotificationTracker? tracker;
@ -532,7 +507,7 @@ void main() {
client = MockElectrumX();
cachedClient = MockCachedElectrumX();
priceAPI = MockPriceAPI();
secureStore = FakeSecureStorage();
tracker = MockTransactionNotificationTracker();
@ -543,7 +518,6 @@ void main() {
client: client!,
cachedClient: cachedClient!,
tracker: tracker!,
priceAPI: priceAPI,
secureStore: secureStore,
);
});
@ -555,7 +529,7 @@ void main() {
// verify(client?.ping()).called(1);
// verifyNoMoreInteractions(client);
// verifyNoMoreInteractions(cachedClient);
// verifyNoMoreInteractions(priceAPI);
//
// });
// test("initializeWallet no network exception", () async {
@ -566,7 +540,7 @@ void main() {
// verify(client?.ping()).called(1);
// verifyNoMoreInteractions(client);
// verifyNoMoreInteractions(cachedClient);
// verifyNoMoreInteractions(priceAPI);
//
// });
test("initializeWallet mainnet throws bad network", () async {
@ -589,7 +563,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
});
@ -615,7 +588,6 @@ void main() {
expect(secureStore.interactions, 1);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
});
@ -650,7 +622,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test(
@ -687,7 +658,6 @@ void main() {
expect(secureStore.interactions, 2);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("recoverFromMnemonic using empty seed on mainnet succeeds", () async {
@ -737,7 +707,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("get mnemonic list", () async {
@ -778,7 +747,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("recoverFromMnemonic using non empty seed on mainnet succeeds",
@ -847,7 +815,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("fullRescan succeeds", () async {
@ -1040,7 +1007,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("fullRescan fails", () async {
@ -1243,7 +1209,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("prepareSend fails", () async {
@ -1372,7 +1337,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("confirmSend no hex", () async {
@ -1388,7 +1352,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("confirmSend hex is not string", () async {
@ -1404,7 +1367,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("confirmSend hex is string but missing other data", () async {
@ -1424,7 +1386,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("confirmSend fails due to vSize being greater than fee", () async {
@ -1445,7 +1406,6 @@ void main() {
expect(secureStore.interactions, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("confirmSend fails when broadcast transactions throws", () async {
@ -1471,7 +1431,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
//
// // this test will create a non mocked electrumx client that will try to connect
@ -1484,7 +1443,7 @@ void main() {
// // networkType: BasicNetworkType.test,
// // client: client,
// // cachedClient: cachedClient,
// // priceAPI: priceAPI,
// //
// // secureStore: secureStore,
// // );
// //
@ -1520,7 +1479,7 @@ void main() {
// // expect(secureStore.interactions, 0);
// // verifyNoMoreInteractions(client);
// // verifyNoMoreInteractions(cachedClient);
// // verifyNoMoreInteractions(priceAPI);
// //
// // });
test("refresh wallet mutex locked", () async {
@ -1588,7 +1547,6 @@ void main() {
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(tracker);
verifyNoMoreInteractions(priceAPI);
});
test("refresh wallet normally", () async {
@ -1609,9 +1567,6 @@ void main() {
when(client?.estimateFee(blocks: anyNamed("blocks")))
.thenAnswer((_) async => Decimal.one);
when(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD"))
.thenAnswer((_) async => {Coin.particl: Tuple2(Decimal.one, 0.3)});
final List<dynamic> dynamicArgValues = [];
when(client?.getBatchHistory(args: anyNamed("args")))
@ -1640,7 +1595,6 @@ void main() {
verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(3);
verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3);
verify(client?.getBlockHeadTip()).called(1);
verify(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")).called(2);
for (final arg in dynamicArgValues) {
final map = Map<String, List<dynamic>>.from(arg as Map);
@ -1654,7 +1608,6 @@ void main() {
expect(secureStore.deletes, 0);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
tearDown(() async {