refactor test utility; add ud creation state test

This commit is contained in:
poka 2022-08-28 05:08:41 +02:00
parent 525c375c71
commit 03ab85a282
10 changed files with 344 additions and 210 deletions

View File

@ -1,76 +1,55 @@
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 'package:gecko/main.dart' as app;
import 'general_actions.dart';
import 'tests_utility.dart';
void main() {
void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
await dotenv.load();
testWidgets('Gecko complete', (tester) async {
app.main();
await tester.pumpAndSettle(const Duration(seconds: 1));
testWidgets('Gecko complete', (testerLoc) async {
tester = testerLoc;
// Connect local node and import test chest in background
await fastStart();
// Change Duniter endpoint to local
await changeNode(tester);
// Delete all existing chests is exists
await deleteAllWallets(tester);
// Restore the test chest
await restoreChest(tester);
// Open chest
await firstOpenChest();
await goBack();
// Go wallet 5 view
await goKey(tester, keyOpenSearch);
await enterText(tester, keySearchField, test5.address);
await goKey(tester, keyConfirmSearch);
await waitFor(tester, test5.shortAddress());
await goKey(tester, keySearchResult(test5.address));
await waitFor(tester, 'Certifier');
await waitFor(tester, 'Vous devez ', reverse: true);
await waitFor(tester, 'Vous pourrez renouveler ', reverse: true);
await goKey(keyOpenSearch);
await enterText(keySearchField, test5.address);
await goKey(keyConfirmSearch);
await waitFor(test5.shortAddress());
await goKey(keySearchResult(test5.address));
await waitFor('Certifier');
await waitFor('Vous devez ', reverse: true);
await waitFor('Vous pourrez renouveler ', reverse: true);
// await spawnBlock(tester, number: 10);
// Background pay 25
await pay(tester,
await bkPay(
fromAddress: test1.address, destAddress: test5.address, amount: 25);
await waitFor(tester, '25.0 $currencyName');
await spawnBlock(tester);
await waitFor(tester, '22.0 $currencyName');
await certify(tester,
fromAddress: test1.address, destAddress: test5.address);
await waitFor(tester, '1', exactMatch: true);
await confirmIdentity(tester, fromAddress: test5.address, name: test5.name);
await certify(tester,
fromAddress: test2.address, destAddress: test5.address);
// // Change default wallet to test3
// await goKey(tester, keyPay);
// await goKey(tester, keyChangeChest);
// 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,
await waitFor('25.0 $currencyName');
await spawnBlock();
await waitFor('22.0 $currencyName');
await bkCertify(fromAddress: test1.address, destAddress: test5.address);
await waitFor('1', exactMatch: true);
await bkConfirmIdentity(fromAddress: test5.address, name: test5.name);
await bkCertify(fromAddress: test2.address, destAddress: test5.address);
await waitFor('2', exactMatch: true);
await bkCertify(fromAddress: test3.address, destAddress: test5.address);
await waitFor('3', exactMatch: true);
await bkCertify(fromAddress: test4.address, destAddress: test5.address);
await waitFor('4', exactMatch: true);
await bkPay(
fromAddress: test2.address, destAddress: test5.address, amount: 40);
await waitFor(tester, '61.99 $currencyName');
await spawnBlock(tester, until: 25);
});
await waitFor('61.99 $currencyName');
await spawnBlock(until: 10);
await waitFor('161.99 $currencyName');
await spawnBlock(until: 20);
await waitFor('261.99 $currencyName');
}, timeout: testTimeout());
}

View File

@ -1,8 +1,8 @@
{
"first_ud": 10000,
"first_ud_reeval": 100,
"first_ud_reeval": 50,
"genesis_parameters": {
"genesis_certs_expire_on": 50,
"genesis_certs_expire_on": 500,
"genesis_certs_min_received": 3,
"genesis_memberships_expire_on": 1051200,
"genesis_smith_certs_expire_on": 2102400,

View File

@ -1,4 +1,5 @@
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:gecko/models/widgets_keys.dart';
import 'package:integration_test/integration_test.dart';
@ -6,118 +7,135 @@ import 'package:gecko/main.dart' as app;
import 'general_actions.dart';
import 'tests_utility.dart';
void main() {
void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
await dotenv.load();
testWidgets('Gecko complete', (tester) async {
testWidgets('Gecko complete', (testerLoc) async {
tester = testerLoc;
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
await changeNode(tester);
await changeNode();
// Delete all existing chests is exists
await deleteAllWallets(tester);
await deleteAllWallets();
// Restore the test chest
await restoreChest(tester);
await restoreChest();
// Execute a transaction to test2
await payTest2(tester);
await payTest2();
// Certify test5 account with 3 accounts to become member
await certifyTest5(tester);
});
await certifyTest5();
}, timeout: testTimeout());
}
Future payTest2(WidgetTester tester) async {
await waitFor(tester, 'Rechercher');
await goKey(tester, keyOpenSearch);
Future payTest2() async {
await waitFor('Rechercher');
await goKey(keyOpenSearch);
final addressToSearch = (await Clipboard.getData('text/plain'))!.text;
final endAddress = addressToSearch!.substring(addressToSearch.length - 6);
expect(addressToSearch, test5.address);
await enterText(tester, keySearchField, addressToSearch);
await goKey(tester, keyConfirmSearch);
await waitFor(tester, endAddress);
await goKey(tester, keySearchResult(addressToSearch));
await waitFor(tester, endAddress);
await waitFor(tester, '0.0 ĞD');
await goKey(tester, keyPay);
await enterText(tester, keyAmountField, '12.14');
await goKey(tester, keyConfirmPayment);
await spawnBlock(tester);
await enterText(keySearchField, addressToSearch);
await goKey(keyConfirmSearch);
await waitFor(endAddress);
await goKey(keySearchResult(addressToSearch));
await waitFor(endAddress);
await waitFor('0.0 ĞD');
await goKey(keyPay);
await enterText(keyAmountField, '12.14');
await goKey(keyConfirmPayment);
spawnBlock(duration: 500);
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
await goKey(tester, keyCloseTransactionScreen, duration: 0);
await waitFor(tester, '12.14');
await spawnBlock(tester);
await waitFor(tester, '9.14');
await waitFor('validé !', timeout: const Duration(seconds: 1));
await goKey(keyCloseTransactionScreen, duration: 0);
await waitFor('12.14');
spawnBlock(duration: 500);
await waitFor('9.14');
humanRead(2);
}
Future certifyTest5(WidgetTester tester) async {
Future certifyTest5() async {
// Create identity with Test1 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, 'Identité créée');
await goKey(keyCertify);
await goKey(keyConfirm);
spawnBlock(duration: 500);
await waitFor('validé !', timeout: const Duration(seconds: 1));
await goKey(keyCloseTransactionScreen);
await waitFor('Identité créée');
// Confirm Identity Test5
await goKey(tester, keyAppBarChest, duration: 300);
await goKey(tester, keyOpenWallet(test5.address));
await goKey(tester, keyCopyAddress);
await goKey(tester, keyConfirmIdentity);
await enterText(tester, keyEnterIdentityUsername, test5.name);
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, 'Identité confirmée');
await goKey(keyAppBarChest, duration: 300);
await goKey(keyOpenWallet(test5.address));
await goKey(keyCopyAddress);
humanRead(3);
await goKey(keyConfirmIdentity);
await enterText(keyEnterIdentityUsername, test5.name);
await goKey(keyConfirm);
spawnBlock(duration: 500);
await waitFor('validé !', timeout: const Duration(seconds: 1));
await goKey(keyCloseTransactionScreen);
await waitFor('Identité confirmée');
humanRead(2);
// Set wallet 2 as default wallet
await goBack(tester);
await goKey(tester, keyOpenWallet(test2.address));
await goKey(tester, keySetDefaultWallet);
await waitFor(tester, 'Ce portefeuille est celui par defaut');
await goBack();
await goKey(keyOpenWallet(test2.address));
await goKey(keySetDefaultWallet);
await waitFor('Ce portefeuille est celui par defaut');
// Search Wallet 5 again
await goKey(tester, keyAppBarSearch);
await goKey(keyAppBarSearch);
final addressToSearch = (await Clipboard.getData('text/plain'))!.text;
final endAddress = addressToSearch!.substring(addressToSearch.length - 6);
expect(addressToSearch, test5.address);
await enterText(tester, keySearchField, addressToSearch);
await goKey(tester, keyConfirmSearch);
await waitFor(tester, endAddress);
await goKey(tester, keySearchResult(addressToSearch));
await waitFor(tester, endAddress);
await waitFor(tester, '1');
await enterText(keySearchField, addressToSearch);
await goKey(keyConfirmSearch);
await waitFor(endAddress);
await goKey(keySearchResult(addressToSearch));
await waitFor(endAddress);
await waitFor('1');
// Certify with test2 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, '2');
await goKey(keyCertify);
await goKey(keyConfirm);
spawnBlock(duration: 500);
await waitFor('validé !', timeout: const Duration(seconds: 1));
await goKey(keyCloseTransactionScreen);
await waitFor('2');
// Change default wallet to test3
await goKey(tester, keyPay);
await goKey(tester, keyChangeChest);
await goKey(tester, keySelectThisWallet(test3.address));
await goKey(tester, keyConfirm);
await sleep(tester);
await goKey(keyPay);
await goKey(keyChangeChest);
await goKey(keySelectThisWallet(test3.address));
await goKey(keyConfirm);
await sleep();
// 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 goKey(keyCertify);
await goKey(keyConfirm);
spawnBlock(duration: 500);
await waitFor('validé !', timeout: const Duration(seconds: 1));
await goKey(keyCloseTransactionScreen);
await waitFor('Vous devez attendre');
// Check if test5 is member
await goKey(tester, keyAppBarChest, duration: 300);
await goKey(tester, keyOpenWallet(test5.address));
await waitFor(tester, 'Membre validé !');
await goKey(keyAppBarChest, duration: 300);
await goKey(keyOpenWallet(test5.address));
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);
}

View File

@ -8,89 +8,92 @@ import 'tests_utility.dart';
// GENERAL ACTIONS
Future changeNode(WidgetTester tester) async {
Future changeNode() async {
final ipAddress = dotenv.env['ip_address'] ?? '127.0.0.1';
log.d('ip address: $ipAddress');
await goKey(tester, keyDrawerMenu);
await goKey(tester, keyParameters);
await goKey(tester, keySelectDuniterNodeDropDown, duration: 5);
await goKey(tester, keySelectDuniterNode('Personnalisé'), selectLast: true);
await enterText(tester, keyCustomDuniterEndpoint, 'ws://$ipAddress:9944');
await goKey(tester, keyConnectToEndpoint);
await isIconPresent(tester, Icons.add_card_sharp,
await goKey(keyDrawerMenu);
await goKey(keyParameters);
await goKey(keySelectDuniterNodeDropDown, duration: 5);
await goKey(keySelectDuniterNode('Personnalisé'), selectLast: true);
await enterText(keyCustomDuniterEndpoint, 'ws://$ipAddress:9944');
await goKey(keyConnectToEndpoint);
await isIconPresent(Icons.add_card_sharp,
timeout: const Duration(seconds: 8));
await goBack(tester);
await goBack();
}
Future deleteAllWallets(WidgetTester tester) async {
if (await isPresent(tester, 'Rechercher')) {
await goKey(tester, keyDrawerMenu);
await goKey(tester, keyParameters);
await goKey(tester, keyDeleteAllWallets);
await goKey(tester, keyConfirm);
Future deleteAllWallets() async {
if (await isPresent('Rechercher')) {
await goKey(keyDrawerMenu);
await goKey(keyParameters);
await goKey(keyDeleteAllWallets);
await goKey(keyConfirm);
await tester.pumpAndSettle();
}
}
Future restoreChest(WidgetTester tester) async {
Future restoreChest() async {
// Copy test mnemonic in clipboard
Clipboard.setData(const ClipboardData(text: testMnemonic));
// Open screen import chest
await goKey(tester, keyRestoreChest);
// Wait frame stop before continue
await tester.pumpAndSettle();
await goKey(keyRestoreChest, duration: 0);
// Tap on button to paste mnemonic
await goKey(tester, keyPastMnemonic);
await goKey(keyPastMnemonic);
// Tap on next button 4 times to skip 3 screen
await goKey(tester, keyGoNext);
await goKey(tester, keyGoNext);
await goKey(tester, keyGoNext);
await goKey(tester, keyGoNext);
await goKey(keyGoNext);
await goKey(keyGoNext);
await goKey(keyGoNext);
await goKey(keyGoNext);
// 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 (!isCached) await goKey(tester, keyCachePassword, duration: 0);
if (!isCached) await goKey(keyCachePassword, duration: 0);
// Enter password
await enterText(tester, keyPinForm, 'AAAAA', 0);
await enterText(keyPinForm, 'AAAAA', 0);
// 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
await goKey(tester, keyGoWalletsHome, duration: 0);
await goKey(keyGoWalletsHome, duration: 0);
// Check if string "ĞD" is present in screen
await waitFor(tester, 'ĞD');
await waitFor('ĞD');
// Tap on add a new derivation button
await addDerivation(tester);
await addDerivation();
// Tap on Wallet 5
await goKey(tester, keyOpenWallet(test5.address));
await goKey(keyOpenWallet(test5.address));
// Copy address of Wallet 5
await goKey(tester, keyCopyAddress);
await goKey(keyCopyAddress);
// 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
await goBack(tester);
await goBack(tester);
// Check if string "y'a pas de lézard" is present in screen
await waitFor(tester, "y'a pas de lézard");
// Pop screen 2 time to go back home
await goBack();
await goBack();
}
Future addDerivation(WidgetTester tester) async {
await goKey(tester, keyAddDerivation);
await waitFor(tester, 'Portefeuille 5');
Future addDerivation() async {
await goKey(keyAddDerivation);
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');
}

View File

@ -1,15 +1,13 @@
#!/bin/bash
# MP="`dirname \"$0\"`"
# MP="`( cd \"$MP\" && pwd )`"
# cd $MP
testName=$1
option=$2
[[ ! $testName ]] && testName='gecko_complete'
# Get local IP and set .env
ip_address=$(hostname -I | awk '{print $1}')
echo "ip_address=$ip_address" > .env
[[ $option == 'human' ]] && echo "isHumanReading=true" >> .env
## Start local Duniter node
cd integration_test/duniter

View File

@ -1,10 +1,21 @@
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/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: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);
late WidgetTester tester;
// TEST WALLETS CONSTS
const testMnemonic =
@ -28,11 +39,15 @@ final test5 =
// CUSTOM FUNCTIONS
Future sleep(WidgetTester tester, [int time = 1000]) async {
Future sleep([int time = 1000]) async {
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 {
if (duration != 0) {
await tester.pumpAndSettle(Duration(milliseconds: duration));
@ -40,26 +55,27 @@ Future goKey(WidgetTester tester, Key buttonKey,
final Finder finder = customFinder ?? find.byKey(buttonKey);
log.d('INTEGRATION TEST: Tap on ${finder.description}}');
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));
log.d('INTEGRATION TEST: Go back');
navigator.pop();
await tester.pump();
humanRead();
}
Future enterText(WidgetTester tester, Key fieldKey, String textIn,
[int duration = 200]) async {
Future enterText(Key fieldKey, String textIn, [int duration = 200]) async {
if (duration != 0) {
await tester.pumpAndSettle(Duration(milliseconds: duration));
}
log.d('INTEGRATION TEST: Enter text: $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),
bool reverse = false,
bool exactMatch = false}) async {
@ -76,41 +92,44 @@ Future<void> waitFor(WidgetTester tester, String text,
await tester.pumpAndSettle();
await Future.delayed(const Duration(milliseconds: 100));
} while (reverse ? finder.evaluate().isNotEmpty : finder.evaluate().isEmpty);
humanRead();
}
// 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 {
try {
await waitFor(tester, text, timeout: timeout);
await waitFor(text, timeout: timeout);
humanRead();
return true;
} catch (exception) {
humanRead();
return false;
}
}
// 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 {
await tester.pumpAndSettle();
final finder = find.byIcon(icon);
log.d('tatatatatatata: ${finder.evaluate()}');
humanRead();
return finder.evaluate().isEmpty ? false : true;
}
Future spawnBlock(WidgetTester tester,
{int number = 1, int duration = 200, int? until}) async {
Future spawnBlock({int number = 1, int duration = 200, int? until}) async {
if (duration != 0) {
await sleep(tester, duration);
await sleep(duration);
}
if (until != null) {
number = until - sub.blocNumber;
}
await sub.spawnBlock(number);
await sleep(tester, 200);
await sleep(200);
}
Future pay(WidgetTester tester,
Future bkPay(
{required String fromAddress,
required String destAddress,
required double amount}) async {
@ -119,22 +138,22 @@ Future pay(WidgetTester tester,
destAddress: destAddress,
amount: amount,
password: 'AAAAA');
await spawnBlock(tester);
await sleep(tester, 500);
await spawnBlock();
await sleep(500);
}
Future certify(WidgetTester tester,
Future bkCertify(
{required String fromAddress, required String destAddress}) async {
sub.certify(fromAddress, destAddress, 'AAAAA');
await spawnBlock(tester);
await sleep(tester, 500);
await spawnBlock();
await sleep(500);
}
Future confirmIdentity(WidgetTester tester,
Future bkConfirmIdentity(
{required String fromAddress, required String name}) async {
sub.confirmIdentity(fromAddress, name, 'AAAAA');
await spawnBlock(tester);
await sleep(tester, 500);
await spawnBlock();
await sleep(500);
}
class TestWallet {
@ -146,3 +165,79 @@ class TestWallet {
endAddress() => address.substring(address.length - 6);
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");
}

View File

@ -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());
}

View File

@ -2,6 +2,7 @@
import 'dart:typed_data';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/chest_data.dart';
@ -940,7 +941,11 @@ newKeySig: $newKeySig""");
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++) {
await sdk.webView!
.evalJavascript('api.rpc.engine.createBlock(true, true)');

View File

@ -38,6 +38,10 @@ class WalletOptions extends StatelessWidget {
DuniterIndexer duniterIndexer =
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);
final int currentChest = myWalletProvider.getCurrentChest();

View File

@ -43,12 +43,15 @@ class WalletViewScreen extends StatelessWidget {
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
HomeProvider homeProvider =
Provider.of<HomeProvider>(context, listen: false);
MyWalletsProvider myWalletProvider =
Provider.of<MyWalletsProvider>(context, listen: false);
WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
sub.setCurrentWallet(defaultWallet);
// sub.spawnBlock();
// sub.spawnBlock(0, 25);
return Scaffold(
backgroundColor: backgroundColor,
resizeToAvoidBottomInset: true,