2023-02-28 17:04:31 +01:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2022-08-28 05:08:41 +02:00
|
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
2022-08-24 21:53:16 +02:00
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:gecko/models/widgets_keys.dart';
|
|
|
|
import 'package:integration_test/integration_test.dart';
|
2022-09-09 01:12:17 +02:00
|
|
|
import '../utility/general_actions.dart';
|
|
|
|
import '../utility/tests_utility.dart';
|
2022-08-24 21:53:16 +02:00
|
|
|
|
2022-08-28 05:08:41 +02:00
|
|
|
void main() async {
|
2022-08-24 21:53:16 +02:00
|
|
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
2022-08-28 05:08:41 +02:00
|
|
|
await dotenv.load();
|
2022-08-24 21:53:16 +02:00
|
|
|
|
2022-08-28 05:08:41 +02:00
|
|
|
testWidgets('Gecko complete', (testerLoc) async {
|
2022-08-29 06:03:05 +02:00
|
|
|
// Share WidgetTester to test provider
|
2022-08-28 05:08:41 +02:00
|
|
|
tester = testerLoc;
|
2022-08-29 06:03:05 +02:00
|
|
|
|
|
|
|
// Start app and wait finish starting
|
|
|
|
await startWait();
|
2022-08-24 21:53:16 +02:00
|
|
|
|
|
|
|
// Change Duniter endpoint to local
|
2022-08-28 05:08:41 +02:00
|
|
|
await changeNode();
|
2022-08-24 21:53:16 +02:00
|
|
|
|
2022-08-27 00:31:19 +02:00
|
|
|
// Delete all existing chests is exists
|
2022-08-28 05:08:41 +02:00
|
|
|
await deleteAllWallets();
|
2022-08-24 21:53:16 +02:00
|
|
|
|
2022-08-27 00:31:19 +02:00
|
|
|
// Restore the test chest
|
2022-08-28 05:08:41 +02:00
|
|
|
await restoreChest();
|
2022-08-24 21:53:16 +02:00
|
|
|
|
2022-08-29 06:03:05 +02:00
|
|
|
// Execute a transaction to test5
|
2022-08-28 05:08:41 +02:00
|
|
|
await payTest2();
|
2022-08-24 21:53:16 +02:00
|
|
|
|
2022-08-27 00:31:19 +02:00
|
|
|
// Certify test5 account with 3 accounts to become member
|
2022-08-28 05:08:41 +02:00
|
|
|
await certifyTest5();
|
|
|
|
}, timeout: testTimeout());
|
2022-08-24 21:53:16 +02:00
|
|
|
}
|
|
|
|
|
2022-08-28 05:08:41 +02:00
|
|
|
Future payTest2() async {
|
2022-09-09 01:12:17 +02:00
|
|
|
spawnBlock(until: 13);
|
2023-02-28 17:04:31 +01:00
|
|
|
await waitFor('searchWallet'.tr());
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyOpenSearch);
|
|
|
|
final addressToSearch = await clipPaste();
|
|
|
|
final endAddress = addressToSearch.substring(addressToSearch.length - 6);
|
2022-08-27 05:43:43 +02:00
|
|
|
expect(addressToSearch, test5.address);
|
2022-08-28 05:08:41 +02:00
|
|
|
await enterText(keySearchField, addressToSearch);
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyConfirmSearch);
|
2022-08-28 05:08:41 +02:00
|
|
|
await waitFor(endAddress);
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keySearchResult(addressToSearch));
|
2022-08-28 05:08:41 +02:00
|
|
|
await waitFor(endAddress);
|
2022-09-11 13:14:52 +02:00
|
|
|
await waitFor('0.0', exactMatch: true);
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyPay);
|
2022-08-28 05:08:41 +02:00
|
|
|
await enterText(keyAmountField, '12.14');
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyConfirmPayment);
|
2022-08-28 05:08:41 +02:00
|
|
|
spawnBlock(duration: 500);
|
|
|
|
|
2023-02-28 17:04:31 +01:00
|
|
|
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1));
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyCloseTransactionScreen, duration: 0);
|
2022-08-28 05:08:41 +02:00
|
|
|
await waitFor('12.14');
|
|
|
|
spawnBlock(duration: 500);
|
|
|
|
await waitFor('9.14');
|
|
|
|
humanRead(2);
|
2022-08-24 21:53:16 +02:00
|
|
|
}
|
|
|
|
|
2022-08-28 05:08:41 +02:00
|
|
|
Future certifyTest5() async {
|
2022-08-24 21:53:16 +02:00
|
|
|
// Create identity with Test1 account
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyCertify);
|
|
|
|
await tapKey(keyConfirm);
|
2022-08-28 05:08:41 +02:00
|
|
|
spawnBlock(duration: 500);
|
2023-02-28 17:04:31 +01:00
|
|
|
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1));
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyCloseTransactionScreen);
|
2023-02-28 17:04:31 +01:00
|
|
|
await waitFor('identityCreated'.tr());
|
2022-08-24 21:53:16 +02:00
|
|
|
|
|
|
|
// Confirm Identity Test5
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyAppBarChest, duration: 300);
|
|
|
|
await tapKey(keyOpenWallet(test5.address));
|
|
|
|
await tapKey(keyCopyAddress);
|
2022-08-28 05:08:41 +02:00
|
|
|
humanRead(3);
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyConfirmIdentity);
|
2022-08-28 05:08:41 +02:00
|
|
|
await enterText(keyEnterIdentityUsername, test5.name);
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyConfirm);
|
2022-08-28 05:08:41 +02:00
|
|
|
spawnBlock(duration: 500);
|
2023-02-28 17:04:31 +01:00
|
|
|
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1));
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyCloseTransactionScreen);
|
2023-02-28 17:04:31 +01:00
|
|
|
await waitFor('identityConfirmed'.tr());
|
2022-08-28 05:08:41 +02:00
|
|
|
humanRead(2);
|
2022-08-27 00:31:19 +02:00
|
|
|
// Set wallet 2 as default wallet
|
2022-08-28 05:08:41 +02:00
|
|
|
await goBack();
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyOpenWallet(test2.address));
|
|
|
|
await tapKey(keySetDefaultWallet);
|
2023-02-28 17:04:31 +01:00
|
|
|
await waitFor('thisWalletIsDefault'.tr());
|
2022-08-24 21:53:16 +02:00
|
|
|
|
2022-08-27 00:31:19 +02:00
|
|
|
// Search Wallet 5 again
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyAppBarSearch);
|
|
|
|
final addressToSearch = await clipPaste();
|
|
|
|
final endAddress = addressToSearch.substring(addressToSearch.length - 6);
|
2022-08-27 05:43:43 +02:00
|
|
|
expect(addressToSearch, test5.address);
|
2022-08-28 05:08:41 +02:00
|
|
|
await enterText(keySearchField, addressToSearch);
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyConfirmSearch);
|
2022-08-28 05:08:41 +02:00
|
|
|
await waitFor(endAddress);
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keySearchResult(addressToSearch));
|
2022-08-28 05:08:41 +02:00
|
|
|
await waitFor(endAddress);
|
|
|
|
await waitFor('1');
|
2022-08-24 21:53:16 +02:00
|
|
|
|
|
|
|
// Certify with test2 account
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyCertify);
|
|
|
|
await tapKey(keyConfirm);
|
2022-08-28 05:08:41 +02:00
|
|
|
spawnBlock(duration: 500);
|
2023-02-28 17:04:31 +01:00
|
|
|
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1));
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyCloseTransactionScreen);
|
2022-08-28 05:08:41 +02:00
|
|
|
await waitFor('2');
|
2022-08-24 21:53:16 +02:00
|
|
|
|
|
|
|
// Change default wallet to test3
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyPay);
|
|
|
|
await tapKey(keyChangeChest);
|
|
|
|
await tapKey(keySelectThisWallet(test3.address));
|
|
|
|
await tapKey(keyConfirm);
|
2022-08-28 05:08:41 +02:00
|
|
|
await sleep();
|
2022-08-24 21:53:16 +02:00
|
|
|
|
|
|
|
// Certify with test3 account
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyCertify);
|
|
|
|
await tapKey(keyConfirm);
|
2022-08-28 05:08:41 +02:00
|
|
|
spawnBlock(duration: 500);
|
2023-02-28 17:04:31 +01:00
|
|
|
await waitFor('extrinsicValidated'.tr(), timeout: const Duration(seconds: 1));
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyCloseTransactionScreen);
|
2023-02-28 17:04:31 +01:00
|
|
|
await waitFor('mustWaitXBeforeCertify'.substring(0, 12));
|
2022-08-24 21:53:16 +02:00
|
|
|
|
|
|
|
// Check if test5 is member
|
2022-08-29 06:03:05 +02:00
|
|
|
await tapKey(keyAppBarChest, duration: 300);
|
|
|
|
await tapKey(keyOpenWallet(test5.address));
|
2023-02-28 17:04:31 +01:00
|
|
|
await waitFor('memberValidated'.tr());
|
2022-08-28 05:08:41 +02:00
|
|
|
|
|
|
|
// spawn 20 blocs and check if ud is creating
|
|
|
|
await spawnBlock(until: 20);
|
2022-09-09 01:12:17 +02:00
|
|
|
await waitFor('109.13');
|
|
|
|
await spawnBlock(until: 30);
|
2022-08-28 05:08:41 +02:00
|
|
|
await waitFor('209.13');
|
|
|
|
|
|
|
|
// Check UD reval
|
2022-09-09 01:12:17 +02:00
|
|
|
await spawnBlock(until: 60);
|
|
|
|
await waitFor('509.57');
|
2022-08-28 05:08:41 +02:00
|
|
|
humanRead(5);
|
2022-08-24 21:53:16 +02:00
|
|
|
}
|