Backup&Restore
This commit is contained in:
1 parent
394df3109b
commit
aae2bf6d60
29 files changed
+2769
-120
No files matched your search
@@ -38,6 +38,26 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('private-key backup frames', () {
|
||||
test('uses the firmware command codes and 64-byte identity payload', () {
|
||||
final keyData = Uint8List.fromList(List.generate(64, (index) => index));
|
||||
expect(buildExportPrivateKeyFrame(), [cmdExportPrivateKey]);
|
||||
final frame = buildImportPrivateKeyFrame(keyData);
|
||||
expect(frame.length, 65);
|
||||
expect(frame.first, cmdImportPrivateKey);
|
||||
expect(frame.sublist(1), keyData);
|
||||
expect(respCodePrivateKey, 14);
|
||||
expect(respCodeDisabled, 15);
|
||||
});
|
||||
|
||||
test('rejects identity data with the wrong length', () {
|
||||
expect(
|
||||
() => buildImportPrivateKeyFrame(Uint8List(63)),
|
||||
throwsArgumentError,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('BufferWriter.writeCString', () {
|
||||
test('NUL-terminates and truncates on a character boundary', () {
|
||||
final writer = BufferWriter()..writeCString('#${'ё' * 20}', 32);
|
||||
|
||||
@@ -51,6 +51,21 @@ void main() {
|
||||
expect(queue.length, 0);
|
||||
});
|
||||
|
||||
test('firmware-disabled private-key transfer fails its waiter', () async {
|
||||
final queue = newQueue();
|
||||
final pending = queue.track(
|
||||
buildExportPrivateKeyFrame(),
|
||||
waitForReply: true,
|
||||
);
|
||||
|
||||
expect(queue.completeReply(frame([respCodeDisabled])), isTrue);
|
||||
await expectLater(
|
||||
pending!.completer!.future,
|
||||
throwsA(isA<UnsupportedError>()),
|
||||
);
|
||||
expect(queue.length, 0);
|
||||
});
|
||||
|
||||
test('untracked commands are not enrolled', () {
|
||||
final queue = newQueue();
|
||||
expect(queue.track(buildSyncNextMessageFrame()), isNull);
|
||||
|
||||
Reference in new issue
Block a user