Skip to content

CW 882: Integrate Seed Verification Flow To Integration Tests #1966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
25a8393
fix: Generic fixes
Blazebrain Dec 20, 2024
e3c4f7a
Merge branch 'main' of https://github.com/cake-tech/cake_wallet
Blazebrain Jan 13, 2025
1335627
fix: Modify hasSufficientFundsForRent to work for spl transactions
Blazebrain Jan 14, 2025
ecc0156
feat: Integrate seed verification into integration tests
Blazebrain Jan 16, 2025
f5cc30b
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Jan 16, 2025
50c82e0
fix: Adjust workflow file
Blazebrain Jan 16, 2025
ff3606a
chore: Remove previous working directory
Blazebrain Jan 16, 2025
4707dc8
fix: Revert change
Blazebrain Jan 16, 2025
164ae7e
chore: Remove step to setup kvm, already existing in new setup
Blazebrain Jan 16, 2025
45aed18
chore: Remove a couple of steps from workflow
Blazebrain Jan 16, 2025
3ca0334
chore: Try switching test commands
Blazebrain Jan 16, 2025
5060cbe
fix: Switch back to flutter drive
Blazebrain Jan 16, 2025
85f8ebb
fix: Flutter error when running tests with Flutter drive
Blazebrain Jan 16, 2025
ee067cc
Merge branch 'main' into Integrate-Seed-Verification-Flow-To-Integrat…
OmarHatem28 Jan 17, 2025
b0602f8
feat: Add screenshots to individual test pages and modify integration…
Blazebrain Jan 17, 2025
3216a87
Merge branch 'Integrate-Seed-Verification-Flow-To-Integration-Tests' …
Blazebrain Jan 17, 2025
17285bd
feat: Implement transaction success info robot and fix issue with sen…
Blazebrain Jan 17, 2025
640766d
fix: Improve integration testing for exchange flow and clean up logic…
Blazebrain Jan 20, 2025
b83cf66
fix: Handle duplicate words for seeds and test restore through seeds
Blazebrain Jan 20, 2025
35d5a10
fix: Optimize implementation for transactions history test
Blazebrain Jan 22, 2025
2e8038b
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Feb 11, 2025
f640062
Skip seed verification when in debug and when not in CI flow
Blazebrain Feb 11, 2025
adc9f3f
chore: Remove print statements and add TODOs
Blazebrain Feb 11, 2025
33d0033
fix: Upgrade version for upload action
Blazebrain Feb 11, 2025
1ebc087
fix: Add missing secrets to testing workflow file
Blazebrain Feb 11, 2025
4c9e37c
fix tests not working in latest main [skip slack]
MrCyjaneK Feb 3, 2025
5bfa166
add zano seed [skip slack] [run tests]
MrCyjaneK Feb 3, 2025
dda2927
disable exchange_flow_test.dart [run tests] [skip slack]
MrCyjaneK Feb 3, 2025
1396e97
Run tests on linux always (since nobody ever used [run tests])
MrCyjaneK Feb 12, 2025
6881707
fix tests after ui updates
MrCyjaneK Feb 12, 2025
0d2b0a3
[skip slack] tests update
MrCyjaneK Feb 12, 2025
1f60c4e
Merge pull request #1999 from cake-tech/cyjan-fix-tests
Blazebrain Mar 12, 2025
cd0d049
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Mar 12, 2025
bbe72f4
Merge branch 'Integrate-Seed-Verification-Flow-To-Integration-Tests' …
Blazebrain Mar 12, 2025
b9d6d6d
Fixing tests WIP
Blazebrain Mar 13, 2025
0f7c4ee
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Mar 20, 2025
d6c7beb
Fix create wallet integraiton test flow
Blazebrain Mar 21, 2025
74fc9d7
Update and fix Exchange flow test flow
Blazebrain Mar 21, 2025
1711bb1
Switch printV to printToConsole
Blazebrain Mar 24, 2025
aad7320
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Mar 24, 2025
e285236
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Apr 7, 2025
c24d531
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Apr 8, 2025
3eea48d
Adjustments to the the flows on Send and Exchange
Blazebrain Apr 9, 2025
9faec1c
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Apr 9, 2025
c2e77c0
feat: Modify Exchange and send tests to fit new flow
Blazebrain Apr 9, 2025
26506a9
fix:
Blazebrain Apr 9, 2025
629cdf0
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Apr 24, 2025
5ff769e
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
OmarHatem28 Apr 26, 2025
9e3d64e
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into …
Blazebrain Apr 29, 2025
55d32ab
Merge branch 'Integrate-Seed-Verification-Flow-To-Integration-Tests' …
Blazebrain Apr 29, 2025
717bb0c
fix(integration-tests): Fix issues relating to send flow integration …
Blazebrain Apr 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
550 changes: 271 additions & 279 deletions .github/workflows/automated_integration_test.yml

Large diffs are not rendered by default.

36 changes: 17 additions & 19 deletions cw_solana/lib/solana_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class SolanaWalletClient {
transactionDetails.addAll(response);

// to avoid reaching the node RPS limit
await Future.delayed(Duration(milliseconds: 500));
await Future.delayed(const Duration(milliseconds: 500));
}

for (final tx in transactionDetails) {
Expand Down Expand Up @@ -379,18 +379,16 @@ class SolanaWalletClient {
required double solBalance,
required double fee,
}) async {
return true;
// TODO: this is not doing what the name inclines
// final rent =
// await _client!.getMinimumBalanceForMintRentExemption(commitment: Commitment.confirmed);
//
// final rentInSol = (rent / lamportsPerSol).toDouble();
//
// final remnant = solBalance - (inputAmount + fee);
//
// if (remnant > rentInSol) return true;
//
// return false;
final rent =
await _client!.getMinimumBalanceForMintRentExemption(commitment: Commitment.confirmed);

final rentInSol = (rent / lamportsPerSol).toDouble();

final remnant = solBalance - (inputAmount + fee);

if (remnant > rentInSol) return true;

return false;
}

Future<PendingSolanaTransaction> _signNativeTokenTransaction({
Expand Down Expand Up @@ -542,7 +540,7 @@ class SolanaWalletClient {
),
);

await Future.delayed(Duration(seconds: 5));
await Future.delayed(const Duration(seconds: 5));
}
} catch (e) {
throw SolanaCreateAssociatedTokenAccountException(e.toString());
Expand All @@ -569,7 +567,7 @@ class SolanaWalletClient {
);

bool hasSufficientFundsLeft = await hasSufficientFundsLeftForRent(
inputAmount: inputAmount,
inputAmount: 0,
fee: fee,
solBalance: solBalance,
);
Expand All @@ -586,12 +584,12 @@ class SolanaWalletClient {
);

sendTx() async {
await Future.delayed(Duration(seconds: 3));
await Future.delayed(const Duration(seconds: 3));

return await sendTransaction(
signedTransaction: signedTx,
commitment: commitment,
);
signedTransaction: signedTx,
commitment: commitment,
);
}

final pendingTransaction = PendingSolanaTransaction(
Expand Down
5 changes: 5 additions & 0 deletions integration_test/components/common_test_cases.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

class CommonTestCases {
WidgetTester tester;
Expand Down Expand Up @@ -171,4 +172,8 @@ class CommonTestCases {

Future<void> defaultSleepTime({int seconds = 2}) async =>
await Future.delayed(Duration(seconds: seconds));

Future<void> takeScreenshots(String screenshotName) async {
await (tester.binding as IntegrationTestWidgetsFlutterBinding).takeScreenshot(screenshotName);
}
}
39 changes: 27 additions & 12 deletions integration_test/components/common_test_flows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import '../robots/new_wallet_type_page_robot.dart';
import '../robots/pre_seed_page_robot.dart';
import '../robots/restore_from_seed_or_key_robot.dart';
import '../robots/restore_options_page_robot.dart';
import '../robots/seed_verification_page_robot.dart';
import '../robots/setup_pin_code_robot.dart';
import '../robots/wallet_group_description_page_robot.dart';
import '../robots/wallet_list_page_robot.dart';
Expand All @@ -40,6 +41,7 @@ class CommonTestFlows {
_walletListPageRobot = WalletListPageRobot(_tester),
_newWalletTypePageRobot = NewWalletTypePageRobot(_tester),
_restoreOptionsPageRobot = RestoreOptionsPageRobot(_tester),
_seedVerificationPageRobot = SeedVerificationPageRobot(_tester),
_createPinWelcomePageRobot = CreatePinWelcomePageRobot(_tester),
_restoreFromSeedOrKeysPageRobot = RestoreFromSeedOrKeysPageRobot(_tester),
_walletGroupDescriptionPageRobot = WalletGroupDescriptionPageRobot(_tester);
Expand All @@ -58,6 +60,7 @@ class CommonTestFlows {
final NewWalletTypePageRobot _newWalletTypePageRobot;
final RestoreOptionsPageRobot _restoreOptionsPageRobot;
final CreatePinWelcomePageRobot _createPinWelcomePageRobot;
final SeedVerificationPageRobot _seedVerificationPageRobot;
final RestoreFromSeedOrKeysPageRobot _restoreFromSeedOrKeysPageRobot;
final WalletGroupDescriptionPageRobot _walletGroupDescriptionPageRobot;

Expand Down Expand Up @@ -87,7 +90,8 @@ class CommonTestFlows {
await _confirmPreSeedInfo();

await _confirmWalletDetails();
await _commonTestCases.defaultSleepTime();

await _verifyWalletSeed();
}

//* ========== Handles flow from welcome to restoring wallet from seeds ===============
Expand Down Expand Up @@ -150,6 +154,9 @@ class CommonTestFlows {
await _confirmPreSeedInfo();

await _confirmWalletDetails();

await _verifyWalletSeed();

await _commonTestCases.defaultSleepTime();
}

Expand Down Expand Up @@ -240,8 +247,10 @@ class CommonTestFlows {

if (Platform.isLinux) {
// manual pin input
await _restoreFromSeedOrKeysPageRobot.enterPasswordForWalletRestore(CommonTestConstants.pin.join(""));
await _restoreFromSeedOrKeysPageRobot.enterPasswordRepeatForWalletRestore(CommonTestConstants.pin.join(""));
await _restoreFromSeedOrKeysPageRobot
.enterPasswordForWalletRestore(CommonTestConstants.pin.join(""));
await _restoreFromSeedOrKeysPageRobot
.enterPasswordRepeatForWalletRestore(CommonTestConstants.pin.join(""));
}

await _newWalletPageRobot.onNextButtonPressed();
Expand All @@ -264,13 +273,17 @@ class CommonTestFlows {

// await _walletSeedPageRobot.onCopySeedsButtonPressed();

await _walletSeedPageRobot.onSeedPageVerifyButtonPressed();
// Turns out the popup about "Copied to clipboard" prevents
//the button from being pressed on the first try, by just
//tapping it again we fix it.
// await _walletSeedPageRobot.onSeedPageVerifyButtonPressed();

await _walletSeedPageRobot.onOpenWalletButtonPressed();
await _walletSeedPageRobot.onVerifySeedButtonPressed();
}

//* ============ Handles Wallet Seed Verification Page ==================

Future<void> _verifyWalletSeed() async {
await _seedVerificationPageRobot.isSeedVerificationPage();

_seedVerificationPageRobot.hasTitle();

await _seedVerificationPageRobot.verifyWalletSeeds();
}

//* Main Restore Actions - On the RestoreFromSeed/Keys Page - Restore from Seeds Action
Expand All @@ -293,8 +306,10 @@ class CommonTestFlows {

if (Platform.isLinux) {
// manual pin input
await _restoreFromSeedOrKeysPageRobot.enterPasswordForWalletRestore(CommonTestConstants.pin.join(""));
await _restoreFromSeedOrKeysPageRobot.enterPasswordRepeatForWalletRestore(CommonTestConstants.pin.join(""));
await _restoreFromSeedOrKeysPageRobot
.enterPasswordForWalletRestore(CommonTestConstants.pin.join(""));
await _restoreFromSeedOrKeysPageRobot
.enterPasswordRepeatForWalletRestore(CommonTestConstants.pin.join(""));
}

await _restoreFromSeedOrKeysPageRobot.onRestoreWalletButtonPressed();
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/auth_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class AuthPageRobot extends PinCodeWidgetRobot {

Future<void> isAuthPage() async {
await commonTestCases.isSpecificPage<AuthPage>();
await commonTestCases.takeScreenshots('auth_page');
}

void hasTitle() {
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/create_pin_welcome_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CreatePinWelcomePageRobot {

Future<void> isCreatePinWelcomePage() async {
await commonTestCases.isSpecificPage<CreatePinWelcomePage>();
await commonTestCases.takeScreenshots('create_pin_welcome_page');
}

void hasTitle() {
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/dashboard_menu_widget_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class DashboardMenuWidgetRobot {
late CommonTestCases commonTestCases;

Future<void> hasMenuWidget() async {
await commonTestCases.takeScreenshots('menu_widget_page');
commonTestCases.hasType<MenuWidget>();
}

Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/dashboard_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class DashboardPageRobot {

Future<void> isDashboardPage() async {
await commonTestCases.isSpecificPage<DashboardPage>();
await commonTestCases.takeScreenshots('dashboard_page');
}

Future<void> confirmWalletTypeIsDisplayedCorrectly(
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/disclaimer_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class DisclaimerPageRobot {

Future<void> isDisclaimerPage() async {
await commonTestCases.isSpecificPage<DisclaimerPage>();
await commonTestCases.takeScreenshots('disclaimer_page');
}

void hasCheckIcon(bool hasBeenTapped) {
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/exchange_confirm_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ExchangeConfirmPageRobot {

Future<void> isExchangeConfirmPage() async {
await commonTestCases.isSpecificPage<ExchangeConfirmPage>();
await commonTestCases.takeScreenshots('exchange_confirm_page');
}

void confirmComponentsOfTradeDisplayProperly() {
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/exchange_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ExchangePageRobot {

Future<void> isExchangePage() async {
await commonTestCases.isSpecificPage<ExchangePage>();
await commonTestCases.takeScreenshots('exchange_page');
await commonTestCases.defaultSleepTime();
}

Expand Down
2 changes: 2 additions & 0 deletions integration_test/robots/exchange_trade_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class ExchangeTradePageRobot {

Future<void> isExchangeTradePage() async {
await commonTestCases.isSpecificPage<ExchangeTradePage>();
await commonTestCases.takeScreenshots('exchange_trade_page');

}

void hasInformationDialog() {
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/new_wallet_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class NewWalletPageRobot {

Future<void> isNewWalletPage() async {
await commonTestCases.isSpecificPage<NewWalletPage>();
await commonTestCases.takeScreenshots('new_wallet_page');
}

Future<void> enterWalletName(String walletName) async {
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/new_wallet_type_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class NewWalletTypePageRobot {

Future<void> isNewWalletTypePage() async {
await commonTestCases.isSpecificPage<NewWalletTypePage>();
await commonTestCases.takeScreenshots('new_wallet_type_page');
}

void displaysCorrectTitle(bool isCreate) {
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/pin_code_widget_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class PinCodeWidgetRobot {
);
}

await commonTestCases.takeScreenshots('pin_code_widget');
await commonTestCases.defaultSleepTime();
}
}
1 change: 1 addition & 0 deletions integration_test/robots/pre_seed_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class PreSeedPageRobot {

Future<void> isPreSeedPage() async {
await commonTestCases.isSpecificPage<PreSeedPage>();
await commonTestCases.takeScreenshots('pre_seed_page');
}

Future<void> onConfirmButtonPressed() async {
Expand Down
3 changes: 1 addition & 2 deletions integration_test/robots/restore_from_seed_or_key_robot.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'package:cake_wallet/entities/seed_type.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/restore/wallet_restore_page.dart';
import 'package:cake_wallet/src/widgets/seed_widget.dart';
import 'package:cake_wallet/src/widgets/validable_annotated_editable_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import '../components/common_test_cases.dart';
Expand All @@ -16,6 +14,7 @@ class RestoreFromSeedOrKeysPageRobot {

Future<void> isRestoreFromSeedKeyPage() async {
await commonTestCases.isSpecificPage<WalletRestorePage>();
await commonTestCases.takeScreenshots('wallet_restore_page');
}

Future<void> confirmViewComponentsDisplayProperlyPerPageView() async {
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/restore_options_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class RestoreOptionsPageRobot {

Future<void> isRestoreOptionsPage() async {
await commonTestCases.isSpecificPage<RestoreOptionsPage>();
await commonTestCases.takeScreenshots('restore_options');
}

void hasRestoreOptionsButton() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class SecurityAndBackupPageRobot {

Future<void> isSecurityAndBackupPage() async {
await commonTestCases.isSpecificPage<SecurityBackupPage>();
await commonTestCases.takeScreenshots('security_backup_page');
}

void hasTitle() {
Expand Down
42 changes: 42 additions & 0 deletions integration_test/robots/seed_verification_page_robot.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/seed/seed_verification/seed_verification_page.dart';
import 'package:flutter_test/flutter_test.dart';

import '../components/common_test_cases.dart';

class SeedVerificationPageRobot {
SeedVerificationPageRobot(this.tester) : commonTestCases = CommonTestCases(tester);

final WidgetTester tester;
final CommonTestCases commonTestCases;

Future<void> isSeedVerificationPage() async {
await commonTestCases.isSpecificPage<SeedVerificationPage>();
await commonTestCases.takeScreenshots('seed_verification_page');
}

void hasTitle() {
commonTestCases.hasText(S.current.verify_seed);
}

Future<void> verifyWalletSeeds() async {
final seedVerificationPage =
tester.widget<SeedVerificationPage>(find.byType(SeedVerificationPage));

final walletSeedViewModel = seedVerificationPage.walletSeedViewModel;

while (!walletSeedViewModel.isVerificationComplete) {
final currentCorrectWord = walletSeedViewModel.currentCorrectWord;

await commonTestCases.tapItemByKey(
'seed_verification_option_${currentCorrectWord}_button_key',
);

await commonTestCases.defaultSleepTime(seconds: 1);
}

await commonTestCases.tapItemByKey('wallet_seed_page_open_wallet_button_key');

await commonTestCases.defaultSleepTime();
}
}
1 change: 1 addition & 0 deletions integration_test/robots/send_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class SendPageRobot {

Future<void> isSendPage() async {
await commonTestCases.isSpecificPage<SendPage>();
await commonTestCases.takeScreenshots('send_page');
}

void hasTitle() {
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/setup_pin_code_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SetupPinCodeRobot extends PinCodeWidgetRobot {

Future<void> isSetupPinCodePage() async {
await commonTestCases.isSpecificPage<SetupPinCodePage>();
await commonTestCases.takeScreenshots('setup_pin_code_page');
}

void hasTitle() {
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/transactions_page_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TransactionsPageRobot {

Future<void> isTransactionsPage() async {
await commonTestCases.isSpecificPage<TransactionsPage>();
await commonTestCases.takeScreenshots('transactions_page');
}

Future<void> confirmTransactionsPageConstantsDisplayProperly() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class WalletGroupDescriptionPageRobot {

Future<void> isWalletGroupDescriptionPage() async {
await commonTestCases.isSpecificPage<WalletGroupDescriptionPage>();
await commonTestCases.takeScreenshots('wallet_group_description_page');
}

void hasTitle() {
Expand Down
1 change: 1 addition & 0 deletions integration_test/robots/wallet_keys_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class WalletKeysAndSeedPageRobot {

Future<void> isWalletKeysAndSeedPage() async {
await commonTestCases.isSpecificPage<WalletKeysPage>();
await commonTestCases.takeScreenshots('wallet_keys_page');
}

void hasTitle() {
Expand Down
Loading
Loading