refactor test utility; add ud creation state test
This commit is contained in:
parent
525c375c71
commit
03ab85a282
|
@ -1,76 +1,55 @@
|
||||||
|
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';
|
||||||
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';
|
||||||
|
|
||||||
void main() {
|
void main() async {
|
||||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
await dotenv.load();
|
||||||
|
|
||||||
testWidgets('Gecko complete', (tester) async {
|
testWidgets('Gecko complete', (testerLoc) async {
|
||||||
app.main();
|
tester = testerLoc;
|
||||||
await tester.pumpAndSettle(const Duration(seconds: 1));
|
// Connect local node and import test chest in background
|
||||||
|
await fastStart();
|
||||||
|
|
||||||
// Change Duniter endpoint to local
|
// Open chest
|
||||||
await changeNode(tester);
|
await firstOpenChest();
|
||||||
|
await goBack();
|
||||||
// Delete all existing chests is exists
|
|
||||||
await deleteAllWallets(tester);
|
|
||||||
|
|
||||||
// Restore the test chest
|
|
||||||
await restoreChest(tester);
|
|
||||||
|
|
||||||
// Go wallet 5 view
|
// Go wallet 5 view
|
||||||
await goKey(tester, keyOpenSearch);
|
await goKey(keyOpenSearch);
|
||||||
await enterText(tester, keySearchField, test5.address);
|
await enterText(keySearchField, test5.address);
|
||||||
await goKey(tester, keyConfirmSearch);
|
await goKey(keyConfirmSearch);
|
||||||
await waitFor(tester, test5.shortAddress());
|
await waitFor(test5.shortAddress());
|
||||||
await goKey(tester, keySearchResult(test5.address));
|
await goKey(keySearchResult(test5.address));
|
||||||
await waitFor(tester, 'Certifier');
|
await waitFor('Certifier');
|
||||||
await waitFor(tester, 'Vous devez ', reverse: true);
|
await waitFor('Vous devez ', reverse: true);
|
||||||
await waitFor(tester, 'Vous pourrez renouveler ', reverse: true);
|
await waitFor('Vous pourrez renouveler ', reverse: true);
|
||||||
|
|
||||||
// await spawnBlock(tester, number: 10);
|
|
||||||
// Background pay 25
|
// Background pay 25
|
||||||
await pay(tester,
|
await bkPay(
|
||||||
fromAddress: test1.address, destAddress: test5.address, amount: 25);
|
fromAddress: test1.address, destAddress: test5.address, amount: 25);
|
||||||
await waitFor(tester, '25.0 $currencyName');
|
await waitFor('25.0 $currencyName');
|
||||||
await spawnBlock(tester);
|
await spawnBlock();
|
||||||
await waitFor(tester, '22.0 $currencyName');
|
await waitFor('22.0 $currencyName');
|
||||||
await certify(tester,
|
await bkCertify(fromAddress: test1.address, destAddress: test5.address);
|
||||||
fromAddress: test1.address, destAddress: test5.address);
|
await waitFor('1', exactMatch: true);
|
||||||
await waitFor(tester, '1', exactMatch: true);
|
await bkConfirmIdentity(fromAddress: test5.address, name: test5.name);
|
||||||
await confirmIdentity(tester, fromAddress: test5.address, name: test5.name);
|
await bkCertify(fromAddress: test2.address, destAddress: test5.address);
|
||||||
await certify(tester,
|
await waitFor('2', exactMatch: true);
|
||||||
fromAddress: test2.address, destAddress: test5.address);
|
await bkCertify(fromAddress: test3.address, destAddress: test5.address);
|
||||||
|
await waitFor('3', exactMatch: true);
|
||||||
// // Change default wallet to test3
|
await bkCertify(fromAddress: test4.address, destAddress: test5.address);
|
||||||
// await goKey(tester, keyPay);
|
await waitFor('4', exactMatch: true);
|
||||||
// await goKey(tester, keyChangeChest);
|
await bkPay(
|
||||||
// await goKey(tester, keySelectThisWallet(test2.address));
|
|
||||||
// await goKey(tester, keyConfirm);
|
|
||||||
// await sleep(tester);
|
|
||||||
|
|
||||||
// // Certify with test3 account
|
|
||||||
// await goKey(tester, keyCertify);
|
|
||||||
// await goKey(tester, keyConfirm);
|
|
||||||
// await spawnBlock(tester, duration: 500);
|
|
||||||
// await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
|
|
||||||
// await goKey(tester, keyCloseTransactionScreen);
|
|
||||||
// await waitFor(tester, 'Vous devez attendre');
|
|
||||||
|
|
||||||
await waitFor(tester, '2', exactMatch: true);
|
|
||||||
await certify(tester,
|
|
||||||
fromAddress: test3.address, destAddress: test5.address);
|
|
||||||
await waitFor(tester, '3', exactMatch: true);
|
|
||||||
await certify(tester,
|
|
||||||
fromAddress: test4.address, destAddress: test5.address);
|
|
||||||
await waitFor(tester, '4', exactMatch: true);
|
|
||||||
await pay(tester,
|
|
||||||
fromAddress: test2.address, destAddress: test5.address, amount: 40);
|
fromAddress: test2.address, destAddress: test5.address, amount: 40);
|
||||||
await waitFor(tester, '61.99 $currencyName');
|
await waitFor('61.99 $currencyName');
|
||||||
await spawnBlock(tester, until: 25);
|
await spawnBlock(until: 10);
|
||||||
});
|
await waitFor('161.99 $currencyName');
|
||||||
|
await spawnBlock(until: 20);
|
||||||
|
await waitFor('261.99 $currencyName');
|
||||||
|
}, timeout: testTimeout());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"first_ud": 10000,
|
"first_ud": 10000,
|
||||||
"first_ud_reeval": 100,
|
"first_ud_reeval": 50,
|
||||||
"genesis_parameters": {
|
"genesis_parameters": {
|
||||||
"genesis_certs_expire_on": 50,
|
"genesis_certs_expire_on": 500,
|
||||||
"genesis_certs_min_received": 3,
|
"genesis_certs_min_received": 3,
|
||||||
"genesis_memberships_expire_on": 1051200,
|
"genesis_memberships_expire_on": 1051200,
|
||||||
"genesis_smith_certs_expire_on": 2102400,
|
"genesis_smith_certs_expire_on": 2102400,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.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';
|
||||||
|
@ -6,118 +7,135 @@ import 'package:gecko/main.dart' as app;
|
||||||
import 'general_actions.dart';
|
import 'general_actions.dart';
|
||||||
import 'tests_utility.dart';
|
import 'tests_utility.dart';
|
||||||
|
|
||||||
void main() {
|
void main() async {
|
||||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
await dotenv.load();
|
||||||
|
|
||||||
testWidgets('Gecko complete', (tester) async {
|
testWidgets('Gecko complete', (testerLoc) async {
|
||||||
|
tester = testerLoc;
|
||||||
app.main();
|
app.main();
|
||||||
await tester.pumpAndSettle(const Duration(seconds: 1));
|
await waitFor('Test starting...', reverse: true);
|
||||||
|
await tester.pumpAndSettle(const Duration(milliseconds: 100));
|
||||||
|
await sleep(2000);
|
||||||
|
|
||||||
// Change Duniter endpoint to local
|
// Change Duniter endpoint to local
|
||||||
await changeNode(tester);
|
await changeNode();
|
||||||
|
|
||||||
// Delete all existing chests is exists
|
// Delete all existing chests is exists
|
||||||
await deleteAllWallets(tester);
|
await deleteAllWallets();
|
||||||
|
|
||||||
// Restore the test chest
|
// Restore the test chest
|
||||||
await restoreChest(tester);
|
await restoreChest();
|
||||||
|
|
||||||
// Execute a transaction to test2
|
// Execute a transaction to test2
|
||||||
await payTest2(tester);
|
await payTest2();
|
||||||
|
|
||||||
// Certify test5 account with 3 accounts to become member
|
// Certify test5 account with 3 accounts to become member
|
||||||
await certifyTest5(tester);
|
await certifyTest5();
|
||||||
});
|
}, timeout: testTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future payTest2(WidgetTester tester) async {
|
Future payTest2() async {
|
||||||
await waitFor(tester, 'Rechercher');
|
await waitFor('Rechercher');
|
||||||
await goKey(tester, keyOpenSearch);
|
await goKey(keyOpenSearch);
|
||||||
final addressToSearch = (await Clipboard.getData('text/plain'))!.text;
|
final addressToSearch = (await Clipboard.getData('text/plain'))!.text;
|
||||||
final endAddress = addressToSearch!.substring(addressToSearch.length - 6);
|
final endAddress = addressToSearch!.substring(addressToSearch.length - 6);
|
||||||
expect(addressToSearch, test5.address);
|
expect(addressToSearch, test5.address);
|
||||||
await enterText(tester, keySearchField, addressToSearch);
|
await enterText(keySearchField, addressToSearch);
|
||||||
await goKey(tester, keyConfirmSearch);
|
await goKey(keyConfirmSearch);
|
||||||
await waitFor(tester, endAddress);
|
await waitFor(endAddress);
|
||||||
await goKey(tester, keySearchResult(addressToSearch));
|
await goKey(keySearchResult(addressToSearch));
|
||||||
await waitFor(tester, endAddress);
|
await waitFor(endAddress);
|
||||||
await waitFor(tester, '0.0 ĞD');
|
await waitFor('0.0 ĞD');
|
||||||
await goKey(tester, keyPay);
|
await goKey(keyPay);
|
||||||
await enterText(tester, keyAmountField, '12.14');
|
await enterText(keyAmountField, '12.14');
|
||||||
await goKey(tester, keyConfirmPayment);
|
await goKey(keyConfirmPayment);
|
||||||
await spawnBlock(tester);
|
spawnBlock(duration: 500);
|
||||||
|
|
||||||
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
|
await waitFor('validé !', timeout: const Duration(seconds: 1));
|
||||||
await goKey(tester, keyCloseTransactionScreen, duration: 0);
|
await goKey(keyCloseTransactionScreen, duration: 0);
|
||||||
await waitFor(tester, '12.14');
|
await waitFor('12.14');
|
||||||
await spawnBlock(tester);
|
spawnBlock(duration: 500);
|
||||||
await waitFor(tester, '9.14');
|
await waitFor('9.14');
|
||||||
|
humanRead(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future certifyTest5(WidgetTester tester) async {
|
Future certifyTest5() async {
|
||||||
// Create identity with Test1 account
|
// Create identity with Test1 account
|
||||||
await goKey(tester, keyCertify);
|
await goKey(keyCertify);
|
||||||
await goKey(tester, keyConfirm);
|
await goKey(keyConfirm);
|
||||||
await spawnBlock(tester, duration: 500);
|
spawnBlock(duration: 500);
|
||||||
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
|
await waitFor('validé !', timeout: const Duration(seconds: 1));
|
||||||
await goKey(tester, keyCloseTransactionScreen);
|
await goKey(keyCloseTransactionScreen);
|
||||||
await waitFor(tester, 'Identité créée');
|
await waitFor('Identité créée');
|
||||||
|
|
||||||
// Confirm Identity Test5
|
// Confirm Identity Test5
|
||||||
await goKey(tester, keyAppBarChest, duration: 300);
|
await goKey(keyAppBarChest, duration: 300);
|
||||||
await goKey(tester, keyOpenWallet(test5.address));
|
await goKey(keyOpenWallet(test5.address));
|
||||||
await goKey(tester, keyCopyAddress);
|
await goKey(keyCopyAddress);
|
||||||
await goKey(tester, keyConfirmIdentity);
|
humanRead(3);
|
||||||
await enterText(tester, keyEnterIdentityUsername, test5.name);
|
await goKey(keyConfirmIdentity);
|
||||||
await goKey(tester, keyConfirm);
|
await enterText(keyEnterIdentityUsername, test5.name);
|
||||||
await spawnBlock(tester, duration: 500);
|
await goKey(keyConfirm);
|
||||||
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
|
spawnBlock(duration: 500);
|
||||||
await goKey(tester, keyCloseTransactionScreen);
|
await waitFor('validé !', timeout: const Duration(seconds: 1));
|
||||||
await waitFor(tester, 'Identité confirmée');
|
await goKey(keyCloseTransactionScreen);
|
||||||
|
await waitFor('Identité confirmée');
|
||||||
|
humanRead(2);
|
||||||
// Set wallet 2 as default wallet
|
// Set wallet 2 as default wallet
|
||||||
await goBack(tester);
|
await goBack();
|
||||||
await goKey(tester, keyOpenWallet(test2.address));
|
await goKey(keyOpenWallet(test2.address));
|
||||||
await goKey(tester, keySetDefaultWallet);
|
await goKey(keySetDefaultWallet);
|
||||||
await waitFor(tester, 'Ce portefeuille est celui par defaut');
|
await waitFor('Ce portefeuille est celui par defaut');
|
||||||
|
|
||||||
// Search Wallet 5 again
|
// Search Wallet 5 again
|
||||||
await goKey(tester, keyAppBarSearch);
|
await goKey(keyAppBarSearch);
|
||||||
final addressToSearch = (await Clipboard.getData('text/plain'))!.text;
|
final addressToSearch = (await Clipboard.getData('text/plain'))!.text;
|
||||||
final endAddress = addressToSearch!.substring(addressToSearch.length - 6);
|
final endAddress = addressToSearch!.substring(addressToSearch.length - 6);
|
||||||
expect(addressToSearch, test5.address);
|
expect(addressToSearch, test5.address);
|
||||||
await enterText(tester, keySearchField, addressToSearch);
|
await enterText(keySearchField, addressToSearch);
|
||||||
await goKey(tester, keyConfirmSearch);
|
await goKey(keyConfirmSearch);
|
||||||
await waitFor(tester, endAddress);
|
await waitFor(endAddress);
|
||||||
await goKey(tester, keySearchResult(addressToSearch));
|
await goKey(keySearchResult(addressToSearch));
|
||||||
await waitFor(tester, endAddress);
|
await waitFor(endAddress);
|
||||||
await waitFor(tester, '1');
|
await waitFor('1');
|
||||||
|
|
||||||
// Certify with test2 account
|
// Certify with test2 account
|
||||||
await goKey(tester, keyCertify);
|
await goKey(keyCertify);
|
||||||
await goKey(tester, keyConfirm);
|
await goKey(keyConfirm);
|
||||||
await spawnBlock(tester, duration: 500);
|
spawnBlock(duration: 500);
|
||||||
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
|
await waitFor('validé !', timeout: const Duration(seconds: 1));
|
||||||
await goKey(tester, keyCloseTransactionScreen);
|
await goKey(keyCloseTransactionScreen);
|
||||||
await waitFor(tester, '2');
|
await waitFor('2');
|
||||||
|
|
||||||
// Change default wallet to test3
|
// Change default wallet to test3
|
||||||
await goKey(tester, keyPay);
|
await goKey(keyPay);
|
||||||
await goKey(tester, keyChangeChest);
|
await goKey(keyChangeChest);
|
||||||
await goKey(tester, keySelectThisWallet(test3.address));
|
await goKey(keySelectThisWallet(test3.address));
|
||||||
await goKey(tester, keyConfirm);
|
await goKey(keyConfirm);
|
||||||
await sleep(tester);
|
await sleep();
|
||||||
|
|
||||||
// Certify with test3 account
|
// Certify with test3 account
|
||||||
await goKey(tester, keyCertify);
|
await goKey(keyCertify);
|
||||||
await goKey(tester, keyConfirm);
|
await goKey(keyConfirm);
|
||||||
await spawnBlock(tester, duration: 500);
|
spawnBlock(duration: 500);
|
||||||
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
|
await waitFor('validé !', timeout: const Duration(seconds: 1));
|
||||||
await goKey(tester, keyCloseTransactionScreen);
|
await goKey(keyCloseTransactionScreen);
|
||||||
await waitFor(tester, 'Vous devez attendre');
|
await waitFor('Vous devez attendre');
|
||||||
|
|
||||||
// Check if test5 is member
|
// Check if test5 is member
|
||||||
await goKey(tester, keyAppBarChest, duration: 300);
|
await goKey(keyAppBarChest, duration: 300);
|
||||||
await goKey(tester, keyOpenWallet(test5.address));
|
await goKey(keyOpenWallet(test5.address));
|
||||||
await waitFor(tester, 'Membre validé !');
|
await waitFor('Membre validé !');
|
||||||
|
|
||||||
|
// spawn 20 blocs and check if ud is creating
|
||||||
|
await spawnBlock(until: 10);
|
||||||
|
await waitFor('109.13');
|
||||||
|
await spawnBlock(until: 20);
|
||||||
|
await waitFor('209.13');
|
||||||
|
|
||||||
|
// Check UD reval
|
||||||
|
await spawnBlock(until: 50);
|
||||||
|
await waitFor('509.35');
|
||||||
|
humanRead(5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,89 +8,92 @@ import 'tests_utility.dart';
|
||||||
|
|
||||||
// GENERAL ACTIONS
|
// GENERAL ACTIONS
|
||||||
|
|
||||||
Future changeNode(WidgetTester tester) async {
|
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(tester, keyDrawerMenu);
|
await goKey(keyDrawerMenu);
|
||||||
await goKey(tester, keyParameters);
|
await goKey(keyParameters);
|
||||||
await goKey(tester, keySelectDuniterNodeDropDown, duration: 5);
|
await goKey(keySelectDuniterNodeDropDown, duration: 5);
|
||||||
await goKey(tester, keySelectDuniterNode('Personnalisé'), selectLast: true);
|
await goKey(keySelectDuniterNode('Personnalisé'), selectLast: true);
|
||||||
await enterText(tester, keyCustomDuniterEndpoint, 'ws://$ipAddress:9944');
|
await enterText(keyCustomDuniterEndpoint, 'ws://$ipAddress:9944');
|
||||||
await goKey(tester, keyConnectToEndpoint);
|
await goKey(keyConnectToEndpoint);
|
||||||
await isIconPresent(tester, Icons.add_card_sharp,
|
await isIconPresent(Icons.add_card_sharp,
|
||||||
timeout: const Duration(seconds: 8));
|
timeout: const Duration(seconds: 8));
|
||||||
await goBack(tester);
|
await goBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future deleteAllWallets(WidgetTester tester) async {
|
Future deleteAllWallets() async {
|
||||||
if (await isPresent(tester, 'Rechercher')) {
|
if (await isPresent('Rechercher')) {
|
||||||
await goKey(tester, keyDrawerMenu);
|
await goKey(keyDrawerMenu);
|
||||||
await goKey(tester, keyParameters);
|
await goKey(keyParameters);
|
||||||
await goKey(tester, keyDeleteAllWallets);
|
await goKey(keyDeleteAllWallets);
|
||||||
await goKey(tester, keyConfirm);
|
await goKey(keyConfirm);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future restoreChest(WidgetTester tester) async {
|
Future restoreChest() async {
|
||||||
// Copy test mnemonic in clipboard
|
// Copy test mnemonic in clipboard
|
||||||
Clipboard.setData(const ClipboardData(text: testMnemonic));
|
Clipboard.setData(const ClipboardData(text: testMnemonic));
|
||||||
|
|
||||||
// Open screen import chest
|
// Open screen import chest
|
||||||
await goKey(tester, keyRestoreChest);
|
await goKey(keyRestoreChest, duration: 0);
|
||||||
|
|
||||||
// Wait frame stop before continue
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
// Tap on button to paste mnemonic
|
// Tap on button to paste mnemonic
|
||||||
await goKey(tester, keyPastMnemonic);
|
await goKey(keyPastMnemonic);
|
||||||
|
|
||||||
// Tap on next button 4 times to skip 3 screen
|
// Tap on next button 4 times to skip 3 screen
|
||||||
await goKey(tester, keyGoNext);
|
await goKey(keyGoNext);
|
||||||
await goKey(tester, keyGoNext);
|
await goKey(keyGoNext);
|
||||||
await goKey(tester, keyGoNext);
|
await goKey(keyGoNext);
|
||||||
await goKey(tester, keyGoNext);
|
await goKey(keyGoNext);
|
||||||
|
|
||||||
// Check if cached password checkbox is checked
|
// Check if cached password checkbox is checked
|
||||||
final isCached = await isIconPresent(tester, 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(tester, keyCachePassword, duration: 0);
|
if (!isCached) await goKey(keyCachePassword, duration: 0);
|
||||||
|
|
||||||
// Enter password
|
// Enter password
|
||||||
await enterText(tester, 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(tester, 'Accéder à mon coffre');
|
await waitFor('Accéder à mon coffre');
|
||||||
|
|
||||||
// Go to wallets home
|
// Go to wallets home
|
||||||
await goKey(tester, keyGoWalletsHome, duration: 0);
|
await goKey(keyGoWalletsHome, duration: 0);
|
||||||
|
|
||||||
// Check if string "ĞD" is present in screen
|
// Check if string "ĞD" is present in screen
|
||||||
await waitFor(tester, 'ĞD');
|
await waitFor('ĞD');
|
||||||
|
|
||||||
// Tap on add a new derivation button
|
// Tap on add a new derivation button
|
||||||
await addDerivation(tester);
|
await addDerivation();
|
||||||
|
|
||||||
// Tap on Wallet 5
|
// Tap on Wallet 5
|
||||||
await goKey(tester, keyOpenWallet(test5.address));
|
await goKey(keyOpenWallet(test5.address));
|
||||||
|
|
||||||
// Copy address of Wallet 5
|
// Copy address of Wallet 5
|
||||||
await goKey(tester, keyCopyAddress);
|
await goKey(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(tester, 'Cette adresse a été copié');
|
await waitFor('Cette adresse a été copié');
|
||||||
|
|
||||||
// Pop screen 2 time to go back home screen
|
// Pop screen 2 time to go back home
|
||||||
await goBack(tester);
|
await goBack();
|
||||||
await goBack(tester);
|
await goBack();
|
||||||
|
|
||||||
// Check if string "y'a pas de lézard" is present in screen
|
|
||||||
await waitFor(tester, "y'a pas de lézard");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future addDerivation(WidgetTester tester) async {
|
Future addDerivation() async {
|
||||||
await goKey(tester, keyAddDerivation);
|
await goKey(keyAddDerivation);
|
||||||
await waitFor(tester, 'Portefeuille 5');
|
await waitFor('Portefeuille 5');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future firstOpenChest() async {
|
||||||
|
await goKey(keyOpenWalletsHomme);
|
||||||
|
sleep(300);
|
||||||
|
final isCached = await isIconPresent(Icons.check_box);
|
||||||
|
if (!isCached) await goKey(keyCachePassword, duration: 0);
|
||||||
|
await enterText(keyPinForm, 'AAAAA', 0);
|
||||||
|
await waitFor('100.0 $currencyName');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# MP="`dirname \"$0\"`"
|
|
||||||
# MP="`( cd \"$MP\" && pwd )`"
|
|
||||||
# cd $MP
|
|
||||||
|
|
||||||
testName=$1
|
testName=$1
|
||||||
|
option=$2
|
||||||
[[ ! $testName ]] && testName='gecko_complete'
|
[[ ! $testName ]] && testName='gecko_complete'
|
||||||
|
|
||||||
# Get local IP and set .env
|
# Get local IP and set .env
|
||||||
ip_address=$(hostname -I | awk '{print $1}')
|
ip_address=$(hostname -I | awk '{print $1}')
|
||||||
echo "ip_address=$ip_address" > .env
|
echo "ip_address=$ip_address" > .env
|
||||||
|
[[ $option == 'human' ]] && echo "isHumanReading=true" >> .env
|
||||||
|
|
||||||
## Start local Duniter node
|
## Start local Duniter node
|
||||||
cd integration_test/duniter
|
cd integration_test/duniter
|
||||||
|
|
|
@ -1,10 +1,21 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.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';
|
||||||
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
|
import 'package:gecko/providers/generate_wallets.dart';
|
||||||
|
import 'package:gecko/providers/my_wallets.dart';
|
||||||
import 'package:gecko/providers/substrate_sdk.dart';
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'dart:io' as io;
|
||||||
|
import 'package:gecko/main.dart' as app;
|
||||||
|
|
||||||
|
final bool isHumanReading =
|
||||||
|
dotenv.env['isHumanReading'] == 'true' ? true : false;
|
||||||
|
Timeout testTimeout([int seconds = 120]) =>
|
||||||
|
Timeout(Duration(seconds: isHumanReading ? 600 : seconds));
|
||||||
final sub = Provider.of<SubstrateSdk>(homeContext, listen: false);
|
final sub = Provider.of<SubstrateSdk>(homeContext, listen: false);
|
||||||
|
late WidgetTester tester;
|
||||||
|
|
||||||
// TEST WALLETS CONSTS
|
// TEST WALLETS CONSTS
|
||||||
const testMnemonic =
|
const testMnemonic =
|
||||||
|
@ -28,11 +39,15 @@ final test5 =
|
||||||
|
|
||||||
// CUSTOM FUNCTIONS
|
// CUSTOM FUNCTIONS
|
||||||
|
|
||||||
Future sleep(WidgetTester tester, [int time = 1000]) async {
|
Future sleep([int time = 1000]) async {
|
||||||
await Future.delayed(Duration(milliseconds: time));
|
await Future.delayed(Duration(milliseconds: time));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future goKey(WidgetTester tester, Key buttonKey,
|
Future humanRead([int time = 1, bool force = false]) async {
|
||||||
|
if (isHumanReading || force) io.sleep(Duration(seconds: time));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future goKey(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));
|
||||||
|
@ -40,26 +55,27 @@ Future goKey(WidgetTester tester, Key buttonKey,
|
||||||
final Finder finder = customFinder ?? find.byKey(buttonKey);
|
final Finder finder = customFinder ?? find.byKey(buttonKey);
|
||||||
log.d('INTEGRATION TEST: Tap on ${finder.description}}');
|
log.d('INTEGRATION TEST: Tap on ${finder.description}}');
|
||||||
await tester.tap(selectLast ? finder.last : finder);
|
await tester.tap(selectLast ? finder.last : finder);
|
||||||
// await tester.pumpAndSettle(Duration(milliseconds: duration));
|
humanRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future goBack(WidgetTester tester) 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');
|
||||||
navigator.pop();
|
navigator.pop();
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
humanRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future enterText(WidgetTester tester, Key fieldKey, String textIn,
|
Future enterText(Key fieldKey, String textIn, [int duration = 200]) async {
|
||||||
[int duration = 200]) async {
|
|
||||||
if (duration != 0) {
|
if (duration != 0) {
|
||||||
await tester.pumpAndSettle(Duration(milliseconds: duration));
|
await tester.pumpAndSettle(Duration(milliseconds: duration));
|
||||||
}
|
}
|
||||||
log.d('INTEGRATION TEST: Enter text: $textIn');
|
log.d('INTEGRATION TEST: Enter text: $textIn');
|
||||||
await tester.enterText(find.byKey(fieldKey), textIn);
|
await tester.enterText(find.byKey(fieldKey), textIn);
|
||||||
|
humanRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> waitFor(WidgetTester tester, String text,
|
Future<void> waitFor(String text,
|
||||||
{Duration timeout = const Duration(seconds: 5),
|
{Duration timeout = const Duration(seconds: 5),
|
||||||
bool reverse = false,
|
bool reverse = false,
|
||||||
bool exactMatch = false}) async {
|
bool exactMatch = false}) async {
|
||||||
|
@ -76,41 +92,44 @@ Future<void> waitFor(WidgetTester tester, String text,
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test if text is visible on screen, return a boolean
|
// Test if text is visible on screen, return a boolean
|
||||||
Future<bool> isPresent(WidgetTester tester, String text,
|
Future<bool> isPresent(String text,
|
||||||
{Duration timeout = const Duration(seconds: 1)}) async {
|
{Duration timeout = const Duration(seconds: 1)}) async {
|
||||||
try {
|
try {
|
||||||
await waitFor(tester, text, timeout: timeout);
|
await waitFor(text, timeout: timeout);
|
||||||
|
humanRead();
|
||||||
return true;
|
return true;
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
|
humanRead();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test if widget exist on screen, return a boolean
|
// Test if widget exist on screen, return a boolean
|
||||||
Future<bool> isIconPresent(WidgetTester tester, IconData icon,
|
Future<bool> isIconPresent(IconData icon,
|
||||||
{Duration timeout = const Duration(seconds: 1)}) async {
|
{Duration timeout = const Duration(seconds: 1)}) async {
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
final finder = find.byIcon(icon);
|
final finder = find.byIcon(icon);
|
||||||
log.d('tatatatatatata: ${finder.evaluate()}');
|
log.d('tatatatatatata: ${finder.evaluate()}');
|
||||||
|
humanRead();
|
||||||
return finder.evaluate().isEmpty ? false : true;
|
return finder.evaluate().isEmpty ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future spawnBlock(WidgetTester tester,
|
Future spawnBlock({int number = 1, int duration = 200, int? until}) async {
|
||||||
{int number = 1, int duration = 200, int? until}) async {
|
|
||||||
if (duration != 0) {
|
if (duration != 0) {
|
||||||
await sleep(tester, duration);
|
await sleep(duration);
|
||||||
}
|
}
|
||||||
if (until != null) {
|
if (until != null) {
|
||||||
number = until - sub.blocNumber;
|
number = until - sub.blocNumber;
|
||||||
}
|
}
|
||||||
await sub.spawnBlock(number);
|
await sub.spawnBlock(number);
|
||||||
await sleep(tester, 200);
|
await sleep(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future pay(WidgetTester tester,
|
Future bkPay(
|
||||||
{required String fromAddress,
|
{required String fromAddress,
|
||||||
required String destAddress,
|
required String destAddress,
|
||||||
required double amount}) async {
|
required double amount}) async {
|
||||||
|
@ -119,22 +138,22 @@ Future pay(WidgetTester tester,
|
||||||
destAddress: destAddress,
|
destAddress: destAddress,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
password: 'AAAAA');
|
password: 'AAAAA');
|
||||||
await spawnBlock(tester);
|
await spawnBlock();
|
||||||
await sleep(tester, 500);
|
await sleep(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future certify(WidgetTester tester,
|
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');
|
||||||
await spawnBlock(tester);
|
await spawnBlock();
|
||||||
await sleep(tester, 500);
|
await sleep(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future confirmIdentity(WidgetTester tester,
|
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');
|
||||||
await spawnBlock(tester);
|
await spawnBlock();
|
||||||
await sleep(tester, 500);
|
await sleep(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestWallet {
|
class TestWallet {
|
||||||
|
@ -146,3 +165,79 @@ class TestWallet {
|
||||||
endAddress() => address.substring(address.length - 6);
|
endAddress() => address.substring(address.length - 6);
|
||||||
shortAddress() => getShortPubkey(address);
|
shortAddress() => getShortPubkey(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future bkSetNode([String? endpoint]) async {
|
||||||
|
if (endpoint == null) {
|
||||||
|
final ipAddress = dotenv.env['ip_address'] ?? '127.0.0.1';
|
||||||
|
endpoint = 'ws://$ipAddress:9944';
|
||||||
|
}
|
||||||
|
configBox.put('customEndpoint', endpoint);
|
||||||
|
sub.connectNode(homeContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future bkRestoreChest([String mnemonic = testMnemonic]) async {
|
||||||
|
final myWalletProvider =
|
||||||
|
Provider.of<MyWalletsProvider>(homeContext, listen: false);
|
||||||
|
final generateWalletProvider =
|
||||||
|
Provider.of<GenerateWalletsProvider>(homeContext, listen: false);
|
||||||
|
|
||||||
|
await generateWalletProvider.storeHDWChest(homeContext);
|
||||||
|
|
||||||
|
for (int number = 0; number <= 4; number++) {
|
||||||
|
await _addImportAccount(
|
||||||
|
mnemonic: mnemonic,
|
||||||
|
chest: 0,
|
||||||
|
number: number,
|
||||||
|
name: 'test${number + 1}',
|
||||||
|
derivation: (number + 1) * 2);
|
||||||
|
}
|
||||||
|
myWalletProvider.rebuildWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<WalletData> _addImportAccount(
|
||||||
|
{required String mnemonic,
|
||||||
|
required int chest,
|
||||||
|
required int number,
|
||||||
|
required String name,
|
||||||
|
required int derivation}) async {
|
||||||
|
final address = await sub.importAccount(
|
||||||
|
mnemonic: mnemonic, derivePath: '//$derivation', password: 'AAAAA');
|
||||||
|
final myWallet = WalletData(
|
||||||
|
version: dataVersion,
|
||||||
|
chest: chest,
|
||||||
|
address: address,
|
||||||
|
number: number,
|
||||||
|
name: name,
|
||||||
|
derivation: derivation,
|
||||||
|
imageDefaultPath: '${number % 4}.png');
|
||||||
|
await walletBox.add(myWallet);
|
||||||
|
|
||||||
|
return myWallet;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future bkDeleteAllWallets() async {
|
||||||
|
final myWalletProvider =
|
||||||
|
Provider.of<MyWalletsProvider>(homeContext, listen: false);
|
||||||
|
if (myWalletProvider.listWallets.isNotEmpty) {
|
||||||
|
await myWalletProvider.deleteAllWallet(homeContext);
|
||||||
|
myWalletProvider.rebuildWidget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future fastStart() async {
|
||||||
|
app.main();
|
||||||
|
await waitFor('Test starting...', reverse: true);
|
||||||
|
await tester.pumpAndSettle(const Duration(milliseconds: 100));
|
||||||
|
await sleep(2000);
|
||||||
|
|
||||||
|
// Connect to local endpoint
|
||||||
|
await bkSetNode();
|
||||||
|
await sleep();
|
||||||
|
|
||||||
|
// Delete all existing chests is exists
|
||||||
|
await bkDeleteAllWallets();
|
||||||
|
|
||||||
|
// Restore the test chest
|
||||||
|
await bkRestoreChest();
|
||||||
|
await waitFor("y'a pas de lézard");
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
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('Gecko complete', (testerLoc) async {
|
||||||
|
tester = testerLoc;
|
||||||
|
// Connect local node and import test chest in background
|
||||||
|
await fastStart();
|
||||||
|
|
||||||
|
// Open chest
|
||||||
|
await firstOpenChest();
|
||||||
|
|
||||||
|
// Go to test1 options and check if balance growup with UDs creations
|
||||||
|
await goKey(keyOpenWallet(test1.address));
|
||||||
|
await waitFor('100.0 $currencyName');
|
||||||
|
await spawnBlock(until: 10);
|
||||||
|
await waitFor('200.0 $currencyName');
|
||||||
|
await spawnBlock(until: 20);
|
||||||
|
await waitFor('300.0 $currencyName');
|
||||||
|
}, timeout: testTimeout());
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.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';
|
||||||
|
@ -940,7 +941,11 @@ newKeySig: $newKeySig""");
|
||||||
await sdk.api.keyring.deleteAccount(keyring, keypair);
|
await sdk.api.keyring.deleteAccount(keyring, keypair);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future spawnBlock([int number = 1]) async {
|
Future spawnBlock([int number = 1, int until = 0]) async {
|
||||||
|
if (!kDebugMode) return;
|
||||||
|
if (blocNumber < until) {
|
||||||
|
number = until - blocNumber;
|
||||||
|
}
|
||||||
for (var i = 1; i <= number; i++) {
|
for (var i = 1; i <= number; i++) {
|
||||||
await sdk.webView!
|
await sdk.webView!
|
||||||
.evalJavascript('api.rpc.engine.createBlock(true, true)');
|
.evalJavascript('api.rpc.engine.createBlock(true, true)');
|
||||||
|
|
|
@ -38,6 +38,10 @@ class WalletOptions extends StatelessWidget {
|
||||||
DuniterIndexer duniterIndexer =
|
DuniterIndexer duniterIndexer =
|
||||||
Provider.of<DuniterIndexer>(context, listen: false);
|
Provider.of<DuniterIndexer>(context, listen: false);
|
||||||
|
|
||||||
|
// SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||||
|
// sub.spawnBlock();
|
||||||
|
// sub.spawnBlock(0, 25);
|
||||||
|
|
||||||
log.d(walletOptions.address.text);
|
log.d(walletOptions.address.text);
|
||||||
|
|
||||||
final int currentChest = myWalletProvider.getCurrentChest();
|
final int currentChest = myWalletProvider.getCurrentChest();
|
||||||
|
|
|
@ -43,12 +43,15 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||||
HomeProvider homeProvider =
|
HomeProvider homeProvider =
|
||||||
Provider.of<HomeProvider>(context, listen: false);
|
Provider.of<HomeProvider>(context, listen: false);
|
||||||
|
|
||||||
MyWalletsProvider myWalletProvider =
|
MyWalletsProvider myWalletProvider =
|
||||||
Provider.of<MyWalletsProvider>(context, listen: false);
|
Provider.of<MyWalletsProvider>(context, listen: false);
|
||||||
WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
|
WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
|
||||||
|
|
||||||
sub.setCurrentWallet(defaultWallet);
|
sub.setCurrentWallet(defaultWallet);
|
||||||
|
|
||||||
|
// sub.spawnBlock();
|
||||||
|
// sub.spawnBlock(0, 25);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
resizeToAvoidBottomInset: true,
|
resizeToAvoidBottomInset: true,
|
||||||
|
|
Loading…
Reference in New Issue