Commit 92e3e96a authored by Matt Perry's avatar Matt Perry

Merge pull request #1949 from mpcomplete/async

Remove use of FakeAsync in signing_test.dart
parents ba3f60f8 6185fa14
...@@ -6,7 +6,6 @@ import 'package:bignum/bignum.dart'; ...@@ -6,7 +6,6 @@ import 'package:bignum/bignum.dart';
import 'package:cipher/cipher.dart' hide CipherParameters; import 'package:cipher/cipher.dart' hide CipherParameters;
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';
import 'package:flx/signing.dart'; import 'package:flx/signing.dart';
import 'package:quiver/testing/async.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
main() async { main() async {
...@@ -97,33 +96,19 @@ main() async { ...@@ -97,33 +96,19 @@ main() async {
expect(verifies, equals(false), reason: failReason); expect(verifies, equals(false), reason: failReason);
}); });
test('verifyContentHash works', () { test('verifyContentHash works', () async {
new FakeAsync().run((FakeAsync async) { Stream contentStream = new Stream.fromIterable(kTestBytesList);
bool verifies; bool verifies = await verifyContentHash(new BigInteger(kTestHash), contentStream);
Stream contentStream = new Stream.fromIterable(kTestBytesList); expect(verifies, equals(true));
verifyContentHash(new BigInteger(kTestHash), contentStream).then((bool rv) {
verifies = rv; // Ensure it fails with invalid hash or content.
}); contentStream = new Stream.fromIterable(kTestBytesList);
async.elapse(Duration.ZERO); verifies = await verifyContentHash(new BigInteger(0xdeadbeef), contentStream);
expect(verifies, equals(true)); expect(verifies, equals(false));
// Ensure it fails with invalid hash or content. Stream badContentStream =
verifies = null; new Stream.fromIterable([new Uint8List.fromList(<int>[42])]);
contentStream = new Stream.fromIterable(kTestBytesList); verifies = await verifyContentHash(new BigInteger(kTestHash), badContentStream);
verifyContentHash(new BigInteger(0xdeadbeef), contentStream).then((bool rv) { expect(verifies, equals(false));
verifies = rv;
});
async.elapse(Duration.ZERO);
expect(verifies, equals(false));
verifies = null;
Stream badContentStream =
new Stream.fromIterable([new Uint8List.fromList(<int>[42])]);
verifyContentHash(new BigInteger(kTestHash), badContentStream).then((bool rv) {
verifies = rv;
});
async.elapse(Duration.ZERO);
expect(verifies, equals(false));
});
}); });
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment