Skip to content

Commit

Permalink
✅ Improves test equality checks
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Oct 9, 2024
1 parent 15afa42 commit 1ede7e6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
25 changes: 20 additions & 5 deletions packages/agent_dart_base/test/agent/certificate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,29 @@ void hashTest() {
),
'world'.plainToU8a(useDartEncode: true),
);
expect(lookupPath(['aa'.plainToU8a(useDartEncode: true)], tree), null);
expect(lookupPath(['ax'.plainToU8a(useDartEncode: true)], tree), null);
expect(lookupPath(['b'.plainToU8a(useDartEncode: true)], tree), null);
expect(lookupPath(['bb'.plainToU8a(useDartEncode: true)], tree), null);
expect(
lookupPath(['aa'.plainToU8a(useDartEncode: true)], tree),
equals(null),
);
expect(
lookupPath(['ax'.plainToU8a(useDartEncode: true)], tree),
equals(null),
);
expect(
lookupPath(['b'.plainToU8a(useDartEncode: true)], tree),
equals(null),
);
expect(
lookupPath(['bb'.plainToU8a(useDartEncode: true)], tree),
equals(null),
);
expect(
lookupPath(['d'.plainToU8a(useDartEncode: true)], tree),
'morning'.plainToU8a(useDartEncode: true),
);
expect(lookupPath(['e'.plainToU8a(useDartEncode: true)], tree), null);
expect(
lookupPath(['e'.plainToU8a(useDartEncode: true)], tree),
equals(null),
);
});
}
24 changes: 16 additions & 8 deletions packages/agent_dart_base/test/wallet/signer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,39 @@ void main() {
stopwatch
..reset()
..start();
final acc2 = await ICPSigner.fromPhrase(mne2, curveType: CurveType.all);
final acc2 = await ICPSigner.fromPhrase(
mne2,
curveType: CurveType.all,
);
stopwatch.stop();
final allCurvesDuration = stopwatch.elapsed;

stopwatch
..reset()
..start();
final acc21 = await ICPSigner.fromPhrase(mne2);
final acc21 = await ICPSigner.fromPhrase(
mne2,
curveType: CurveType.ed25519,
);
stopwatch.stop();
final acc21TimePeriod = stopwatch.elapsed;

stopwatch
..reset()
..start();
final acc22 =
await ICPSigner.fromPhrase(mne2, curveType: CurveType.secp256k1);
final acc22 = await ICPSigner.fromPhrase(
mne2,
curveType: CurveType.secp256k1,
);
stopwatch.stop();
final acc22TimePeriod = stopwatch.elapsed;

expect(acc21TimePeriod < allCurvesDuration, true);
expect(acc22TimePeriod < allCurvesDuration, true);
expect(acc2.account.identity != null, true);
expect(acc2.account.ecIdentity != null, true);
expect(acc21.account.ecIdentity, null);
expect(acc22.account.identity, null);
expect(acc21.account.ecIdentity, equals(null));
expect(acc22.account.identity, equals(null));

expect(
acc2.account.ecKeys?.accountId!.toHex(),
Expand All @@ -51,8 +59,8 @@ void main() {

await acc2.lock('123');
expect(acc2.isLocked, true);
expect(acc2.account.identity, null);
expect(acc2.account.ecKeys, null);
expect(acc2.account.identity, equals(null));
expect(acc2.account.ecKeys, equals(null));

await acc2.unlock('123');
expect(acc2.isLocked, false);
Expand Down

0 comments on commit 1ede7e6

Please sign in to comment.