Skip to content

Commit

Permalink
feat: Update key generator test and update flutter and dart version f…
Browse files Browse the repository at this point in the history
…or test
  • Loading branch information
bibash28 committed Jun 4, 2024
1 parent 8eb94d2 commit ca933bb
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 59 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/credential_manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: credential_manifest

on: [ pull_request, push ]
on: [pull_request, push]

jobs:
build:
uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main
with:
flutter_channel: stable
flutter_version: 3.19.6
flutter_version: 3.22.1
min_coverage: 30
working_directory: packages/credential_manifest
dart_sdk: 3.3.4
dart_sdk: 3.4.1
6 changes: 3 additions & 3 deletions .github/workflows/cryptocurrency_keys.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: cryptocurrency_keys

on: [ pull_request, push ]
on: [pull_request, push]

jobs:
build:
uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main
with:
flutter_channel: stable
flutter_version: 3.19.6
flutter_version: 3.22.1
min_coverage: 30
working_directory: packages/cryptocurrency_keys
dart_sdk: 3.3.4
dart_sdk: 3.4.1
4 changes: 2 additions & 2 deletions .github/workflows/did_kit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main
with:
flutter_channel: stable
flutter_version: 3.19.6
flutter_version: 3.22.1
min_coverage: 30
working_directory: packages/did_kit
dart_sdk: 3.3.4
dart_sdk: 3.4.1
build_runner: false
6 changes: 3 additions & 3 deletions .github/workflows/jwt_decode.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: jwt_decode

on: [ pull_request, push ]
on: [pull_request, push]

jobs:
build:
uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main
with:
flutter_channel: stable
flutter_version: 3.19.6
flutter_version: 3.22.1
min_coverage: 30
working_directory: packages/jwt_decode
dart_sdk: 3.3.4
dart_sdk: 3.4.1
build_runner: false
14 changes: 14 additions & 0 deletions .github/workflows/key_generator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: key_generator

on: [pull_request, push]

jobs:
build:
uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main
with:
flutter_channel: stable
flutter_version: 3.22.1
min_coverage: 30
working_directory: packages/key_generator
dart_sdk: 3.4.1
build_runner: false
4 changes: 2 additions & 2 deletions .github/workflows/polygonid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main
with:
flutter_channel: stable
flutter_version: 3.19.6
flutter_version: 3.22.1
min_coverage: 30
working_directory: packages/polygonid
dart_sdk: 3.3.4
dart_sdk: 3.4.1
build_runner: false
4 changes: 2 additions & 2 deletions .github/workflows/secure_storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
uses: TalaoDAO/AltMe/.github/workflows/flutter_package.yaml@main
with:
flutter_channel: stable
flutter_version: 3.19.6
flutter_version: 3.22.1
min_coverage: 30
working_directory: packages/secure_storage
dart_sdk: 3.3.4
dart_sdk: 3.4.1
build_runner: false
1 change: 0 additions & 1 deletion packages/key_generator/lib/src/key_generator.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:convert';
import 'dart:typed_data';

import 'package:bip32/bip32.dart' as bip32;
import 'package:bip39/bip39.dart' as bip393;
import 'package:dart_bip32_bip44/dart_bip32_bip44.dart';
Expand Down
4 changes: 1 addition & 3 deletions packages/key_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ dependencies:
dart_web3: ^0.0.3
ed25519_hd_key: ^2.2.0
hex: ^0.2.0
pinenacl: ^0.3.3
secp256k1: ^0.3.0
tezart:
git:
url: https://github.com/autonomy-system/tezart.git
ref: e53e4ab9eaabea53cbf70e814efd2245b4659f48

dependency_overrides:
pinenacl: ^0.5.1 # tezart from git depends on pinenacl ^0.3.3

dev_dependencies:
flutter_test:
sdk: flutter
Expand Down
93 changes: 53 additions & 40 deletions packages/key_generator/test/src/key_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,50 +138,63 @@ void main() {
});
});

group('ethereum', () {
const accountType = AccountType.ethereum;
test('throw Exception for secretKey from ethereum', () async {
final key = await keyGenerator.jwkFromMnemonic(
mnemonic: mnemonics,
accountType: accountType,
derivePathIndex: derivePathIndex,
);
expect(key, evmJwkKey);
});
group('EVM', () {
const accountTypes = [
AccountType.ethereum,
AccountType.fantom,
AccountType.polygon,
AccountType.binance,
];

for (final accountType in accountTypes) {
test('throw Exception for secretKey from ethereum', () async {
final key = await keyGenerator.jwkFromMnemonic(
mnemonic: mnemonics,
accountType: accountType,
derivePathIndex: derivePathIndex,
);
expect(key, evmJwkKey);
});

test('key from secretKey for ethereum', () async {
final key = await keyGenerator.jwkFromSecretKey(
secretKey: ethereumSecretKey,
accountType: accountType,
);
expect(key, evmJwkKey);
});
test('key from secretKey for ethereum', () async {
final key = await keyGenerator.jwkFromSecretKey(
secretKey: ethereumSecretKey,
accountType: accountType,
);
expect(key, evmJwkKey);
});

test('0x wallet address from mnemonics for ethereum', () async {
final walletAddress = await keyGenerator.walletAddressFromMnemonic(
mnemonic: mnemonics,
accountType: accountType,
derivePathIndex: derivePathIndex,
);
expect(walletAddress, ethereumWalletAddress);
});
test('0x wallet address from mnemonics for ethereum', () async {
final walletAddress = await keyGenerator.walletAddressFromMnemonic(
mnemonic: mnemonics,
accountType: accountType,
derivePathIndex: derivePathIndex,
);
expect(walletAddress, ethereumWalletAddress);
});

test('secretKey from mnemonics for ethereum ', () async {
final secretKey = await keyGenerator.secretKeyFromMnemonic(
mnemonic: mnemonics,
accountType: accountType,
derivePathIndex: derivePathIndex,
);
expect(secretKey, ethereumSecretKey);
});
test('secretKey from mnemonics for ethereum ', () async {
final secretKey = await keyGenerator.secretKeyFromMnemonic(
mnemonic: mnemonics,
accountType: accountType,
derivePathIndex: derivePathIndex,
);
expect(secretKey, ethereumSecretKey);
});

test('0x wallet address from secret key for ethereum', () async {
final walletAddress = await keyGenerator.walletAddressFromSecretKey(
secretKey: ethereumSecretKey,
accountType: accountType,
);
expect(walletAddress, ethereumWalletAddress);
});
test('0x wallet address from secret key for ethereum', () async {
final walletAddress = await keyGenerator.walletAddressFromSecretKey(
secretKey: ethereumSecretKey,
accountType: accountType,
);
expect(walletAddress, ethereumWalletAddress);
});
}
});

test('getKeystore returns correct value', () {
final data = keyGenerator.getKeystore(secretKey: tezosSecretKey);
expect(data.address, tezosWalletAddress);
});
});
}

0 comments on commit ca933bb

Please sign in to comment.