fix test revocation

This commit is contained in:
poka 2022-09-09 01:12:17 +02:00
parent e2ed9c5c98
commit f7e3066352
25 changed files with 131 additions and 84 deletions

View File

@ -2,7 +2,7 @@
"first_ud": 10000,
"first_ud_reeval": 50,
"genesis_parameters": {
"genesis_certs_expire_on": 500,
"genesis_certs_expire_on": 10,
"genesis_certs_min_received": 3,
"genesis_memberships_expire_on": 1051200,
"genesis_smith_certs_expire_on": 2102400,
@ -54,7 +54,7 @@
"smith_cert_validity_period": 1000,
"smith_membership_period": 1000,
"smith_pending_membership_period": 500,
"smiths_wot_first_cert_issuable_on": 20,
"smiths_wot_first_cert_issuable_on": 4,
"smiths_wot_min_cert_for_membership": 3,
"wot_first_cert_issuable_on": 0,
"wot_min_cert_for_create_idty_right": 3,

View File

@ -1,31 +0,0 @@
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';
import 'general_actions.dart';
import 'tests_utility.dart';
void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
await dotenv.load();
testWidgets('Identity revocation', (testerLoc) async {
tester = testerLoc;
// Connect local node and import test chest in background
await bkFastStart();
// Open chest
await firstOpenChest();
// Revoke test3
await spawnBlock();
await tapKey(keyOpenWallet(test3.address));
await tapKey(keyManageMembership);
await tapKey(keyRevokeIdty);
await tapKey(keyConfirm);
spawnBlock(duration: 2000);
await waitFor('validé !', timeout: const Duration(seconds: 4));
await tapKey(keyCloseTransactionScreen, duration: 0);
await waitFor('Membre validé !', reverse: true);
}, timeout: testTimeout());
}

View File

@ -17,7 +17,7 @@ docker compose up -d
cd ../..
# Start integration test
flutter test integration_test/$testName.dart && echo '0' > /tmp/geckoTestResult || echo '1' > /tmp/geckoTestResult
flutter test integration_test/scenarios/$testName.dart && echo '0' > /tmp/geckoTestResult || echo '1' > /tmp/geckoTestResult
# Reset .env
echo "ip_address=127.0.0.1" > .env

View File

@ -3,8 +3,8 @@ 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';
import '../utility/general_actions.dart';
import '../utility/tests_utility.dart';
void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
@ -17,6 +17,7 @@ void main() async {
// Open chest
await firstOpenChest();
spawnBlock(until: 15);
await goBack();
// Go wallet 5 view
@ -35,21 +36,27 @@ void main() async {
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 bkCertify(
fromAddress: test1.address,
destAddress: test5.address,
spawnBloc: false);
await bkConfirmIdentity(fromAddress: test5.address, name: test5.name);
await bkCertify(fromAddress: test2.address, destAddress: test5.address);
await waitFor('2', exactMatch: true);
await waitFor('1', exactMatch: true);
await bkCertify(
fromAddress: test2.address,
destAddress: test5.address,
spawnBloc: false);
// 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('61.99 $currencyName');
await spawnBlock(until: 10);
await waitFor('161.99 $currencyName');
await spawnBlock(until: 20);
await waitFor('261.99 $currencyName');
// await bkPay(
// fromAddress: test2.address, destAddress: test5.address, amount: 40);
await waitFor('21.99 $currencyName');
await spawnBlock(until: 30);
await waitFor('121.99 $currencyName');
await spawnBlock(until: 40);
await waitFor('221.99 $currencyName');
}, timeout: testTimeout());
}

View File

@ -2,8 +2,8 @@ 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';
import 'general_actions.dart';
import 'tests_utility.dart';
import '../utility/general_actions.dart';
import '../utility/tests_utility.dart';
void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
@ -34,6 +34,7 @@ void main() async {
}
Future payTest2() async {
spawnBlock(until: 13);
await waitFor('Rechercher');
await tapKey(keyOpenSearch);
final addressToSearch = await clipPaste();
@ -127,13 +128,13 @@ Future certifyTest5() async {
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('109.13');
await spawnBlock(until: 30);
await waitFor('209.13');
// Check UD reval
await spawnBlock(until: 50);
await waitFor('509.36');
await spawnBlock(until: 60);
await waitFor('509.57');
humanRead(5);
}

View File

@ -0,0 +1,47 @@
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';
import '../utility/general_actions.dart';
import '../utility/tests_utility.dart';
void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
await dotenv.load();
testWidgets('Identity revocation', (testerLoc) async {
tester = testerLoc;
// Connect local node and import test chest in background
await bkFastStart();
// Open chest
await firstOpenChest();
await spawnBlock(until: 13);
await sleep();
// Create test5 identity
await bkPay(
fromAddress: test1.address, destAddress: test5.address, amount: 30);
sub.reload();
await bkCertify(fromAddress: test1.address, destAddress: test5.address);
sub.reload();
await sleep();
// Certify test5 to become member
await tapKey(keyOpenWallet(test5.address));
await bkConfirmIdentity(fromAddress: test5.address, name: test5.name);
await bkCertify(fromAddress: test2.address, destAddress: test5.address);
await bkCertify(fromAddress: test3.address, destAddress: test5.address);
await waitFor('Membre validé !', exactMatch: true);
// Revoke test5
await tapKey(keyManageMembership, duration: 1000);
await tapKey(keyRevokeIdty);
await tapKey(keyConfirm);
spawnBlock(duration: 2000);
await waitFor('validé !', timeout: const Duration(seconds: 4));
await tapKey(keyCloseTransactionScreen, duration: 0);
await waitFor('Aucune identité', exactMatch: true);
await sleep();
}, timeout: testTimeout());
}

View File

@ -4,8 +4,8 @@ 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';
import '../utility/general_actions.dart';
import '../utility/tests_utility.dart';
void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

View File

@ -1,8 +1,8 @@
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'general_actions.dart';
import 'tests_utility.dart';
import '../utility/general_actions.dart';
import '../utility/tests_utility.dart';
void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

View File

@ -3,8 +3,8 @@ 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';
import '../utility/general_actions.dart';
import '../utility/tests_utility.dart';
void main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

View File

@ -190,15 +190,21 @@ Future bkPay(
destAddress: destAddress,
amount: amount,
password: 'AAAAA');
await sleep(500);
await spawnBlock();
await sleep(500);
}
// Certify in background
Future bkCertify(
{required String fromAddress, required String destAddress}) async {
{required String fromAddress,
required String destAddress,
bool spawnBloc = true}) async {
sub.certify(fromAddress, destAddress, 'AAAAA');
await spawnBlock();
if (spawnBloc) {
await sleep(500);
await spawnBlock();
}
await sleep(500);
}
@ -206,6 +212,7 @@ Future bkCertify(
Future bkConfirmIdentity(
{required String fromAddress, required String name}) async {
sub.confirmIdentity(fromAddress, name, 'AAAAA');
await sleep(500);
await spawnBlock();
await sleep(500);
}
@ -237,7 +244,7 @@ Future bkRestoreChest([String mnemonic = testMnemonic]) async {
name: 'test${number + 1}',
derivation: (number + 1) * 2);
}
myWalletProvider.rebuildWidget();
myWalletProvider.reload();
}
Future<WalletData> _addImportAccount(
@ -273,7 +280,7 @@ Future bkDeleteAllWallets() async {
await configBox.delete('defaultWallet');
await sub.deleteAllAccounts();
myWalletProvider.pinCode = '';
myWalletProvider.rebuildWidget();
myWalletProvider.reload();
}
}

View File

@ -10,7 +10,7 @@ import 'package:gecko/providers/substrate_sdk.dart';
import 'package:provider/provider.dart';
class ChestProvider with ChangeNotifier {
void rebuildWidget() {
void reload() {
notifyListeners();
}

View File

@ -219,7 +219,7 @@ class HomeProvider with ChangeNotifier {
);
}
void rebuildWidget() {
void reload() {
notifyListeners();
}
}

View File

@ -219,7 +219,7 @@ class MyWalletsProvider with ChangeNotifier {
if (actualLock == lockPin) pinCode = '';
}
void rebuildWidget() {
void reload() {
notifyListeners();
}
}

View File

@ -8,7 +8,7 @@ class SearchProvider with ChangeNotifier {
final cacheDuring = 20 * 60 * 1000; //First number is minutes
int cacheTime = 0;
void rebuildWidget() {
void reload() {
notifyListeners();
}

View File

@ -8,6 +8,8 @@ import 'package:gecko/models/chest_data.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/providers/home.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:gecko/providers/wallet_options.dart';
import 'package:gecko/providers/wallets_profiles.dart';
import 'package:polkawallet_sdk/api/apiKeyring.dart';
import 'package:polkawallet_sdk/api/types/networkParams.dart';
import 'package:polkawallet_sdk/api/types/txInfoData.dart';
@ -46,6 +48,10 @@ class SubstrateSdk with ChangeNotifier {
Future<String> _executeCall(TxInfoData txInfo, txOptions, String password,
[String? rawParams]) async {
final walletOptions =
Provider.of<WalletOptionsProvider>(homeContext, listen: false);
final walletProfiles =
Provider.of<WalletsProfilesProvider>(homeContext, listen: false);
try {
final hash = await sdk.api.tx.signAndSend(txInfo, txOptions, password,
rawParam: rawParams, onStatusChange: (p0) {
@ -62,8 +68,11 @@ class SubstrateSdk with ChangeNotifier {
return 'timeout';
} else {
// Success !
transactionStatus = hash.toString();
notifyListeners();
walletOptions.reload();
walletProfiles.reload();
return hash.toString();
}
} catch (e) {
@ -272,6 +281,9 @@ class SubstrateSdk with ChangeNotifier {
}
Future<String> idtyStatus(String address) async {
// WalletOptionsProvider walletOptions =
// Provider.of<WalletOptionsProvider>(homeContext, listen: false);
var idtyIndex = await _getIdentityIndexOf(address);
if (idtyIndex == 0) {
@ -283,6 +295,10 @@ class SubstrateSdk with ChangeNotifier {
if (idtyStatus != null) {
final String status = idtyStatus['status'];
// if (address == walletOptions.address.text && status == 'Validated') {
// walletOptions.reloadBuild();
// }
return (status);
} else {
return 'expired';

View File

@ -427,7 +427,7 @@ class WalletOptionsProvider with ChangeNotifier {
return canValidateNameBool;
}
void reloadBuild() {
void reload() {
notifyListeners();
}

View File

@ -119,7 +119,7 @@ class HomeScreen extends StatelessWidget {
await chestBox.clear();
await configBox.delete('defaultWallet');
await sub.deleteAllAccounts();
myWalletProvider.rebuildWidget();
myWalletProvider.reload();
}
// var connectivityResult =

View File

@ -119,7 +119,7 @@ class _ChooseChestState extends State<ChooseChest> {
myWalletProvider.pinCode = '';
WalletData? defaultWallet =
myWalletProvider.getDefaultWallet();
myWalletProvider.rebuildWidget();
myWalletProvider.reload();
await Navigator.push(
context,

View File

@ -125,7 +125,7 @@ class ChooseWalletScreen extends StatelessWidget {
key: keySelectThisWallet(repository.address!),
onTap: () {
selectedWallet = repository;
myWalletProvider.rebuildWidget();
myWalletProvider.reload();
},
child: ClipOvalShadow(
shadow: const Shadow(
@ -202,7 +202,7 @@ class ChooseWalletScreen extends StatelessWidget {
),
onTap: () async {
selectedWallet = repository;
myWalletProvider.rebuildWidget();
myWalletProvider.reload();
},
)
]),

View File

@ -244,7 +244,7 @@ class UnlockingWallet extends StatelessWidget {
.shake); // Triggering error shake animation
pinColor = Colors.red[600];
myWalletProvider.pinCode = myWalletProvider.mnemonic = '';
walletOptions.reloadBuild();
walletOptions.reload();
pinFocus.requestFocus();
} else {
pinColor = Colors.green[400];

View File

@ -54,7 +54,7 @@ class WalletOptions extends StatelessWidget {
onWillPop: () {
walletOptions.isEditing = false;
walletOptions.isBalanceBlur = false;
myWalletProvider.rebuildWidget();
myWalletProvider.reload();
Navigator.pop(context);
return Future<bool>.value(true);
},
@ -69,7 +69,7 @@ class WalletOptions extends StatelessWidget {
onPressed: () {
walletOptions.isEditing = false;
walletOptions.isBalanceBlur = false;
myWalletProvider.rebuildWidget();
myWalletProvider.reload();
Navigator.pop(context);
}),
title: SizedBox(
@ -245,7 +245,7 @@ class WalletOptions extends StatelessWidget {
wallet.imageCustomPath = newPath;
walletBox.put(wallet.key, wallet);
}
walletProvider.reloadBuild();
walletProvider.reload();
},
child: wallet.imageCustomPath == null || wallet.imageCustomPath == ''
? Image.asset(
@ -273,7 +273,7 @@ class WalletOptions extends StatelessWidget {
child: InkWell(
onTap: () async {
wallet.imageCustomPath = await (walletProvider.changeAvatar());
walletProvider.reloadBuild();
walletProvider.reload();
},
child: Image.asset(
'assets/walletOptions/camera.png',
@ -521,8 +521,8 @@ class WalletOptions extends StatelessWidget {
// defaultWallet = wallet;
await sub.setCurrentWallet(wallet);
myWalletProvider.readAllWallets(currentChest);
myWalletProvider.rebuildWidget();
walletOptions.reloadBuild();
myWalletProvider.reload();
walletOptions.reload();
}
Widget deleteWallet(BuildContext context,
@ -556,7 +556,7 @@ class WalletOptions extends StatelessWidget {
WidgetsBinding.instance.addPostFrameCallback((_) {
myWalletProvider.listWallets =
myWalletProvider.readAllWallets(currentChest);
myWalletProvider.rebuildWidget();
myWalletProvider.reload();
});
}
: null,

View File

@ -224,7 +224,7 @@ class OnboardingStepTen extends StatelessWidget {
await walletBox.add(myWallet);
}
myWalletProvider.readAllWallets(currentChest);
myWalletProvider.rebuildWidget();
myWalletProvider.reload();
generateWalletProvider.generatedMnemonic = '';
myWalletProvider.resetPinCode();
@ -239,7 +239,7 @@ class OnboardingStepTen extends StatelessWidget {
.shake); // Triggering error shake animation
hasError = true;
pinColor = Colors.red[600];
walletOptions.reloadBuild();
walletOptions.reload();
}
},
onChanged: (value) {

View File

@ -57,7 +57,7 @@ class SearchScreen extends StatelessWidget {
autofocus: true,
maxLines: 1,
textAlign: TextAlign.left,
onChanged: (v) => searchProvider.rebuildWidget(),
onChanged: (v) => searchProvider.reload(),
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,

View File

@ -594,7 +594,7 @@ class WalletViewScreen extends StatelessWidget {
FilteringTextInputFormatter.allow(
RegExp(r'(^\d+\.?\d{0,2})')),
],
// onChanged: (v) => _searchProvider.rebuildWidget(),
// onChanged: (v) => _searchProvider.reload(),
decoration: InputDecoration(
hintText: '0.00',
suffix: Text(currencyName),