Test fast keychain generation
This commit is contained in:
parent
5027b4eb2a
commit
5c97742167
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:gecko/models/generateWallets.dart';
|
import 'package:gecko/models/generateWallets.dart';
|
||||||
import 'package:gecko/models/myWallets.dart';
|
import 'package:gecko/models/myWallets.dart';
|
||||||
|
import 'package:gecko/models/walletOptions.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
|
@ -30,6 +31,8 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
||||||
Provider.of<GenerateWalletsProvider>(context);
|
Provider.of<GenerateWalletsProvider>(context);
|
||||||
MyWalletsProvider _myWalletProvider =
|
MyWalletsProvider _myWalletProvider =
|
||||||
Provider.of<MyWalletsProvider>(context);
|
Provider.of<MyWalletsProvider>(context);
|
||||||
|
WalletOptionsProvider _walletOptions =
|
||||||
|
Provider.of<WalletOptionsProvider>(context);
|
||||||
final int _currentChest = _myWalletProvider.getCurrentChest();
|
final int _currentChest = _myWalletProvider.getCurrentChest();
|
||||||
|
|
||||||
this._mnemonicController.text = generatedMnemonic;
|
this._mnemonicController.text = generatedMnemonic;
|
||||||
|
@ -67,6 +70,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
||||||
fontWeight: FontWeight.w400),
|
fontWeight: FontWeight.w400),
|
||||||
)),
|
)),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
|
key: Key('askedWord'),
|
||||||
focusNode: _wordFocus,
|
focusNode: _wordFocus,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
enabled: !_generateWalletProvider.isAskedWordValid,
|
enabled: !_generateWalletProvider.isAskedWordValid,
|
||||||
|
@ -95,6 +99,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
||||||
fontWeight: FontWeight.w400),
|
fontWeight: FontWeight.w400),
|
||||||
)),
|
)),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
|
key: Key('walletName'),
|
||||||
focusNode: _generateWalletProvider.walletNameFocus,
|
focusNode: _generateWalletProvider.walletNameFocus,
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
FilteringTextInputFormatter.allow(
|
FilteringTextInputFormatter.allow(
|
||||||
|
@ -119,6 +124,7 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 50,
|
height: 50,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
|
key: Key('confirmStorage'),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
elevation: 12,
|
elevation: 12,
|
||||||
primary: Colors.green[
|
primary: Colors.green[
|
||||||
|
@ -137,14 +143,13 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
||||||
false;
|
false;
|
||||||
_generateWalletProvider.askedWordColor =
|
_generateWalletProvider.askedWordColor =
|
||||||
Colors.black;
|
Colors.black;
|
||||||
WidgetsBinding.instance
|
_myWalletProvider.listWallets =
|
||||||
.addPostFrameCallback((_) {
|
_myWalletProvider
|
||||||
_myWalletProvider.listWallets =
|
.readAllWallets(_currentChest);
|
||||||
_myWalletProvider
|
_myWalletProvider.getDefaultWallet();
|
||||||
.readAllWallets(_currentChest);
|
scheduleMicrotask(() {
|
||||||
scheduleMicrotask(() {
|
_walletOptions.reloadBuild();
|
||||||
_myWalletProvider.rebuildWidget();
|
_myWalletProvider.rebuildWidget();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
Navigator.popUntil(
|
Navigator.popUntil(
|
||||||
context, ModalRoute.withName('/'));
|
context, ModalRoute.withName('/'));
|
||||||
|
|
|
@ -71,6 +71,7 @@ class GenerateWalletsScreen extends StatelessWidget {
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextField(
|
TextField(
|
||||||
|
key: Key('generatedPin'),
|
||||||
enabled: false,
|
enabled: false,
|
||||||
controller: _generateWalletProvider.pin,
|
controller: _generateWalletProvider.pin,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
@ -93,6 +94,7 @@ class GenerateWalletsScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
|
key: Key('storeKeychain'),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
primary: Color(0xffFFD68E), // background
|
primary: Color(0xffFFD68E), // background
|
||||||
onPrimary: Colors.black, // foreground
|
onPrimary: Colors.black, // foreground
|
||||||
|
|
|
@ -35,7 +35,7 @@ class SettingsScreen extends StatelessWidget {
|
||||||
body: Column(children: <Widget>[
|
body: Column(children: <Widget>[
|
||||||
SizedBox(height: 40),
|
SizedBox(height: 40),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 50,
|
height: 70,
|
||||||
width: 500,
|
width: 500,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
|
@ -52,27 +52,30 @@ class SettingsScreen extends StatelessWidget {
|
||||||
if (value == true) {Navigator.pop(context)}
|
if (value == true) {Navigator.pop(context)}
|
||||||
}),
|
}),
|
||||||
child: Text("Importer un portefeuille Cesium",
|
child: Text("Importer un portefeuille Cesium",
|
||||||
style: TextStyle(fontSize: 15)))),
|
style: TextStyle(fontSize: 16)))),
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 30),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 50,
|
height: 70,
|
||||||
width: 500,
|
width: 500,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
|
key: Key('generateKeychain'),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
elevation: 5,
|
elevation: 5,
|
||||||
primary: Color(0xFFFFCA6F), // background
|
primary: Color(0xFFFFCA6F), // background
|
||||||
onPrimary: Colors.black, // foreground
|
onPrimary: Colors.black, // foreground
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.push(
|
onPressed: !_myWallets.checkIfWalletExist()
|
||||||
context,
|
? () => Navigator.push(
|
||||||
MaterialPageRoute(builder: (context) {
|
context,
|
||||||
return GenerateWalletsScreen();
|
MaterialPageRoute(builder: (context) {
|
||||||
}),
|
return GenerateWalletsScreen();
|
||||||
).then((value) => {
|
}),
|
||||||
if (value == true) {Navigator.pop(context)}
|
).then((value) => {
|
||||||
}),
|
if (value == true) {Navigator.pop(context)}
|
||||||
|
})
|
||||||
|
: null,
|
||||||
child: Text("Générer un nouveau trousseau",
|
child: Text("Générer un nouveau trousseau",
|
||||||
style: TextStyle(fontSize: 15)))),
|
style: TextStyle(fontSize: 16)))),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
|
@ -90,8 +93,7 @@ class SettingsScreen extends StatelessWidget {
|
||||||
log.i('Suppression de tous les wallets'),
|
log.i('Suppression de tous les wallets'),
|
||||||
await _myWallets.deleteAllWallet(context)
|
await _myWallets.deleteAllWallet(context)
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text("EFFACER TOUS MES PORTEFEUILLES",
|
||||||
"EFFACER TOUS MES PORTEFEUILLES, LE TEMPS DE L'ALPHA",
|
|
||||||
style: TextStyle(fontSize: 20)))))),
|
style: TextStyle(fontSize: 20)))))),
|
||||||
SizedBox(height: 50),
|
SizedBox(height: 50),
|
||||||
]));
|
]));
|
||||||
|
|
|
@ -35,7 +35,7 @@ packages:
|
||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.0"
|
version: "2.6.0"
|
||||||
audioplayers:
|
audioplayers:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -926,7 +926,7 @@ packages:
|
||||||
name: vm_service
|
name: vm_service
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.0+1"
|
version: "6.2.0"
|
||||||
watcher:
|
watcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -49,7 +49,7 @@ dependencies:
|
||||||
audioplayers: ^0.18.1
|
audioplayers: ^0.18.1
|
||||||
flutter_driver:
|
flutter_driver:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
test: ^1.16.6
|
test: ^1.16.8
|
||||||
unorm_dart: ^0.2.0
|
unorm_dart: ^0.2.0
|
||||||
|
|
||||||
flutter_icons:
|
flutter_icons:
|
||||||
|
|
|
@ -30,17 +30,35 @@ void main() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// *** Global functions *** //
|
||||||
|
|
||||||
// Function to tap the widget by key
|
// Function to tap the widget by key
|
||||||
Future tapOn(String key) async {
|
Future tapOn(String key) async {
|
||||||
await driver.tap(find.byValueKey(key));
|
await driver.tap(find.byValueKey(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Easy get text
|
||||||
Future<String> getText(String text) async {
|
Future<String> getText(String text) async {
|
||||||
return await driver.getText(find.byValueKey(
|
return await driver.getText(find.byValueKey(
|
||||||
text,
|
text,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to go back to previous screen
|
||||||
|
Future goBack() async {
|
||||||
|
await Process.run(
|
||||||
|
'adb',
|
||||||
|
<String>['shell', 'input', 'keyevent', 'KEYCODE_BACK'],
|
||||||
|
runInShell: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Easy sleep
|
||||||
|
Future sleep(int _time) async {
|
||||||
|
await Future.delayed(Duration(milliseconds: _time));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test if widget exist on screen, return a boolean
|
||||||
Future<bool> isPresent(SerializableFinder byValueKey,
|
Future<bool> isPresent(SerializableFinder byValueKey,
|
||||||
{Duration timeout = const Duration(seconds: 1)}) async {
|
{Duration timeout = const Duration(seconds: 1)}) async {
|
||||||
try {
|
try {
|
||||||
|
@ -51,6 +69,61 @@ void main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a derivation
|
||||||
|
Future createDerivation(String _name) async {
|
||||||
|
await tapOn('addDerivation');
|
||||||
|
await sleep(100);
|
||||||
|
|
||||||
|
await driver.enterText(_name);
|
||||||
|
|
||||||
|
await tapOn('validDerivation');
|
||||||
|
await sleep(300);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a derivation
|
||||||
|
Future deleteWallet(bool _confirm) async {
|
||||||
|
await tapOn('deleteWallet');
|
||||||
|
await sleep(100);
|
||||||
|
_confirm ? await tapOn('confirmDeleting') : await tapOn('cancelDeleting');
|
||||||
|
await sleep(300);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete all wallets
|
||||||
|
Future deleteAllWallets() async {
|
||||||
|
await tapOn('drawerMenu');
|
||||||
|
await sleep(300);
|
||||||
|
await tapOn('parameters');
|
||||||
|
await sleep(300);
|
||||||
|
await tapOn('deleteAllWallets');
|
||||||
|
await sleep(300);
|
||||||
|
await tapOn('confirmDeletingAllWallets');
|
||||||
|
await sleep(300);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fast creation of new Keychain
|
||||||
|
Future<String> createNewKeychain(String name) async {
|
||||||
|
await tapOn('drawerMenu');
|
||||||
|
await sleep(300);
|
||||||
|
await tapOn('parameters');
|
||||||
|
await sleep(300);
|
||||||
|
await tapOn('generateKeychain');
|
||||||
|
while (await getText('generatedPin') == '') {
|
||||||
|
print('Waiting for pin code generation...');
|
||||||
|
await sleep(100);
|
||||||
|
}
|
||||||
|
pinCode = await getText('generatedPin');
|
||||||
|
await tapOn('storeKeychain');
|
||||||
|
await sleep(100);
|
||||||
|
await driver.enterText('triche');
|
||||||
|
await tapOn('walletName');
|
||||||
|
await driver.enterText(name);
|
||||||
|
await tapOn('confirmStorage');
|
||||||
|
await sleep(300);
|
||||||
|
return pinCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// *** Begin of tests *** //
|
||||||
|
|
||||||
test('OnBoarding - Open wallets management', (
|
test('OnBoarding - Open wallets management', (
|
||||||
{timeout: Timeout.none}) async {
|
{timeout: Timeout.none}) async {
|
||||||
// await driver.runUnsynchronized(() async { // Needed if we want to manage async drivers
|
// await driver.runUnsynchronized(() async { // Needed if we want to manage async drivers
|
||||||
|
@ -62,14 +135,9 @@ void main() {
|
||||||
// If a wallet exist, go to delete theme all
|
// If a wallet exist, go to delete theme all
|
||||||
if (!await isPresent(find.byValueKey('goStep1'))) {
|
if (!await isPresent(find.byValueKey('goStep1'))) {
|
||||||
await goBack();
|
await goBack();
|
||||||
await tapOn('drawerMenu');
|
|
||||||
await sleep(300);
|
await deleteAllWallets();
|
||||||
await tapOn('parameters');
|
|
||||||
await sleep(300);
|
|
||||||
await tapOn('deleteAllWallets');
|
|
||||||
await sleep(300);
|
|
||||||
await tapOn('confirmDeletingAllWallets');
|
|
||||||
await sleep(300);
|
|
||||||
await driver.tap(manageWalletsFinder);
|
await driver.tap(manageWalletsFinder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,24 +254,13 @@ void main() {
|
||||||
"Top !\n\nVotre trousseau de clef et votre portefeuille ont été créés avec un immense succès.\n\nFélicitations !");
|
"Top !\n\nVotre trousseau de clef et votre portefeuille ont été créés avec un immense succès.\n\nFélicitations !");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('My wallets - Create a derivation and display it', (
|
test('My wallets - Create a derivations, open thems, tap all buttons', (
|
||||||
{timeout: Timeout.none}) async {
|
{timeout: Timeout.none}) async {
|
||||||
await tapOn('goWalletHome');
|
await tapOn('goWalletHome');
|
||||||
|
|
||||||
expect(await getText('myWallets'), "Mes portefeuilles");
|
expect(await getText('myWallets'), "Mes portefeuilles");
|
||||||
await sleep(300);
|
await sleep(300);
|
||||||
|
|
||||||
// Create a derivation
|
|
||||||
Future createDerivation(String _name) async {
|
|
||||||
await tapOn('addDerivation');
|
|
||||||
await sleep(100);
|
|
||||||
|
|
||||||
await driver.enterText(_name);
|
|
||||||
|
|
||||||
await tapOn('validDerivation');
|
|
||||||
await sleep(300);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a second derivation
|
// Add a second derivation
|
||||||
await createDerivation('Derivation 2');
|
await createDerivation('Derivation 2');
|
||||||
|
|
||||||
|
@ -240,19 +297,11 @@ void main() {
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
await tapOn('displayBalance');
|
await tapOn('displayBalance');
|
||||||
|
|
||||||
// Delete a derivation
|
|
||||||
Future deleteWallet(bool _confirm) async {
|
|
||||||
await tapOn('deleteWallet');
|
|
||||||
await sleep(100);
|
|
||||||
_confirm
|
|
||||||
? await tapOn('confirmDeleting')
|
|
||||||
: await tapOn('cancelDeleting');
|
|
||||||
await sleep(300);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete third derivation
|
// Delete third derivation
|
||||||
await deleteWallet(true);
|
await deleteWallet(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('My wallets - Extra tests', ({timeout: Timeout.none}) async {
|
||||||
// Add derivation 5,6 and 7
|
// Add derivation 5,6 and 7
|
||||||
await createDerivation('Derivation 5');
|
await createDerivation('Derivation 5');
|
||||||
await createDerivation('Derivation 6');
|
await createDerivation('Derivation 6');
|
||||||
|
@ -314,7 +363,7 @@ void main() {
|
||||||
await createDerivation('Derivation 20');
|
await createDerivation('Derivation 20');
|
||||||
await sleep(400);
|
await sleep(400);
|
||||||
|
|
||||||
// Scroll the wallet screen
|
// Scroll the wallet screen until Derivation 20 and open it
|
||||||
await driver.scrollUntilVisible(
|
await driver.scrollUntilVisible(
|
||||||
find.byValueKey('listWallets'),
|
find.byValueKey('listWallets'),
|
||||||
find.text('Derivation 20'),
|
find.text('Derivation 20'),
|
||||||
|
@ -325,6 +374,10 @@ void main() {
|
||||||
await sleep(400);
|
await sleep(400);
|
||||||
await driver.tap(find.text('Derivation 20'));
|
await driver.tap(find.text('Derivation 20'));
|
||||||
await tapOn('copyPubkey');
|
await tapOn('copyPubkey');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Search - Search Pi profile, navigate in history transactions', (
|
||||||
|
{timeout: Timeout.none}) async {
|
||||||
await goBack();
|
await goBack();
|
||||||
await goBack();
|
await goBack();
|
||||||
await sleep(200);
|
await sleep(200);
|
||||||
|
@ -351,21 +404,27 @@ void main() {
|
||||||
// await Clipboard.getData(Clipboard.kTextPlain);
|
// await Clipboard.getData(Clipboard.kTextPlain);
|
||||||
// await driver.enterText(pubkeyCopied.text);
|
// await driver.enterText(pubkeyCopied.text);
|
||||||
|
|
||||||
|
await sleep(300);
|
||||||
|
}, timeout: Timeout(Duration(minutes: globalTimeout)));
|
||||||
|
|
||||||
|
test('Wallet generation - Fast wallets generations', (
|
||||||
|
{timeout: Timeout.none}) async {
|
||||||
|
await goBack();
|
||||||
|
await goBack();
|
||||||
|
await deleteAllWallets();
|
||||||
|
await sleep(100);
|
||||||
|
final String pincode = await createNewKeychain('Fast wallet');
|
||||||
|
await sleep(100);
|
||||||
|
await tapOn('manageWallets');
|
||||||
|
await sleep(200);
|
||||||
|
await driver.enterText(pincode);
|
||||||
|
await sleep(100);
|
||||||
|
await createDerivation('Derivation 2');
|
||||||
|
await sleep(100);
|
||||||
|
await driver.tap(find.text('Fast wallet'));
|
||||||
|
await driver.waitFor(find.text('Fast wallet'));
|
||||||
// Wait 3 seconds at the end
|
// Wait 3 seconds at the end
|
||||||
await sleep(3000);
|
await sleep(3000);
|
||||||
}, timeout: Timeout(Duration(minutes: globalTimeout)));
|
});
|
||||||
}, timeout: Timeout(Duration(minutes: globalTimeout)));
|
}, timeout: Timeout(Duration(minutes: globalTimeout)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to go back to previous screen
|
|
||||||
Future goBack() async {
|
|
||||||
await Process.run(
|
|
||||||
'adb',
|
|
||||||
<String>['shell', 'input', 'keyevent', 'KEYCODE_BACK'],
|
|
||||||
runInShell: true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future sleep(int _time) async {
|
|
||||||
await Future.delayed(Duration(milliseconds: _time));
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue