forked from cypherstack/stack_wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrescan_test.dart
136 lines (115 loc) · 5.27 KB
/
rescan_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:stackwallet/main.dart' as campfireApp;
import 'bot_runners/create_wallet_until_pin_confirmation.dart';
import 'bots/lockscreen_view_bot.dart';
import 'bots/main_view_bot.dart';
import 'bots/onboarding/create_pin_view_bot.dart';
import 'bots/onboarding/name_your_wallet_view_bot.dart';
import 'bots/onboarding/onboarding_view_bot.dart';
import 'bots/onboarding/restore_wallet_form_view_bot.dart';
import 'bots/onboarding/terms_and_conditions_bot.dart';
import 'bots/rescan_warning_view_bot.dart';
import 'bots/settings/settings_view_bot.dart';
import 'bots/settings/wallet_settings_view_bot.dart';
import 'private.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets("rescan test", (tester) async {
campfireApp.main();
await tester.pumpAndSettle(Duration(seconds: 10));
// robots
final onboardingViewBot = OnboardingViewBot(tester);
final termsAndConditionsViewBot = TermsAndConditionsViewBot(tester);
final nameYourWalletViewBot = NameYourWalletViewBot(tester);
final createPinViewBot = CreatePinViewBot(tester);
// tap restore wallet button
await onboardingViewBot.ensureVisible();
await onboardingViewBot.tapRestoreWallet();
await termsAndConditionsViewBot.ensureVisible();
await createWalletUntilPinConfirmation(
termsAndConditionsViewBot,
nameYourWalletViewBot,
createPinViewBot,
);
await tester.pumpAndSettle(Duration(seconds: 2));
final restoreWalletFormViewBot = RestoreWalletFormViewBot(tester);
await restoreWalletFormViewBot.ensureVisible();
// paste valid mnemonic
await Clipboard.setData(ClipboardData(text: TEST_MNEMONIC));
await restoreWalletFormViewBot.tapPaste();
await restoreWalletFormViewBot.scrollDown();
await restoreWalletFormViewBot.tapRestore(true);
final mainViewBot = MainViewBot(tester);
await mainViewBot.ensureVisible();
await Future.delayed(Duration(seconds: 10));
expect(find.byType(ListView, skipOffstage: false), findsNWidgets(1));
expect(find.text("0.00041252 FIRO"), findsOneWidget);
// restore should have succeeded by now
// now we test full rescan
await mainViewBot.tapSettings();
final settingsViewBot = SettingsViewBot(tester);
await settingsViewBot.ensureVisible();
await settingsViewBot.tapWalletSettings();
final walletSettingsViewBot = WalletSettingsViewBot(tester);
await walletSettingsViewBot.ensureVisible();
// tap rescan wallet and then cancel
await walletSettingsViewBot.tapFullRescan();
await walletSettingsViewBot.tapCancelRescanConfirmationDialog();
// tap rescan and continue running though
// and testing back taps throughout
await walletSettingsViewBot.tapFullRescan();
await walletSettingsViewBot.tapRescanOnRescanConfirmationDialog();
final lockScreenViewBot = LockscreenViewBot(tester);
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.tapBack();
await walletSettingsViewBot.tapFullRescan();
await walletSettingsViewBot.tapRescanOnRescanConfirmationDialog();
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.enterPin("9999");
await tester.pumpAndSettle(Duration(seconds: 2));
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.tapBack();
await walletSettingsViewBot.tapFullRescan();
await walletSettingsViewBot.tapRescanOnRescanConfirmationDialog();
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.enterPin("1234");
await tester.pumpAndSettle(Duration(seconds: 2));
final rescanWarningViewBot = RescanWarningViewBot(tester);
await rescanWarningViewBot.ensureVisible();
await rescanWarningViewBot.tapBack();
await walletSettingsViewBot.ensureVisible();
// tap qr code
await walletSettingsViewBot.tapFullRescan();
await walletSettingsViewBot.tapRescanOnRescanConfirmationDialog();
await lockScreenViewBot.ensureVisible();
await lockScreenViewBot.enterPin("1234");
await tester.pumpAndSettle(Duration(seconds: 2));
await rescanWarningViewBot.ensureVisible();
await rescanWarningViewBot.tapQrCode();
await rescanWarningViewBot.tapCancelQrCode();
await rescanWarningViewBot.ensureVisible();
// tap copy
await Clipboard.setData(ClipboardData(text: ""));
await rescanWarningViewBot.tapCopy();
final mnemonic = (await Clipboard.getData(Clipboard.kTextPlain))!.text;
expect(mnemonic, TEST_MNEMONIC);
await tester.pumpAndSettle(Duration(seconds: 2));
await Clipboard.setData(ClipboardData(text: ""));
await rescanWarningViewBot.ensureVisible();
// tap continue and cancel
await rescanWarningViewBot.tapContinue();
await rescanWarningViewBot.tapCancelContinue();
await rescanWarningViewBot.ensureVisible();
// tap continue and finally confirm rescan
await rescanWarningViewBot.tapContinue();
await rescanWarningViewBot.tapConfirmContinue();
await mainViewBot.ensureVisible();
await tester.pumpAndSettle();
await Future.delayed(Duration(seconds: 10));
await tester.pumpAndSettle();
expect(find.text("0.00041252 FIRO"), findsOneWidget);
});
}