fix build

This commit is contained in:
Christien Rioux 2024-05-09 10:54:52 -05:00
parent 627066dd27
commit ab4f05a347
15 changed files with 215 additions and 220 deletions

View file

@ -1,4 +1,4 @@
@Timeout(Duration(seconds: 120))
@Timeout(Duration(seconds: 240))
library veilid_support_integration_test;
@ -26,13 +26,6 @@ void main() {
setUpAll(veilidFixture.setUp);
tearDownAll(veilidFixture.tearDown);
// group('Crypto Tests', () {
// test('best cryptosystem', testBestCryptoSystem);
// test('get cryptosystem', testGetCryptoSystem);
// test('get cryptosystem invalid', testGetCryptoSystemInvalid);
// test('hash and verify password', testHashAndVerifyPassword);
// });
group('Attached Tests', () {
setUpAll(veilidFixture.attach);
tearDownAll(veilidFixture.detach);
@ -45,21 +38,25 @@ void main() {
test('create pool', testDHTRecordPoolCreate);
// group('DHTRecordPool Tests', () {
// setUpAll(dhtRecordPoolFixture.setUp);
// tearDownAll(dhtRecordPoolFixture.tearDown);
group('DHTRecordPool Tests', () {
setUpAll(dhtRecordPoolFixture.setUp);
tearDownAll(dhtRecordPoolFixture.tearDown);
// test('create/delete record', testDHTRecordCreateDelete);
// test('record scopes', testDHTRecordScopes);
// test('create/delete deep record', testDHTRecordDeepCreateDelete);
// });
test('create/delete record', testDHTRecordCreateDelete);
test('record scopes', testDHTRecordScopes);
test('create/delete deep record', testDHTRecordDeepCreateDelete);
});
group('DHTShortArray Tests', () {
setUpAll(dhtRecordPoolFixture.setUp);
tearDownAll(dhtRecordPoolFixture.tearDown);
// test('create shortarray', testDHTShortArrayCreateDelete);
test('add shortarray', testDHTShortArrayAdd);
for (final stride in [256, 64, 32, 16, 8, 4, 2, 1]) {
test('create shortarray stride=$stride',
makeTestDHTShortArrayCreateDelete(stride: stride));
test('add shortarray stride=$stride',
makeTestDHTShortArrayAdd(stride: 256));
}
});
});
});

View file

@ -3,86 +3,99 @@ import 'dart:convert';
import 'package:flutter_test/flutter_test.dart';
import 'package:veilid_support/veilid_support.dart';
Future<void> testDHTShortArrayCreateDelete() async {
// Close before delete
{
final arr = await DHTShortArray.create(debugName: 'sa_create_delete 1');
expect(await arr.operate((r) async => r.length), isZero);
expect(arr.isOpen, isTrue);
await arr.close();
expect(arr.isOpen, isFalse);
await arr.delete();
// Operate should fail
await expectLater(() async => arr.operate((r) async => r.length),
throwsA(isA<StateError>()));
}
// Close after delete
{
final arr = await DHTShortArray.create(debugName: 'sa_create_delete 2');
await arr.delete();
// Operate should still succeed because things aren't closed
expect(await arr.operate((r) async => r.length), isZero);
await arr.close();
// Operate should fail
await expectLater(() async => arr.operate((r) async => r.length),
throwsA(isA<StateError>()));
}
// Close after delete multiple
// Okay to request delete multiple times before close
{
final arr = await DHTShortArray.create(debugName: 'sa_create_delete 3');
await arr.delete();
await arr.delete();
// Operate should still succeed because things aren't closed
expect(await arr.operate((r) async => r.length), isZero);
await arr.close();
await arr.close();
// Operate should fail
await expectLater(() async => arr.operate((r) async => r.length),
throwsA(isA<StateError>()));
}
}
Future<void> testDHTShortArrayAdd() async {
final arr = await DHTShortArray.create(debugName: 'sa_add 1');
final dataset =
Iterable<int>.generate(256).map((n) => utf8.encode('elem $n')).toList();
print('adding');
{
final (res, ok) = await arr.operateWrite((w) async {
for (var n = 0; n < dataset.length; n++) {
print('add $n');
final success = await w.tryAddItem(dataset[n]);
expect(success, isTrue);
Future<void> Function() makeTestDHTShortArrayCreateDelete(
{required int stride}) =>
() async {
// Close before delete
{
final arr = await DHTShortArray.create(
debugName: 'sa_create_delete 1 stride $stride', stride: stride);
expect(await arr.operate((r) async => r.length), isZero);
expect(arr.isOpen, isTrue);
await arr.close();
expect(arr.isOpen, isFalse);
await arr.delete();
// Operate should fail
await expectLater(() async => arr.operate((r) async => r.length),
throwsA(isA<StateError>()));
}
});
expect(res, isNull);
expect(ok, isTrue);
}
print('get all');
{
final dataset2 = await arr.operate((r) async => r.getAllItems());
expect(dataset2, equals(dataset));
}
// Close after delete
{
final arr = await DHTShortArray.create(
debugName: 'sa_create_delete 2 stride $stride', stride: stride);
await arr.delete();
// Operate should still succeed because things aren't closed
expect(await arr.operate((r) async => r.length), isZero);
await arr.close();
// Operate should fail
await expectLater(() async => arr.operate((r) async => r.length),
throwsA(isA<StateError>()));
}
print('clear');
{
final (res, ok) = await arr.operateWrite((w) async => w.tryClear());
expect(res, isTrue);
expect(ok, isTrue);
}
// Close after delete multiple
// Okay to request delete multiple times before close
{
final arr = await DHTShortArray.create(
debugName: 'sa_create_delete 3 stride $stride', stride: stride);
await arr.delete();
await arr.delete();
// Operate should still succeed because things aren't closed
expect(await arr.operate((r) async => r.length), isZero);
await arr.close();
await arr.close();
// Operate should fail
await expectLater(() async => arr.operate((r) async => r.length),
throwsA(isA<StateError>()));
}
};
print('get all');
{
final dataset3 = await arr.operate((r) async => r.getAllItems());
expect(dataset3, isEmpty);
}
Future<void> Function() makeTestDHTShortArrayAdd({required int stride}) =>
() async {
final startTime = DateTime.now();
await arr.delete();
await arr.close();
}
final arr = await DHTShortArray.create(
debugName: 'sa_add 1 stride $stride', stride: stride);
final dataset = Iterable<int>.generate(256)
.map((n) => utf8.encode('elem $n'))
.toList();
print('adding\n');
{
final (res, ok) = await arr.operateWrite((w) async {
for (var n = 0; n < dataset.length; n++) {
print('$n ');
final success = await w.tryAddItem(dataset[n]);
expect(success, isTrue);
}
});
expect(res, isNull);
expect(ok, isTrue);
}
//print('get all\n');
{
final dataset2 = await arr.operate((r) async => r.getAllItems());
expect(dataset2, equals(dataset));
}
//print('clear\n');
{
final (res, ok) = await arr.operateWrite((w) async => w.tryClear());
expect(res, isTrue);
expect(ok, isTrue);
}
//print('get all\n');
{
final dataset3 = await arr.operate((r) async => r.getAllItems());
expect(dataset3, isEmpty);
}
await arr.delete();
await arr.close();
final endTime = DateTime.now();
print('Duration: ${endTime.difference(startTime)}');
};