recoverFromMnemonic using non empty seed on mainnet succeeds

This commit is contained in:
sneurlax 2022-12-09 10:41:54 -06:00
parent e3111cf9d2
commit 74a25d5001

View file

@ -793,80 +793,80 @@ void main() {
// verifyNoMoreInteractions(priceAPI);
// });
// test("recoverFromMnemonic using non empty seed on mainnet succeeds",
// () async {
// when(client?.getServerFeatures()).thenAnswer((_) async => {
// "hosts": {},
// "pruning": null,
// "server_version": "Unit tests",
// "protocol_min": "1.4",
// "protocol_max": "1.4.2",
// "genesis_hash": GENESIS_HASH_MAINNET,
// "hash_function": "sha256",
// "services": []
// });
// when(client?.getBatchHistory(args: historyBatchArgs0))
// .thenAnswer((_) async => historyBatchResponse);
// when(client?.getBatchHistory(args: historyBatchArgs1))
// .thenAnswer((_) async => historyBatchResponse);
// when(client?.getBatchHistory(args: historyBatchArgs2))
// .thenAnswer((_) async => historyBatchResponse);
// when(client?.getBatchHistory(args: historyBatchArgs3))
// .thenAnswer((_) async => historyBatchResponse);
// when(client?.getBatchHistory(args: historyBatchArgs4))
// .thenAnswer((_) async => historyBatchResponse);
// when(client?.getBatchHistory(args: historyBatchArgs5))
// .thenAnswer((_) async => historyBatchResponse);
//
// List<dynamic> dynamicArgValues = [];
//
// when(client?.getBatchHistory(args: anyNamed("args")))
// .thenAnswer((realInvocation) async {
// if (realInvocation.namedArguments.values.first.length == 1) {
// dynamicArgValues.add(realInvocation.namedArguments.values.first);
// }
//
// return historyBatchResponse;
// });
//
// await Hive.openBox<dynamic>(testWalletId);
//
// bool hasThrown = false;
// try {
// await part?.recoverFromMnemonic(
// mnemonic: TEST_MNEMONIC,
// maxUnusedAddressGap: 2,
// maxNumberOfIndexesToCheck: 1000,
// height: 4000);
// } catch (_) {
// hasThrown = true;
// }
// expect(hasThrown, false);
//
// verify(client?.getServerFeatures()).called(1);
// verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1);
// verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1);
// verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1);
// verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1);
// verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1);
// verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1);
//
// for (final arg in dynamicArgValues) {
// final map = Map<String, List<dynamic>>.from(arg as Map);
// verify(client?.getBatchHistory(args: map)).called(1);
// expect(activeScriptHashes.contains(map.values.first.first as String),
// true);
// }
//
// expect(secureStore.interactions, 10); // 14
// expect(secureStore.writes, 5); // 7
// expect(secureStore.reads, 5); // 7
// expect(secureStore.deletes, 0);
//
// verifyNoMoreInteractions(client);
// verifyNoMoreInteractions(cachedClient);
// verifyNoMoreInteractions(priceAPI);
// });
test("recoverFromMnemonic using non empty seed on mainnet succeeds",
() async {
when(client?.getServerFeatures()).thenAnswer((_) async => {
"hosts": {},
"pruning": null,
"server_version": "Unit tests",
"protocol_min": "1.4",
"protocol_max": "1.4.2",
"genesis_hash": GENESIS_HASH_MAINNET,
"hash_function": "sha256",
"services": []
});
when(client?.getBatchHistory(args: historyBatchArgs0))
.thenAnswer((_) async => historyBatchResponse);
when(client?.getBatchHistory(args: historyBatchArgs1))
.thenAnswer((_) async => historyBatchResponse);
when(client?.getBatchHistory(args: historyBatchArgs2))
.thenAnswer((_) async => historyBatchResponse);
when(client?.getBatchHistory(args: historyBatchArgs3))
.thenAnswer((_) async => historyBatchResponse);
when(client?.getBatchHistory(args: historyBatchArgs4))
.thenAnswer((_) async => historyBatchResponse);
when(client?.getBatchHistory(args: historyBatchArgs5))
.thenAnswer((_) async => historyBatchResponse);
List<dynamic> dynamicArgValues = [];
when(client?.getBatchHistory(args: anyNamed("args")))
.thenAnswer((realInvocation) async {
if (realInvocation.namedArguments.values.first.length == 1) {
dynamicArgValues.add(realInvocation.namedArguments.values.first);
}
return historyBatchResponse;
});
await Hive.openBox<dynamic>(testWalletId);
bool hasThrown = false;
try {
await part?.recoverFromMnemonic(
mnemonic: TEST_MNEMONIC,
maxUnusedAddressGap: 2,
maxNumberOfIndexesToCheck: 1000,
height: 4000);
} catch (_) {
hasThrown = true;
}
expect(hasThrown, false);
verify(client?.getServerFeatures()).called(1);
// verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); // TODO remove this def above
// verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); // TODO remove this def above
verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1);
verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1);
verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1);
verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1);
for (final arg in dynamicArgValues) {
final map = Map<String, List<dynamic>>.from(arg as Map);
verify(client?.getBatchHistory(args: map)).called(1);
expect(activeScriptHashes.contains(map.values.first.first as String),
true);
}
expect(secureStore.interactions, 10); // 14
expect(secureStore.writes, 5); // 7
expect(secureStore.reads, 5); // 7
expect(secureStore.deletes, 0);
verifyNoMoreInteractions(client);
verifyNoMoreInteractions(cachedClient);
verifyNoMoreInteractions(priceAPI);
});
test("fullRescan succeeds", () async {
when(client?.getServerFeatures()).thenAnswer((_) async => {