Skip to content
Snippets Groups Projects
Commit f4ed793e authored by poka's avatar poka
Browse files

tests: fix transactions not validate

parent ea94b457
Branches
Tags
No related merge requests found
Pipeline #19145 waiting for manual action
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/models/widgets_keys.dart';
import 'package:integration_test/integration_test.dart'; import 'package:integration_test/integration_test.dart';
...@@ -10,6 +11,7 @@ void main() async { ...@@ -10,6 +11,7 @@ void main() async {
// await dotenv.load(); // await dotenv.load();
testWidgets('Gecko complete', (testerLoc) async { testWidgets('Gecko complete', (testerLoc) async {
FlutterError.onError = ignoreOverflowErrors;
// Share WidgetTester to test provider // Share WidgetTester to test provider
tester = testerLoc; tester = testerLoc;
...@@ -50,8 +52,10 @@ Future payTest2() async { ...@@ -50,8 +52,10 @@ Future payTest2() async {
await enterText(keyAmountField, '12.14'); await enterText(keyAmountField, '12.14');
await tapKey(keyConfirmPayment); await tapKey(keyConfirmPayment);
spawnBlock(duration: 500); spawnBlock(duration: 500);
await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1));
await tapKey(keyCloseTransactionScreen, duration: 0); await tapKey(keyCloseTransactionScreen, duration: 0);
await waitFor('12.14'); await waitFor('12.14');
spawnBlock(duration: 500); spawnBlock(duration: 500);
...@@ -63,8 +67,10 @@ Future certifyTest5() async { ...@@ -63,8 +67,10 @@ Future certifyTest5() async {
// Create identity with Test1 account // Create identity with Test1 account
await tapKey(keyCertify); await tapKey(keyCertify);
await tapKey(keyConfirm); await tapKey(keyConfirm);
spawnBlock(duration: 500); spawnBlock(duration: 1000);
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen); await tapKey(keyCloseTransactionScreen);
await waitFor('identityCreated'.tr()); await waitFor('identityCreated'.tr());
...@@ -76,8 +82,10 @@ Future certifyTest5() async { ...@@ -76,8 +82,10 @@ Future certifyTest5() async {
await tapKey(keyConfirmIdentity); await tapKey(keyConfirmIdentity);
await enterText(keyEnterIdentityUsername, test5.name); await enterText(keyEnterIdentityUsername, test5.name);
await tapKey(keyConfirm); await tapKey(keyConfirm);
spawnBlock(duration: 500); spawnBlock(duration: 1000);
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen); await tapKey(keyCloseTransactionScreen);
await waitFor('identityConfirmed'.tr()); await waitFor('identityConfirmed'.tr());
humanRead(2); humanRead(2);
...@@ -102,8 +110,10 @@ Future certifyTest5() async { ...@@ -102,8 +110,10 @@ Future certifyTest5() async {
// Certify with test2 account // Certify with test2 account
await tapKey(keyCertify); await tapKey(keyCertify);
await tapKey(keyConfirm); await tapKey(keyConfirm);
spawnBlock(duration: 500); spawnBlock(duration: 1000);
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen); await tapKey(keyCloseTransactionScreen);
await waitFor('2'); await waitFor('2');
...@@ -117,10 +127,12 @@ Future certifyTest5() async { ...@@ -117,10 +127,12 @@ Future certifyTest5() async {
// Certify with test3 account // Certify with test3 account
await tapKey(keyCertify); await tapKey(keyCertify);
await tapKey(keyConfirm); await tapKey(keyConfirm);
spawnBlock(duration: 500); spawnBlock(duration: 1000);
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen); await tapKey(keyCloseTransactionScreen);
await waitFor('mustWaitXBeforeCertify'.substring(0, 12)); await waitFor('mustWaitXBeforeCertify'.tr().substring(0, 8));
// Check if test5 is member // Check if test5 is member
await tapKey(keyAppBarChest, duration: 300); await tapKey(keyAppBarChest, duration: 300);
......
...@@ -35,12 +35,15 @@ void main() async { ...@@ -35,12 +35,15 @@ void main() async {
await waitFor('memberValidated'.tr(), exactMatch: true); await waitFor('memberValidated'.tr(), exactMatch: true);
// Revoke test5 // Revoke test5
await tapKey(keyManageMembership, duration: 5000); await goBack();
await tapKey(keyOpenWallet(test5.address));
await tapKey(keyManageMembership, duration: 100);
await tapKey(keyRevokeIdty); await tapKey(keyRevokeIdty);
await tapKey(keyConfirm); await tapKey(keyConfirm);
spawnBlock(duration: 2000); spawnBlock(duration: 1000);
await waitFor('extrinsicValidated'.tr().substring(3), await tester.pump(const Duration(seconds: 2));
timeout: const Duration(seconds: 4)); await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen, duration: 0); await tapKey(keyCloseTransactionScreen, duration: 0);
await waitFor('noIdentity'.tr(), exactMatch: true); await waitFor('noIdentity'.tr(), exactMatch: true);
await sleep(); await sleep();
...@@ -48,8 +51,8 @@ void main() async { ...@@ -48,8 +51,8 @@ void main() async {
// Check test1 cannot be revoked // Check test1 cannot be revoked
await goBack(); await goBack();
await tapKey(keyAddDerivation); await tapKey(keyAddDerivation);
await tapKey(keyOpenWallet(test1.address), duration: 500); await tapKey(keyOpenWallet(test1.address), duration: 300);
await tapKey(keyManageMembership, duration: 3000); await tapKey(keyManageMembership, duration: 300);
await waitFor('youCannotRevokeThisIdentity'.tr().substring(0, 15)); await waitFor('youCannotRevokeThisIdentity'.tr().substring(0, 15));
}, timeout: testTimeout()); }, timeout: testTimeout());
} }
...@@ -42,8 +42,10 @@ void main() async { ...@@ -42,8 +42,10 @@ void main() async {
await tapKey(keySelectThisWallet(test6.address), selectLast: true); await tapKey(keySelectThisWallet(test6.address), selectLast: true);
await waitForButtonEnabled(keyConfirm); await waitForButtonEnabled(keyConfirm);
await tapKey(keyConfirm); await tapKey(keyConfirm);
spawnBlock(duration: 2000); spawnBlock(duration: 1000);
await waitFor('extrinsicValidated'.tr()); await tester.pump(const Duration(seconds: 2));
await waitFor('sending'.tr(),
reverse: true, settle: false, timeout: const Duration(seconds: 20));
await tapKey(keyCloseTransactionScreen, duration: 0); await tapKey(keyCloseTransactionScreen, duration: 0);
await tapKey(keyOpenWallet(test6.address), duration: 300); await tapKey(keyOpenWallet(test6.address), duration: 300);
......
...@@ -66,7 +66,7 @@ Future restoreChest() async { ...@@ -66,7 +66,7 @@ Future restoreChest() async {
await enterText(keyPinForm, 'AAAAA', 0); await enterText(keyPinForm, 'AAAAA', 0);
// Check if string "Accéder à mon coffre" is present in screen // Check if string "Accéder à mon coffre" is present in screen
await waitFor('accessMyChest'.tr()); await waitFor('accessMyChest'.tr(), pumpDuration: 30);
// Go to wallets home // Go to wallets home
await tapKey(keyGoWalletsHome, duration: 0); await tapKey(keyGoWalletsHome, duration: 0);
......
...@@ -114,7 +114,7 @@ Future goBack() async { ...@@ -114,7 +114,7 @@ Future goBack() async {
final NavigatorState navigator = tester.state(find.byType(Navigator)); final NavigatorState navigator = tester.state(find.byType(Navigator));
log.d('INTEGRATION TEST: Go back'); log.d('INTEGRATION TEST: Go back');
navigator.pop(); navigator.pop();
await tester.pump(); await tester.pumpAndSettle();
humanRead(); humanRead();
} }
...@@ -129,8 +129,10 @@ Future enterText(Key fieldKey, String textIn, [int duration = 200]) async { ...@@ -129,8 +129,10 @@ Future enterText(Key fieldKey, String textIn, [int duration = 200]) async {
Future<void> waitFor(String text, Future<void> waitFor(String text,
{Duration timeout = const Duration(seconds: 5), {Duration timeout = const Duration(seconds: 5),
bool reverse = false, final bool reverse = false,
bool exactMatch = false}) async { final bool exactMatch = false,
final bool settle = true,
final int pumpDuration = 100}) async {
final end = DateTime.now().add(timeout); final end = DateTime.now().add(timeout);
Finder finder = exactMatch ? find.text(text) : find.textContaining(text); Finder finder = exactMatch ? find.text(text) : find.textContaining(text);
...@@ -143,7 +145,9 @@ Future<void> waitFor(String text, ...@@ -143,7 +145,9 @@ Future<void> waitFor(String text,
throw Exception('Timed out waiting for $searchType : "$text"'); throw Exception('Timed out waiting for $searchType : "$text"');
} }
await tester.pumpAndSettle(); if (settle) {
await tester.pumpAndSettle(Duration(milliseconds: pumpDuration));
}
await Future.delayed(const Duration(milliseconds: 100)); await Future.delayed(const Duration(milliseconds: 100));
} while (reverse ? finder.evaluate().isNotEmpty : finder.evaluate().isEmpty); } while (reverse ? finder.evaluate().isNotEmpty : finder.evaluate().isEmpty);
humanRead(); humanRead();
...@@ -317,6 +321,32 @@ String getWidgetText(Key key) { ...@@ -317,6 +321,32 @@ String getWidgetText(Key key) {
return (word4Finder.evaluate().single.widget as Text).data!; return (word4Finder.evaluate().single.widget as Text).data!;
} }
void ignoreOverflowErrors(
FlutterErrorDetails details, {
bool forceReport = false,
}) {
bool ifIsOverflowError = false;
bool isUnableToLoadAsset = false;
// Detect overflow error.
var exception = details.exception;
if (exception is FlutterError) {
ifIsOverflowError = !exception.diagnostics.any(
(e) => e.value.toString().startsWith("A RenderFlex overflowed by"),
);
isUnableToLoadAsset = !exception.diagnostics.any(
(e) => e.value.toString().startsWith("Unable to load asset"),
);
}
// Ignore if is overflow error.
if (ifIsOverflowError || isUnableToLoadAsset) {
debugPrint('Ignored Error');
} else {
FlutterError.dumpErrorToConsole(details, forceReport: forceReport);
}
}
class TestWallet { class TestWallet {
String address; String address;
String name; String name;
......
...@@ -11,6 +11,7 @@ const keyAppBarChest = Key('keyAppBarChest'); ...@@ -11,6 +11,7 @@ const keyAppBarChest = Key('keyAppBarChest');
// Home // Home
const keyParameters = Key('keyParameters'); const keyParameters = Key('keyParameters');
const keyDebugScreen = Key('keyDebugScreen');
const keyContacts = Key('keyContacts'); const keyContacts = Key('keyContacts');
const keyDrawerMenu = Key('keyDrawerMenu'); const keyDrawerMenu = Key('keyDrawerMenu');
const keyOpenWalletsHomme = Key('keyOpenWalletsHomme'); const keyOpenWalletsHomme = Key('keyOpenWalletsHomme');
......
...@@ -41,7 +41,7 @@ class WalletOptions extends StatelessWidget { ...@@ -41,7 +41,7 @@ class WalletOptions extends StatelessWidget {
Provider.of<MyWalletsProvider>(context, listen: false); Provider.of<MyWalletsProvider>(context, listen: false);
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false); final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
// final sub = Provider.of<SubstrateSdk>(context, listen: false); final sub = Provider.of<SubstrateSdk>(context, listen: false);
// sub.spawnBlock(); // sub.spawnBlock();
// sub.spawnBlock(0, 20); // sub.spawnBlock(0, 20);
...@@ -249,9 +249,6 @@ class WalletOptions extends StatelessWidget { ...@@ -249,9 +249,6 @@ class WalletOptions extends StatelessWidget {
walletProvider.isDefaultWallet = walletProvider.isDefaultWallet =
walletOptions.address.text == walletOptions.address.text ==
defaultWallet.address; defaultWallet.address;
final walletData = walletBox
.get(walletOptions.address.text) ??
WalletData(address: walletOptions.address.text);
return Column(children: [ return Column(children: [
confirmIdentityButton(walletProvider), confirmIdentityButton(walletProvider),
pubkeyWidget(walletProvider, ctx), pubkeyWidget(walletProvider, ctx),
...@@ -267,16 +264,27 @@ class WalletOptions extends StatelessWidget { ...@@ -267,16 +264,27 @@ class WalletOptions extends StatelessWidget {
currentChest), currentChest),
SizedBox(height: 17 * ratio), SizedBox(height: 17 * ratio),
// walletProvider.isMember(context, _walletOptions.address.text) // walletProvider.isMember(context, _walletOptions.address.text)
Column(children: [ FutureBuilder(
future:
sub.isMember(walletOptions.address.text),
builder: (BuildContext context,
AsyncSnapshot<bool> isMember) {
if (isMember.connectionState !=
ConnectionState.done ||
isMember.hasError) {
return const Text('');
}
return Column(children: [
if (!walletProvider.isDefaultWallet && if (!walletProvider.isDefaultWallet &&
!walletData.isMember) !isMember.data!)
deleteWallet( deleteWallet(context, walletProvider,
context, walletProvider, currentChest) currentChest)
else else
const SizedBox(), const SizedBox(),
if (walletData.isMember) if (isMember.data!)
const ManageMembershipButton() const ManageMembershipButton()
]) ]);
}),
]); ]);
}), }),
]), ]),
......
...@@ -6,7 +6,6 @@ import 'package:flutter_markdown/flutter_markdown.dart'; ...@@ -6,7 +6,6 @@ import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
import 'package:gecko/models/chest_data.dart'; import 'package:gecko/models/chest_data.dart';
import 'package:gecko/models/widgets_keys.dart'; import 'package:gecko/models/widgets_keys.dart';
import 'package:gecko/providers/duniter_indexer.dart';
import 'package:gecko/providers/my_wallets.dart'; import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/models/wallet_data.dart'; import 'package:gecko/models/wallet_data.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -25,7 +24,6 @@ import 'package:gecko/widgets/commons/smooth_transition.dart'; ...@@ -25,7 +24,6 @@ import 'package:gecko/widgets/commons/smooth_transition.dart';
import 'package:gecko/widgets/name_by_address.dart'; import 'package:gecko/widgets/name_by_address.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:truncate/truncate.dart';
// import 'package:tutorial_coach_mark/tutorial_coach_mark.dart'; // import 'package:tutorial_coach_mark/tutorial_coach_mark.dart';
class WalletsHome extends StatefulWidget { class WalletsHome extends StatefulWidget {
...@@ -228,7 +226,6 @@ class _WalletsHomeState extends State<WalletsHome> { ...@@ -228,7 +226,6 @@ class _WalletsHomeState extends State<WalletsHome> {
Provider.of<WalletOptionsProvider>(context, listen: false); Provider.of<WalletOptionsProvider>(context, listen: false);
final bool isWalletsExists = myWalletProvider.checkIfWalletExist(); final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
final sub = Provider.of<SubstrateSdk>(context, listen: false); final sub = Provider.of<SubstrateSdk>(context, listen: false);
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
if (!isWalletsExists) { if (!isWalletsExists) {
return const Text(''); return const Text('');
......
...@@ -64,7 +64,7 @@ class MainDrawer extends StatelessWidget { ...@@ -64,7 +64,7 @@ class MainDrawer extends StatelessWidget {
), ),
if (kDebugMode) if (kDebugMode)
ListTile( ListTile(
key: keyParameters, key: keyDebugScreen,
title: Text('Debug screen'.tr()), title: Text('Debug screen'.tr()),
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
......
...@@ -75,7 +75,7 @@ class SearchIdentityQuery extends StatelessWidget { ...@@ -75,7 +75,7 @@ class SearchIdentityQuery extends StatelessWidget {
} }
searchProvider.resultLenght = identities.length; searchProvider.resultLenght = identities.length;
// TODO: Find a way to reload a provider here, in Widget build... riverpod refacto needed... // TODO: Find a way to reload a provider here, in Widget build... riverpod refacto needed... or not ...
double avatarSize = 55; double avatarSize = 55;
return Expanded( return Expanded(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment