can spawn new block just after transactions
This commit is contained in:
parent
afae4130a6
commit
5744155400
|
@ -4,8 +4,10 @@ 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:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
import 'package:gecko/main.dart' as app;
|
import 'package:gecko/main.dart' as app;
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import 'tests_utility.dart';
|
import 'tests_utility.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -15,9 +17,9 @@ void main() {
|
||||||
testWidgets('Import chests', (tester) async {
|
testWidgets('Import chests', (tester) async {
|
||||||
app.main();
|
app.main();
|
||||||
await tester.pumpAndSettle(const Duration(seconds: 1));
|
await tester.pumpAndSettle(const Duration(seconds: 1));
|
||||||
final ipAddress = dotenv.env['ip_address'] ?? '127.0.0.1';
|
|
||||||
|
|
||||||
log.d('ip address: $ipAddress');
|
// Change Duniter endpoint to local
|
||||||
|
await changeNode(tester);
|
||||||
|
|
||||||
// Delete all existing chests
|
// Delete all existing chests
|
||||||
await deleteAllWallets(tester);
|
await deleteAllWallets(tester);
|
||||||
|
@ -25,12 +27,33 @@ void main() {
|
||||||
// Restore a chest
|
// Restore a chest
|
||||||
await restoreChest(tester);
|
await restoreChest(tester);
|
||||||
|
|
||||||
// Execute a transaction to ChristCosmic
|
// Execute a transaction to test2
|
||||||
await payChrist(tester);
|
await payTest2(tester);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future changeNode(WidgetTester tester) 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 sleep(tester, 10000);
|
||||||
|
await goKey(tester, keyConnectToEndpoint);
|
||||||
|
await isIconPresent(tester, Icons.add_card_sharp,
|
||||||
|
timeout: const Duration(seconds: 8));
|
||||||
|
await goBack(tester);
|
||||||
|
// final BuildContext context = tester.element(find.byKey(keyDrawerMenu));
|
||||||
|
// SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||||
|
// await sub.spawnBlock(3);
|
||||||
|
|
||||||
|
// await waitFor(tester, 'Vous êtes bien connecté');
|
||||||
|
}
|
||||||
|
|
||||||
// Customs actions
|
// Customs actions
|
||||||
Future deleteAllWallets(WidgetTester tester) async {
|
Future deleteAllWallets(WidgetTester tester) async {
|
||||||
if (await isPresent(tester, 'Rechercher')) {
|
if (await isPresent(tester, 'Rechercher')) {
|
||||||
|
@ -46,7 +69,7 @@ Future restoreChest(WidgetTester tester) async {
|
||||||
await goKey(tester, keyRestoreChest);
|
await goKey(tester, keyRestoreChest);
|
||||||
Clipboard.setData(const ClipboardData(
|
Clipboard.setData(const ClipboardData(
|
||||||
text:
|
text:
|
||||||
'smart joy blossom stomach champion fun diary relief gossip hospital logic bike'));
|
'pipe paddle ketchup filter life ice feel embody glide quantum ride usage'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await goKey(tester, keyPastMnemonic);
|
await goKey(tester, keyPastMnemonic);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
@ -64,20 +87,27 @@ Future restoreChest(WidgetTester tester) async {
|
||||||
await waitFor(tester, "y'a pas de lézard");
|
await waitFor(tester, "y'a pas de lézard");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future payChrist(WidgetTester tester) async {
|
Future payTest2(WidgetTester tester) async {
|
||||||
await waitFor(tester, 'Rechercher');
|
await waitFor(tester, 'Rechercher');
|
||||||
await goKey(tester, keyOpenSearch);
|
await goKey(tester, keyOpenSearch);
|
||||||
await enterText(tester, keySearchField, 'ChristCosmic');
|
await enterText(tester, keySearchField,
|
||||||
|
'5E4i8vcNjnrDp21Sbnp32WHm2gz8YP3GGFwmdpfg5bHd8Whb');
|
||||||
await goKey(tester, keyConfirmSearch);
|
await goKey(tester, keyConfirmSearch);
|
||||||
await waitFor(tester, 'XuiQeB');
|
await waitFor(tester, 'Hd8Whb');
|
||||||
await goKey(tester,
|
await goKey(tester,
|
||||||
keyIndexerResult('5CJKhFCpdSpumgWjSZ3TQmejJuHV6iELJrtdrfs38SXuiQeB'));
|
keySearchResult('5E4i8vcNjnrDp21Sbnp32WHm2gz8YP3GGFwmdpfg5bHd8Whb'));
|
||||||
await waitFor(tester, 'XuiQeB');
|
await waitFor(tester, 'Hd8Whb');
|
||||||
await waitFor(tester, 'ĞD');
|
await waitFor(tester, 'ĞD');
|
||||||
await goKey(tester, keyPay);
|
await goKey(tester, keyPay);
|
||||||
await enterText(tester, keyAmountField, '2.14');
|
await enterText(tester, keyAmountField, '2.14');
|
||||||
await goKey(tester, keyConfirmPayment);
|
await goKey(tester, keyConfirmPayment);
|
||||||
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 12));
|
await sleep(tester);
|
||||||
|
final BuildContext context =
|
||||||
|
tester.element(find.byKey(keyCloseTransactionScreen));
|
||||||
|
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||||
|
await sub.spawnBlock();
|
||||||
|
|
||||||
|
await waitFor(tester, 'validé !', timeout: const Duration(seconds: 1));
|
||||||
await goKey(tester, keyCloseTransactionScreen);
|
await goKey(tester, keyCloseTransactionScreen);
|
||||||
await waitFor(tester, 'XuiQeB');
|
await waitFor(tester, 'Hd8Whb');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"first_ud": 1000,
|
"first_ud": 10000,
|
||||||
"first_ud_reeval": 100,
|
"first_ud_reeval": 100,
|
||||||
"genesis_parameters": {
|
"genesis_parameters": {
|
||||||
"genesis_certs_expire_on": 10,
|
"genesis_certs_expire_on": 2102400,
|
||||||
"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,
|
||||||
|
@ -11,22 +11,22 @@
|
||||||
},
|
},
|
||||||
"identities": {
|
"identities": {
|
||||||
"test1": {
|
"test1": {
|
||||||
"balance": 1000,
|
"balance": 10000,
|
||||||
"certs": ["test2", "test3", "test4"],
|
"certs": ["test2", "test3", "test4"],
|
||||||
"pubkey": "5FeggKqw2AbnGZF9Y9WPM2QTgzENS3Hit94Ewgmzdg5a3LNa"
|
"pubkey": "5FeggKqw2AbnGZF9Y9WPM2QTgzENS3Hit94Ewgmzdg5a3LNa"
|
||||||
},
|
},
|
||||||
"test2": {
|
"test2": {
|
||||||
"balance": 1000,
|
"balance": 10000,
|
||||||
"certs": ["test1", "test3", "test4"],
|
"certs": ["test1", "test3", "test4"],
|
||||||
"pubkey": "5E4i8vcNjnrDp21Sbnp32WHm2gz8YP3GGFwmdpfg5bHd8Whb"
|
"pubkey": "5E4i8vcNjnrDp21Sbnp32WHm2gz8YP3GGFwmdpfg5bHd8Whb"
|
||||||
},
|
},
|
||||||
"test3": {
|
"test3": {
|
||||||
"balance": 1000,
|
"balance": 10000,
|
||||||
"certs": ["test1", "test2", "test4"],
|
"certs": ["test1", "test2", "test4"],
|
||||||
"pubkey": "5FhTLzXLNBPmtXtDBFECmD7fvKmTtTQDtvBTfVr97tachA1p"
|
"pubkey": "5FhTLzXLNBPmtXtDBFECmD7fvKmTtTQDtvBTfVr97tachA1p"
|
||||||
},
|
},
|
||||||
"test4": {
|
"test4": {
|
||||||
"balance": 1000,
|
"balance": 10000,
|
||||||
"certs": ["test1", "test2", "test3"],
|
"certs": ["test1", "test2", "test3"],
|
||||||
"pubkey": "5DXJ4CusmCg8S1yF6JGVn4fxgk5oFx42WctXqHZ17mykgje5"
|
"pubkey": "5DXJ4CusmCg8S1yF6JGVn4fxgk5oFx42WctXqHZ17mykgje5"
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@
|
||||||
"smith_membership_period": 1000,
|
"smith_membership_period": 1000,
|
||||||
"smith_pending_membership_period": 500,
|
"smith_pending_membership_period": 500,
|
||||||
"smiths_wot_first_cert_issuable_on": 20,
|
"smiths_wot_first_cert_issuable_on": 20,
|
||||||
"smiths_wot_min_cert_for_membership": 2,
|
"smiths_wot_min_cert_for_membership": 3,
|
||||||
"wot_first_cert_issuable_on": 20,
|
"wot_first_cert_issuable_on": 0,
|
||||||
"wot_min_cert_for_create_idty_right": 2,
|
"wot_min_cert_for_create_idty_right": 3,
|
||||||
"wot_min_cert_for_membership": 2
|
"wot_min_cert_for_membership": 3
|
||||||
},
|
},
|
||||||
"smiths": {
|
"smiths": {
|
||||||
"test1": {
|
"test1": {
|
||||||
|
|
|
@ -12,6 +12,7 @@ echo "ip_address=$ip_address" > .env
|
||||||
|
|
||||||
## Start local Duniter node
|
## Start local Duniter node
|
||||||
cd integration_test/duniter
|
cd integration_test/duniter
|
||||||
|
docker-compose down
|
||||||
rm -rf data/chains
|
rm -rf data/chains
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
|
@ -3,12 +3,16 @@ import 'package:flutter/material.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';
|
||||||
|
|
||||||
|
Future sleep(WidgetTester tester, [int time = 1000]) async {
|
||||||
|
await Future.delayed(Duration(milliseconds: time));
|
||||||
|
}
|
||||||
|
|
||||||
Future goKey(WidgetTester tester, Key buttonKey,
|
Future goKey(WidgetTester tester, Key buttonKey,
|
||||||
{Finder? customFinder, int duration = 100}) async {
|
{Finder? customFinder, int duration = 100, bool selectLast = false}) async {
|
||||||
await tester.pumpAndSettle(Duration(milliseconds: duration));
|
await tester.pumpAndSettle(Duration(milliseconds: duration));
|
||||||
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(finder);
|
await tester.tap(selectLast ? finder.last : finder);
|
||||||
// await tester.pumpAndSettle(Duration(milliseconds: duration));
|
// await tester.pumpAndSettle(Duration(milliseconds: duration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +42,6 @@ Future<void> waitFor(
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (DateTime.now().isAfter(end)) {
|
if (DateTime.now().isAfter(end)) {
|
||||||
|
|
||||||
throw Exception('Timed out waiting for text $text');
|
throw Exception('Timed out waiting for text $text');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,9 @@ const keyCachePassword = Key('keyCachePassword');
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
const keyDeleteAllWallets = Key('keyDeleteAllWallets');
|
const keyDeleteAllWallets = Key('keyDeleteAllWallets');
|
||||||
|
const keySelectDuniterNodeDropDown = Key('keySelectDuniterNodeDropDown');
|
||||||
|
const keyCustomDuniterEndpoint = Key('keyCustomDuniterEndpoint');
|
||||||
|
const keyConnectToEndpoint = Key('keyConnectToEndpoint');
|
||||||
|
|
||||||
// Onboarding
|
// Onboarding
|
||||||
const keyPastMnemonic = Key('keyPastMnemonic');
|
const keyPastMnemonic = Key('keyPastMnemonic');
|
||||||
|
@ -77,6 +80,6 @@ const keyConfirmSearch = Key('keyConfirmSearch');
|
||||||
|
|
||||||
// Unit keys
|
// Unit keys
|
||||||
Key keyMnemonicWord(String word) => Key('keyMnemonicWord$word');
|
Key keyMnemonicWord(String word) => Key('keyMnemonicWord$word');
|
||||||
Key keyIndexerResult(String keyId) => Key('keyIndexerResult$keyId');
|
|
||||||
Key keyTransaction(int keyId) => Key('keyTransaction$keyId');
|
Key keyTransaction(int keyId) => Key('keyTransaction$keyId');
|
||||||
Key keySearchResult(String keyId) => Key('keySearchResult$keyId');
|
Key keySearchResult(String keyId) => Key('keySearchResult$keyId');
|
||||||
|
Key keySelectDuniterNode(String keyId) => Key('keySelectDuniterNode$keyId');
|
||||||
|
|
|
@ -301,7 +301,7 @@ class DuniterIndexer with ChangeNotifier {
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
key: keyIndexerResult(profile['id']),
|
key: keySearchResult(profile['id']),
|
||||||
horizontalTitleGap: 40,
|
horizontalTitleGap: 40,
|
||||||
contentPadding: const EdgeInsets.all(5),
|
contentPadding: const EdgeInsets.all(5),
|
||||||
leading: cesiumPlusProvider.defaultAvatar(avatarSize),
|
leading: cesiumPlusProvider.defaultAvatar(avatarSize),
|
||||||
|
|
|
@ -873,7 +873,6 @@ newKeySig: $newKeySig""");
|
||||||
keyring.current.pubKey,
|
keyring.current.pubKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
log.d(sender.address);
|
|
||||||
TxInfoData txInfo;
|
TxInfoData txInfo;
|
||||||
|
|
||||||
txInfo = TxInfoData(
|
txInfo = TxInfoData(
|
||||||
|
@ -940,6 +939,13 @@ newKeySig: $newKeySig""");
|
||||||
await sdk.api.keyring.deleteAccount(keyring, keypair);
|
await sdk.api.keyring.deleteAccount(keyring, keypair);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future spawnBlock([int number = 1]) async {
|
||||||
|
for (var i = 1; i <= number; i++) {
|
||||||
|
await sdk.webView!
|
||||||
|
.evalJavascript('api.rpc.engine.createBlock(true, true)');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void reload() {
|
void reload() {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,9 @@ class HomeScreen extends StatelessWidget {
|
||||||
|
|
||||||
final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
|
final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
|
||||||
|
|
||||||
|
// sub.spawnBlock();
|
||||||
|
// log.d('message');
|
||||||
|
|
||||||
isTall = false;
|
isTall = false;
|
||||||
ratio = 1;
|
ratio = 1;
|
||||||
if (MediaQuery.of(context).size.height >= 930) {
|
if (MediaQuery.of(context).size.height >= 930) {
|
||||||
|
@ -122,17 +125,18 @@ class HomeScreen extends StatelessWidget {
|
||||||
myWalletProvider.rebuildWidget();
|
myWalletProvider.rebuildWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
var connectivityResult =
|
// var connectivityResult =
|
||||||
await (Connectivity().checkConnectivity());
|
// await (Connectivity().checkConnectivity());
|
||||||
|
|
||||||
|
// if (connectivityResult != ConnectivityResult.mobile &&
|
||||||
|
// connectivityResult != ConnectivityResult.wifi) {
|
||||||
|
// homeProvider.changeMessage(
|
||||||
|
// "notConnectedToInternet".tr(), 0);
|
||||||
|
// sub.nodeConnected = false;
|
||||||
|
// }
|
||||||
|
|
||||||
HomeProvider homeProvider =
|
HomeProvider homeProvider =
|
||||||
Provider.of<HomeProvider>(ctx, listen: false);
|
Provider.of<HomeProvider>(ctx, listen: false);
|
||||||
if (connectivityResult != ConnectivityResult.mobile &&
|
|
||||||
connectivityResult != ConnectivityResult.wifi) {
|
|
||||||
homeProvider.changeMessage(
|
|
||||||
"notConnectedToInternet".tr(), 0);
|
|
||||||
sub.nodeConnected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Connectivity()
|
Connectivity()
|
||||||
.onConnectivityChanged
|
.onConnectivityChanged
|
||||||
.listen((ConnectivityResult result) async {
|
.listen((ConnectivityResult result) async {
|
||||||
|
|
|
@ -116,11 +116,14 @@ class SettingsScreen extends StatelessWidget {
|
||||||
Icon(sub.nodeConnected && !sub.isLoadingEndpoint
|
Icon(sub.nodeConnected && !sub.isLoadingEndpoint
|
||||||
? Icons.check
|
? Icons.check
|
||||||
: Icons.close),
|
: Icons.close),
|
||||||
|
if (sub.nodeConnected && !sub.isLoadingEndpoint)
|
||||||
|
const Icon(Icons.add_card_sharp, size: 0.01),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 265,
|
width: 265,
|
||||||
child: Consumer<SettingsProvider>(builder: (context, set, _) {
|
child: Consumer<SettingsProvider>(builder: (context, set, _) {
|
||||||
return DropdownButtonHideUnderline(
|
return DropdownButtonHideUnderline(
|
||||||
|
key: keySelectDuniterNodeDropDown,
|
||||||
child: DropdownButton(
|
child: DropdownButton(
|
||||||
// alignment: AlignmentDirectional.topStart,
|
// alignment: AlignmentDirectional.topStart,
|
||||||
value: selectedDuniterEndpoint,
|
value: selectedDuniterEndpoint,
|
||||||
|
@ -128,6 +131,7 @@ class SettingsScreen extends StatelessWidget {
|
||||||
items: duniterBootstrapNodes
|
items: duniterBootstrapNodes
|
||||||
.map((NetworkParams endpointParams) {
|
.map((NetworkParams endpointParams) {
|
||||||
return DropdownMenuItem(
|
return DropdownMenuItem(
|
||||||
|
key: keySelectDuniterNode(endpointParams.endpoint!),
|
||||||
value: endpointParams.endpoint,
|
value: endpointParams.endpoint,
|
||||||
child: Text(endpointParams.endpoint!),
|
child: Text(endpointParams.endpoint!),
|
||||||
);
|
);
|
||||||
|
@ -146,6 +150,7 @@ class SettingsScreen extends StatelessWidget {
|
||||||
? CircularProgressIndicator(color: orangeC)
|
? CircularProgressIndicator(color: orangeC)
|
||||||
: Consumer<SettingsProvider>(builder: (context, set, _) {
|
: Consumer<SettingsProvider>(builder: (context, set, _) {
|
||||||
return IconButton(
|
return IconButton(
|
||||||
|
key: keyConnectToEndpoint,
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.send,
|
Icons.send,
|
||||||
color: selectedDuniterEndpoint !=
|
color: selectedDuniterEndpoint !=
|
||||||
|
@ -186,6 +191,7 @@ class SettingsScreen extends StatelessWidget {
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 50,
|
height: 50,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
|
key: keyCustomDuniterEndpoint,
|
||||||
controller: endpointController,
|
controller: endpointController,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue