add test: migrate Cesium wallet identity

This commit is contained in:
poka 2022-08-29 06:03:05 +02:00
parent 939c6b3108
commit 9301eaf1a7
11 changed files with 251 additions and 114 deletions

View File

@ -10,21 +10,21 @@ void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); IntegrationTestWidgetsFlutterBinding.ensureInitialized();
await dotenv.load(); await dotenv.load();
testWidgets('Gecko complete', (testerLoc) async { testWidgets('Certifications state', (testerLoc) async {
tester = testerLoc; tester = testerLoc;
// Connect local node and import test chest in background // Connect local node and import test chest in background
await fastStart(); await bkFastStart();
// Open chest // Open chest
await firstOpenChest(); await firstOpenChest();
await goBack(); await goBack();
// Go wallet 5 view // Go wallet 5 view
await goKey(keyOpenSearch); await tapKey(keyOpenSearch);
await enterText(keySearchField, test5.address); await enterText(keySearchField, test5.address);
await goKey(keyConfirmSearch); await tapKey(keyConfirmSearch);
await waitFor(test5.shortAddress()); await waitFor(test5.shortAddress());
await goKey(keySearchResult(test5.address)); await tapKey(keySearchResult(test5.address));
await waitFor('Certifier'); await waitFor('Certifier');
await waitFor('Vous devez ', reverse: true); await waitFor('Vous devez ', reverse: true);
await waitFor('Vous pourrez renouveler ', reverse: true); await waitFor('Vous pourrez renouveler ', reverse: true);

View File

@ -29,6 +29,11 @@
"balance": 10000, "balance": 10000,
"certs": ["test1", "test2", "test3"], "certs": ["test1", "test2", "test3"],
"pubkey": "5DXJ4CusmCg8S1yF6JGVn4fxgk5oFx42WctXqHZ17mykgje5" "pubkey": "5DXJ4CusmCg8S1yF6JGVn4fxgk5oFx42WctXqHZ17mykgje5"
},
"testCesium1": {
"balance": 10000,
"certs": ["test1", "test2", "test3"],
"pubkey": "5GAT6CJW8yVKwUuQc7sM5Kk9GZVTpbZYk9PfjNXtvnNgAJZ1"
} }
}, },
"parameters": { "parameters": {

View File

@ -1,9 +1,7 @@
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv/flutter_dotenv.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';
import 'package:gecko/main.dart' as app;
import 'general_actions.dart'; import 'general_actions.dart';
import 'tests_utility.dart'; import 'tests_utility.dart';
@ -12,11 +10,11 @@ void main() async {
await dotenv.load(); await dotenv.load();
testWidgets('Gecko complete', (testerLoc) async { testWidgets('Gecko complete', (testerLoc) async {
// Share WidgetTester to test provider
tester = testerLoc; tester = testerLoc;
app.main();
await waitFor('Test starting...', reverse: true); // Start app and wait finish starting
await tester.pumpAndSettle(const Duration(milliseconds: 100)); await startWait();
await sleep(2000);
// Change Duniter endpoint to local // Change Duniter endpoint to local
await changeNode(); await changeNode();
@ -27,7 +25,7 @@ void main() async {
// Restore the test chest // Restore the test chest
await restoreChest(); await restoreChest();
// Execute a transaction to test2 // Execute a transaction to test5
await payTest2(); await payTest2();
// Certify test5 account with 3 accounts to become member // Certify test5 account with 3 accounts to become member
@ -37,23 +35,23 @@ void main() async {
Future payTest2() async { Future payTest2() async {
await waitFor('Rechercher'); await waitFor('Rechercher');
await goKey(keyOpenSearch); await tapKey(keyOpenSearch);
final addressToSearch = (await Clipboard.getData('text/plain'))!.text; final addressToSearch = await clipPaste();
final endAddress = addressToSearch!.substring(addressToSearch.length - 6); final endAddress = addressToSearch.substring(addressToSearch.length - 6);
expect(addressToSearch, test5.address); expect(addressToSearch, test5.address);
await enterText(keySearchField, addressToSearch); await enterText(keySearchField, addressToSearch);
await goKey(keyConfirmSearch); await tapKey(keyConfirmSearch);
await waitFor(endAddress); await waitFor(endAddress);
await goKey(keySearchResult(addressToSearch)); await tapKey(keySearchResult(addressToSearch));
await waitFor(endAddress); await waitFor(endAddress);
await waitFor('0.0 ĞD'); await waitFor('0.0 ĞD');
await goKey(keyPay); await tapKey(keyPay);
await enterText(keyAmountField, '12.14'); await enterText(keyAmountField, '12.14');
await goKey(keyConfirmPayment); await tapKey(keyConfirmPayment);
spawnBlock(duration: 500); spawnBlock(duration: 500);
await waitFor('validé !', timeout: const Duration(seconds: 1)); await waitFor('validé !', timeout: const Duration(seconds: 1));
await goKey(keyCloseTransactionScreen, duration: 0); await tapKey(keyCloseTransactionScreen, duration: 0);
await waitFor('12.14'); await waitFor('12.14');
spawnBlock(duration: 500); spawnBlock(duration: 500);
await waitFor('9.14'); await waitFor('9.14');
@ -62,70 +60,70 @@ Future payTest2() async {
Future certifyTest5() async { Future certifyTest5() async {
// Create identity with Test1 account // Create identity with Test1 account
await goKey(keyCertify); await tapKey(keyCertify);
await goKey(keyConfirm); await tapKey(keyConfirm);
spawnBlock(duration: 500); spawnBlock(duration: 500);
await waitFor('validé !', timeout: const Duration(seconds: 1)); await waitFor('validé !', timeout: const Duration(seconds: 1));
await goKey(keyCloseTransactionScreen); await tapKey(keyCloseTransactionScreen);
await waitFor('Identité créée'); await waitFor('Identité créée');
// Confirm Identity Test5 // Confirm Identity Test5
await goKey(keyAppBarChest, duration: 300); await tapKey(keyAppBarChest, duration: 300);
await goKey(keyOpenWallet(test5.address)); await tapKey(keyOpenWallet(test5.address));
await goKey(keyCopyAddress); await tapKey(keyCopyAddress);
humanRead(3); humanRead(3);
await goKey(keyConfirmIdentity); await tapKey(keyConfirmIdentity);
await enterText(keyEnterIdentityUsername, test5.name); await enterText(keyEnterIdentityUsername, test5.name);
await goKey(keyConfirm); await tapKey(keyConfirm);
spawnBlock(duration: 500); spawnBlock(duration: 500);
await waitFor('validé !', timeout: const Duration(seconds: 1)); await waitFor('validé !', timeout: const Duration(seconds: 1));
await goKey(keyCloseTransactionScreen); await tapKey(keyCloseTransactionScreen);
await waitFor('Identité confirmée'); await waitFor('Identité confirmée');
humanRead(2); humanRead(2);
// Set wallet 2 as default wallet // Set wallet 2 as default wallet
await goBack(); await goBack();
await goKey(keyOpenWallet(test2.address)); await tapKey(keyOpenWallet(test2.address));
await goKey(keySetDefaultWallet); await tapKey(keySetDefaultWallet);
await waitFor('Ce portefeuille est celui par defaut'); await waitFor('Ce portefeuille est celui par defaut');
// Search Wallet 5 again // Search Wallet 5 again
await goKey(keyAppBarSearch); await tapKey(keyAppBarSearch);
final addressToSearch = (await Clipboard.getData('text/plain'))!.text; final addressToSearch = await clipPaste();
final endAddress = addressToSearch!.substring(addressToSearch.length - 6); final endAddress = addressToSearch.substring(addressToSearch.length - 6);
expect(addressToSearch, test5.address); expect(addressToSearch, test5.address);
await enterText(keySearchField, addressToSearch); await enterText(keySearchField, addressToSearch);
await goKey(keyConfirmSearch); await tapKey(keyConfirmSearch);
await waitFor(endAddress); await waitFor(endAddress);
await goKey(keySearchResult(addressToSearch)); await tapKey(keySearchResult(addressToSearch));
await waitFor(endAddress); await waitFor(endAddress);
await waitFor('1'); await waitFor('1');
// Certify with test2 account // Certify with test2 account
await goKey(keyCertify); await tapKey(keyCertify);
await goKey(keyConfirm); await tapKey(keyConfirm);
spawnBlock(duration: 500); spawnBlock(duration: 500);
await waitFor('validé !', timeout: const Duration(seconds: 1)); await waitFor('validé !', timeout: const Duration(seconds: 1));
await goKey(keyCloseTransactionScreen); await tapKey(keyCloseTransactionScreen);
await waitFor('2'); await waitFor('2');
// Change default wallet to test3 // Change default wallet to test3
await goKey(keyPay); await tapKey(keyPay);
await goKey(keyChangeChest); await tapKey(keyChangeChest);
await goKey(keySelectThisWallet(test3.address)); await tapKey(keySelectThisWallet(test3.address));
await goKey(keyConfirm); await tapKey(keyConfirm);
await sleep(); await sleep();
// Certify with test3 account // Certify with test3 account
await goKey(keyCertify); await tapKey(keyCertify);
await goKey(keyConfirm); await tapKey(keyConfirm);
spawnBlock(duration: 500); spawnBlock(duration: 500);
await waitFor('validé !', timeout: const Duration(seconds: 1)); await waitFor('validé !', timeout: const Duration(seconds: 1));
await goKey(keyCloseTransactionScreen); await tapKey(keyCloseTransactionScreen);
await waitFor('Vous devez attendre'); await waitFor('Vous devez attendre');
// Check if test5 is member // Check if test5 is member
await goKey(keyAppBarChest, duration: 300); await tapKey(keyAppBarChest, duration: 300);
await goKey(keyOpenWallet(test5.address)); await tapKey(keyOpenWallet(test5.address));
await waitFor('Membre validé !'); await waitFor('Membre validé !');
// spawn 20 blocs and check if ud is creating // spawn 20 blocs and check if ud is creating

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
@ -12,12 +11,12 @@ Future changeNode() async {
final ipAddress = dotenv.env['ip_address'] ?? '127.0.0.1'; final ipAddress = dotenv.env['ip_address'] ?? '127.0.0.1';
log.d('ip address: $ipAddress'); log.d('ip address: $ipAddress');
await goKey(keyDrawerMenu); await tapKey(keyDrawerMenu);
await goKey(keyParameters); await tapKey(keyParameters);
await goKey(keySelectDuniterNodeDropDown, duration: 5); await tapKey(keySelectDuniterNodeDropDown, duration: 5);
await goKey(keySelectDuniterNode('Personnalisé'), selectLast: true); await tapKey(keySelectDuniterNode('Personnalisé'), selectLast: true);
await enterText(keyCustomDuniterEndpoint, 'ws://$ipAddress:9944'); await enterText(keyCustomDuniterEndpoint, 'ws://$ipAddress:9944');
await goKey(keyConnectToEndpoint); await tapKey(keyConnectToEndpoint);
await isIconPresent(Icons.add_card_sharp, await isIconPresent(Icons.add_card_sharp,
timeout: const Duration(seconds: 8)); timeout: const Duration(seconds: 8));
await goBack(); await goBack();
@ -25,35 +24,35 @@ Future changeNode() async {
Future deleteAllWallets() async { Future deleteAllWallets() async {
if (await isPresent('Rechercher')) { if (await isPresent('Rechercher')) {
await goKey(keyDrawerMenu); await tapKey(keyDrawerMenu);
await goKey(keyParameters); await tapKey(keyParameters);
await goKey(keyDeleteAllWallets); await tapKey(keyDeleteAllWallets);
await goKey(keyConfirm); await tapKey(keyConfirm);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
} }
Future restoreChest() async { Future restoreChest() async {
// Copy test mnemonic in clipboard // Copy test mnemonic in clipboard
Clipboard.setData(const ClipboardData(text: testMnemonic)); await clipCopy(testMnemonic);
// Open screen import chest // Open screen import chest
await goKey(keyRestoreChest, duration: 0); await tapKey(keyRestoreChest, duration: 0);
// Tap on button to paste mnemonic // Tap on button to paste mnemonic
await goKey(keyPastMnemonic); await tapKey(keyPastMnemonic);
// Tap on next button 4 times to skip 3 screen // Tap on next button 4 times to skip 3 screen
await goKey(keyGoNext); await tapKey(keyGoNext);
await goKey(keyGoNext); await tapKey(keyGoNext);
await goKey(keyGoNext); await tapKey(keyGoNext);
await goKey(keyGoNext); await tapKey(keyGoNext);
// Check if cached password checkbox is checked // Check if cached password checkbox is checked
final isCached = await isIconPresent(Icons.check_box); final isCached = await isIconPresent(Icons.check_box);
// If not, tap on to cache password // If not, tap on to cache password
if (!isCached) await goKey(keyCachePassword, duration: 0); if (!isCached) await tapKey(keyCachePassword, duration: 0);
// Enter password // Enter password
await enterText(keyPinForm, 'AAAAA', 0); await enterText(keyPinForm, 'AAAAA', 0);
@ -62,7 +61,7 @@ Future restoreChest() async {
await waitFor('Accéder à mon coffre'); await waitFor('Accéder à mon coffre');
// Go to wallets home // Go to wallets home
await goKey(keyGoWalletsHome, duration: 0); await tapKey(keyGoWalletsHome, duration: 0);
// Check if string "ĞD" is present in screen // Check if string "ĞD" is present in screen
await waitFor('ĞD'); await waitFor('ĞD');
@ -71,10 +70,10 @@ Future restoreChest() async {
await addDerivation(); await addDerivation();
// Tap on Wallet 5 // Tap on Wallet 5
await goKey(keyOpenWallet(test5.address)); await tapKey(keyOpenWallet(test5.address));
// Copy address of Wallet 5 // Copy address of Wallet 5
await goKey(keyCopyAddress); await tapKey(keyCopyAddress);
// Check if string "Cette adresse a été copié" is present in screen // Check if string "Cette adresse a été copié" is present in screen
await waitFor('Cette adresse a été copié'); await waitFor('Cette adresse a été copié');
@ -85,15 +84,15 @@ Future restoreChest() async {
} }
Future addDerivation() async { Future addDerivation() async {
await goKey(keyAddDerivation); await tapKey(keyAddDerivation);
await waitFor('Portefeuille 5'); await waitFor('Portefeuille 5');
} }
Future firstOpenChest() async { Future firstOpenChest() async {
await goKey(keyOpenWalletsHomme); await tapKey(keyOpenWalletsHomme);
sleep(300); sleep(300);
final isCached = await isIconPresent(Icons.check_box); final isCached = await isIconPresent(Icons.check_box);
if (!isCached) await goKey(keyCachePassword, duration: 0); if (!isCached) await tapKey(keyCachePassword, duration: 0);
await enterText(keyPinForm, 'AAAAA', 0); await enterText(keyPinForm, 'AAAAA', 0);
await waitFor('100.0 $currencyName'); await waitFor('100.0 $currencyName');
} }

View File

@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/widgets_keys.dart';
import 'package:integration_test/integration_test.dart';
import 'general_actions.dart';
import 'tests_utility.dart';
void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
await dotenv.load();
testWidgets('Migrate Cesium identity and balance', (testerLoc) async {
tester = testerLoc;
// Connect local node and import test chest in background
await bkFastStart();
// Open chest
await firstOpenChest();
// Go to test1 options and check if balance growup with UDs creations
await tapKey(keyAddDerivation);
await waitFor('Portefeuille 6');
await scrollUntil(keyImportG1v1);
await tapKey(keyImportG1v1);
await enterText(keyCesiumId, 'test');
await enterText(keyCesiumPassword, 'test');
await waitFor(cesiumTest1.shortAddress());
await waitFor('100.0 $currencyName');
await waitFor('3', exactMatch: true);
isObscureText();
await tapKey(keyCesiumIdVisible);
await tester.pumpAndSettle();
isObscureText(false);
await tapKey(keyCesiumIdVisible);
await tester.pumpAndSettle();
isObscureText();
await tapKey(keySelectWallet);
await tapKey(keySelectThisWallet(test6.address), selectLast: true);
await waitForButtonEnabled(keyConfirm);
await tapKey(keyConfirm);
spawnBlock(duration: 2000);
await waitFor('validé !');
await tapKey(keyCloseTransactionScreen, duration: 0);
await tapKey(keyOpenWallet(test6.address), duration: 300);
await waitFor('3', exactMatch: true);
await waitFor('Membre validé !');
// TODO: fix batch for transfertAll
// await waitFor('100.0 $currencyName');
}, timeout: testTimeout());
}
isObscureText([bool isObscure = true]) {
final passwordTextFormField = find.descendant(
of: find.byKey(keyCesiumId),
matching: find.byType(EditableText),
);
final input = tester.widget<EditableText>(passwordTextFormField);
expect(input.obscureText, isObscure ? isTrue : isFalse);
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
@ -30,12 +31,20 @@ final test4 =
TestWallet('5DXJ4CusmCg8S1yF6JGVn4fxgk5oFx42WctXqHZ17mykgje5', 'test4'); TestWallet('5DXJ4CusmCg8S1yF6JGVn4fxgk5oFx42WctXqHZ17mykgje5', 'test4');
final test5 = final test5 =
TestWallet('5Dq3giahrBfykJogPetZJ2jjSmhw49Fa7i6qKkseUvRJ2T3R', 'test5'); TestWallet('5Dq3giahrBfykJogPetZJ2jjSmhw49Fa7i6qKkseUvRJ2T3R', 'test5');
// final test6 = final test6 =
// TestWallet('5FeggKqw2AbnGZF9Y9WPM2QTgzENS3Hit94Ewgmzdg5a3LNa', 'test6'); TestWallet('5GxEp3do81j97kNaH4JyZgDXuPoKWoTuxXXWGyyNXeKeVLHb', 'test6');
// final test7 = final test7 =
// TestWallet('5FeggKqw2AbnGZF9Y9WPM2QTgzENS3Hit94Ewgmzdg5a3LNa', 'test7'); TestWallet('5FZ1sSvREbQLCtSSCvMUx7KCAnpJkB7q5mfz2oixiZq2ChET', 'test7');
// final test8 = final test8 =
// TestWallet('5FeggKqw2AbnGZF9Y9WPM2QTgzENS3Hit94Ewgmzdg5a3LNa', 'test8'); TestWallet('5CoKV9EEgwb2NmWamTXUAa6ycfNb2k1iNfVGvJAkg7dLq9RH', 'test8');
final cesiumTest1 = TestWallet(
'5GAT6CJW8yVKwUuQc7sM5Kk9GZVTpbZYk9PfjNXtvnNgAJZ1', 'cesiumTest1');
final cesiumTest2 = TestWallet(
'5DTnny1tTkUs1SXHZTx98RUAj76Z88FfFhsQjd48dXnk8gHR', 'cesiumTest2');
final cesiumTest3 = TestWallet(
'5EJct9jTDNKco4YiYfETAseq1gaduBtsJUcNnFicfvh3bTV6', 'cesiumTest3');
final cesiumTest4 = TestWallet(
'5HD1oSv6A7VNxPYos6F86JFZ3bhz5LnEaWC4hkwLMj84v4ww', 'cesiumTest4');
// CUSTOM FUNCTIONS // CUSTOM FUNCTIONS
@ -43,11 +52,17 @@ Future sleep([int time = 1000]) async {
await Future.delayed(Duration(milliseconds: time)); await Future.delayed(Duration(milliseconds: time));
} }
Future<String> clipPaste() async =>
(await Clipboard.getData('text/plain'))?.text ?? '';
clipCopy(String text) async =>
await Clipboard.setData(ClipboardData(text: text));
Future humanRead([int time = 1, bool force = false]) async { Future humanRead([int time = 1, bool force = false]) async {
if (isHumanReading || force) io.sleep(Duration(seconds: time)); if (isHumanReading || force) io.sleep(Duration(seconds: time));
} }
Future goKey(Key buttonKey, Future tapKey(Key buttonKey,
{Finder? customFinder, int duration = 100, bool selectLast = false}) async { {Finder? customFinder, int duration = 100, bool selectLast = false}) async {
if (duration != 0) { if (duration != 0) {
await tester.pumpAndSettle(Duration(milliseconds: duration)); await tester.pumpAndSettle(Duration(milliseconds: duration));
@ -58,6 +73,42 @@ Future goKey(Key buttonKey,
humanRead(); humanRead();
} }
Finder findByKey(Key key) {
return find.byKey(key);
}
bool isButtonEnabled(Key key) {
return tester.widget<ElevatedButton>(findByKey(key)).enabled;
}
Future scrollUntil(Key element) async {
final findList = find.byType(Scrollable);
final findElement = findByKey(element);
await tester.scrollUntilVisible(
findElement,
500.0,
scrollable: findList,
);
}
Future<void> waitForButtonEnabled(Key key,
{Duration timeout = const Duration(seconds: 5),
bool reverse = false}) async {
final end = DateTime.now().add(timeout);
log.d('INTEGRATION TEST: Wait for $key to be enabled');
do {
if (DateTime.now().isAfter(end)) {
throw Exception('Timed out waiting for button enabled: $key');
}
await tester.pumpAndSettle();
await Future.delayed(const Duration(milliseconds: 100));
} while (reverse ? isButtonEnabled(key) : !isButtonEnabled(key));
humanRead();
}
Future goBack() async { 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');
@ -129,6 +180,7 @@ Future spawnBlock({int number = 1, int duration = 200, int? until}) async {
await sleep(200); await sleep(200);
} }
// Pay in background
Future bkPay( Future bkPay(
{required String fromAddress, {required String fromAddress,
required String destAddress, required String destAddress,
@ -142,6 +194,7 @@ Future bkPay(
await sleep(500); await sleep(500);
} }
// Certify in background
Future bkCertify( Future bkCertify(
{required String fromAddress, required String destAddress}) async { {required String fromAddress, required String destAddress}) async {
sub.certify(fromAddress, destAddress, 'AAAAA'); sub.certify(fromAddress, destAddress, 'AAAAA');
@ -149,6 +202,7 @@ Future bkCertify(
await sleep(500); await sleep(500);
} }
// Confirm my identity in background
Future bkConfirmIdentity( Future bkConfirmIdentity(
{required String fromAddress, required String name}) async { {required String fromAddress, required String name}) async {
sub.confirmIdentity(fromAddress, name, 'AAAAA'); sub.confirmIdentity(fromAddress, name, 'AAAAA');
@ -156,16 +210,7 @@ Future bkConfirmIdentity(
await sleep(500); await sleep(500);
} }
class TestWallet { // Change node in background
String address;
String name;
TestWallet(this.address, this.name);
endAddress() => address.substring(address.length - 6);
shortAddress() => getShortPubkey(address);
}
Future bkSetNode([String? endpoint]) async { Future bkSetNode([String? endpoint]) async {
if (endpoint == null) { if (endpoint == null) {
final ipAddress = dotenv.env['ip_address'] ?? '127.0.0.1'; final ipAddress = dotenv.env['ip_address'] ?? '127.0.0.1';
@ -175,6 +220,7 @@ Future bkSetNode([String? endpoint]) async {
sub.connectNode(homeContext); sub.connectNode(homeContext);
} }
// Restore chest in background
Future bkRestoreChest([String mnemonic = testMnemonic]) async { Future bkRestoreChest([String mnemonic = testMnemonic]) async {
final myWalletProvider = final myWalletProvider =
Provider.of<MyWalletsProvider>(homeContext, listen: false); Provider.of<MyWalletsProvider>(homeContext, listen: false);
@ -215,6 +261,7 @@ Future<WalletData> _addImportAccount(
return myWallet; return myWallet;
} }
// Delete all wallets in background
Future bkDeleteAllWallets() async { Future bkDeleteAllWallets() async {
final myWalletProvider = final myWalletProvider =
Provider.of<MyWalletsProvider>(homeContext, listen: false); Provider.of<MyWalletsProvider>(homeContext, listen: false);
@ -224,11 +271,9 @@ Future bkDeleteAllWallets() async {
} }
} }
Future fastStart() async { Future bkFastStart() async {
app.main(); // Start app and wait finish starting
await waitFor('Test starting...', reverse: true); await startWait();
await tester.pumpAndSettle(const Duration(milliseconds: 100));
await sleep(2000);
// Connect to local endpoint // Connect to local endpoint
await bkSetNode(); await bkSetNode();
@ -241,3 +286,20 @@ Future fastStart() async {
await bkRestoreChest(); await bkRestoreChest();
await waitFor("y'a pas de lézard"); await waitFor("y'a pas de lézard");
} }
Future startWait() async {
app.main();
await waitFor('Test starting...', reverse: true);
await tester.pumpAndSettle(const Duration(milliseconds: 300));
await sleep(2000);
}
class TestWallet {
String address;
String name;
TestWallet(this.address, this.name);
endAddress() => address.substring(address.length - 6);
shortAddress() => getShortPubkey(address);
}

View File

@ -10,16 +10,16 @@ void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); IntegrationTestWidgetsFlutterBinding.ensureInitialized();
await dotenv.load(); await dotenv.load();
testWidgets('Gecko complete', (testerLoc) async { testWidgets('UDs creation state', (testerLoc) async {
tester = testerLoc; tester = testerLoc;
// Connect local node and import test chest in background // Connect local node and import test chest in background
await fastStart(); await bkFastStart();
// Open chest // Open chest
await firstOpenChest(); await firstOpenChest();
// Go to test1 options and check if balance growup with UDs creations // Go to test1 options and check if balance growup with UDs creations
await goKey(keyOpenWallet(test1.address)); await tapKey(keyOpenWallet(test1.address));
await waitFor('100.0 $currencyName'); await waitFor('100.0 $currencyName');
await spawnBlock(until: 10); await spawnBlock(until: 10);
await waitFor('200.0 $currencyName'); await waitFor('200.0 $currencyName');

View File

@ -83,6 +83,12 @@ const keyGoWalletsHome = Key('keyGoWalletsHome');
const keySearchField = Key('keySearchField'); const keySearchField = Key('keySearchField');
const keyConfirmSearch = Key('keyConfirmSearch'); const keyConfirmSearch = Key('keyConfirmSearch');
// Import Cesium wallet
const keyCesiumId = Key('keyCesiumId');
const keyCesiumPassword = Key('keyCesiumPassword');
const keySelectWallet = Key('keySelectWallet');
const keyCesiumIdVisible = Key('keyCesiumIdVisible');
// Items keys // Items keys
Key keyTransaction(int keyId) => Key('keyTransaction$keyId'); Key keyTransaction(int keyId) => Key('keyTransaction$keyId');
Key keyMnemonicWord(String word) => Key('keyMnemonicWord$word'); Key keyMnemonicWord(String word) => Key('keyMnemonicWord$word');

View File

@ -354,6 +354,7 @@ class GenerateWalletsProvider with ChangeNotifier {
cellController10, cellController10,
cellController11 cellController11
]; ];
if (sentence?.text == null) return;
for (var word in sentence!.text!.split(' ')) { for (var word in sentence!.text!.split(' ')) {
bool isValid = isBipWord(word, false); bool isValid = isBipWord(word, false);

View File

@ -38,7 +38,8 @@ class SubstrateSdk with ChangeNotifier {
TextEditingController csSalt = TextEditingController(); TextEditingController csSalt = TextEditingController();
TextEditingController csPassword = TextEditingController(); TextEditingController csPassword = TextEditingController();
String g1V1NewAddress = ''; String g1V1NewAddress = '';
bool isCesiumIDVisible = true; bool isCesiumIDVisible = false;
bool isCesiumAddresLoading = false;
///////////////////////////////////// /////////////////////////////////////
////////// 1: API METHODS /////////// ////////// 1: API METHODS ///////////

View File

@ -22,7 +22,6 @@ class ImportG1v1 extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
// HomeProvider _homeProvider = Provider.of<HomeProvider>(context);
WalletOptionsProvider walletOptions = WalletOptionsProvider walletOptions =
Provider.of<WalletOptionsProvider>(context, listen: false); Provider.of<WalletOptionsProvider>(context, listen: false);
MyWalletsProvider myWalletProvider = MyWalletsProvider myWalletProvider =
@ -110,6 +109,7 @@ class ImportG1v1 extends StatelessWidget {
return Column(children: <Widget>[ return Column(children: <Widget>[
const SizedBox(height: 20), const SizedBox(height: 20),
TextFormField( TextFormField(
key: keyCesiumId,
autofocus: true, autofocus: true,
onChanged: (text) { onChanged: (text) {
if (debounce?.isActive ?? false) { if (debounce?.isActive ?? false) {
@ -117,21 +117,23 @@ class ImportG1v1 extends StatelessWidget {
} }
debounce = Timer( debounce = Timer(
const Duration(milliseconds: debouneTime), () { const Duration(milliseconds: debouneTime), () {
sub.reload();
sub.csToV2Address( sub.csToV2Address(
sub.csSalt.text, sub.csPassword.text); sub.csSalt.text, sub.csPassword.text);
}); });
}, },
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
controller: sub.csSalt, controller: sub.csSalt,
obscureText: sub obscureText: !sub
.isCesiumIDVisible, //This will obscure text dynamically .isCesiumIDVisible, //This will obscure text dynamically
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'enterCesiumId'.tr(), hintText: 'enterCesiumId'.tr(),
suffixIcon: IconButton( suffixIcon: IconButton(
key: keyCesiumIdVisible,
icon: Icon( icon: Icon(
sub.isCesiumIDVisible sub.isCesiumIDVisible
? Icons.visibility ? Icons.visibility_off
: Icons.visibility_off, : Icons.visibility,
color: Colors.black, color: Colors.black,
), ),
onPressed: () { onPressed: () {
@ -142,6 +144,7 @@ class ImportG1v1 extends StatelessWidget {
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
TextFormField( TextFormField(
key: keyCesiumPassword,
autofocus: true, autofocus: true,
onChanged: (text) { onChanged: (text) {
if (debounce?.isActive ?? false) { if (debounce?.isActive ?? false) {
@ -149,21 +152,23 @@ class ImportG1v1 extends StatelessWidget {
} }
debounce = Timer( debounce = Timer(
const Duration(milliseconds: debouneTime), () { const Duration(milliseconds: debouneTime), () {
sub.g1V1NewAddress = '';
sub.reload();
sub.csToV2Address( sub.csToV2Address(
sub.csSalt.text, sub.csPassword.text); sub.csSalt.text, sub.csPassword.text);
}); });
}, },
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
controller: sub.csPassword, controller: sub.csPassword,
obscureText: sub obscureText: !sub
.isCesiumIDVisible, //This will obscure text dynamically .isCesiumIDVisible, //This will obscure text dynamically
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'enterCesiumPassword'.tr(), hintText: 'enterCesiumPassword'.tr(),
suffixIcon: IconButton( suffixIcon: IconButton(
icon: Icon( icon: Icon(
sub.isCesiumIDVisible sub.isCesiumIDVisible
? Icons.visibility ? Icons.visibility_off
: Icons.visibility_off, : Icons.visibility,
color: Colors.black, color: Colors.black,
), ),
onPressed: () { onPressed: () {
@ -188,14 +193,6 @@ class ImportG1v1 extends StatelessWidget {
), ),
), ),
), ),
// Text(
// getShortPubkey(sub.g1V1NewAddress),
// style: const TextStyle(
// fontSize: 18,
// color: Colors.black,
// fontWeight: FontWeight.bold,
// fontFamily: 'Monospace'),
// ),
const SizedBox(height: 20), const SizedBox(height: 20),
Text( Text(
'${balance['transferableBalance']} $currencyName', '${balance['transferableBalance']} $currencyName',
@ -214,12 +211,14 @@ class ImportG1v1 extends StatelessWidget {
Text('selectDestWallet'.tr()), Text('selectDestWallet'.tr()),
const SizedBox(height: 5), const SizedBox(height: 5),
DropdownButtonHideUnderline( DropdownButtonHideUnderline(
key: keySelectWallet,
child: DropdownButton( child: DropdownButton(
// alignment: AlignmentDirectional.topStart, // alignment: AlignmentDirectional.topStart,
value: selectedWallet, value: selectedWallet,
icon: const Icon(Icons.keyboard_arrow_down), icon: const Icon(Icons.keyboard_arrow_down),
items: myWalletProvider.listWallets.map((wallet) { items: myWalletProvider.listWallets.map((wallet) {
return DropdownMenuItem( return DropdownMenuItem(
key: keySelectThisWallet(wallet.address!),
value: wallet, value: wallet,
child: Text( child: Text(
wallet.name!, wallet.name!,
@ -238,6 +237,7 @@ class ImportG1v1 extends StatelessWidget {
width: 380 * ratio, width: 380 * ratio,
height: 60 * ratio, height: 60 * ratio,
child: ElevatedButton( child: ElevatedButton(
key: keyConfirm,
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
elevation: 4, elevation: 4,
primary: orangeC, // background primary: orangeC, // background
@ -245,7 +245,6 @@ class ImportG1v1 extends StatelessWidget {
), ),
onPressed: canValidate onPressed: canValidate
? () async { ? () async {
log.d('GOOO');
WalletData? defaultWallet = WalletData? defaultWallet =
myWalletProvider.getDefaultWallet(); myWalletProvider.getDefaultWallet();