Sender-side offline delivery hardening.
- OfferOutbox: a keystore-backed (no plaintext) queue of lot ids to publish
later. Stores ids, not offers, so on flush each offer is rebuilt from the
lot's CURRENT state — an offline edit is respected, a deleted lot drops out.
- flushOutbox(): on reconnect, republishes queued lots and clears them (no-op
offline; drops ids whose lot is gone).
- Market screen: sharing offline parks the lots ('we'll share these when you're
connected'); opening the market online auto-flushes the queue first.
- Wired via DI + TaneApp(outbox); i18n en/es/pt.
Tests: 4 outbox + 3 flush + market UI, 20 green. Analyzer clean for new code.
31 lines
864 B
Dart
31 lines
864 B
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:tane/services/offer_outbox.dart';
|
|
|
|
import '../support/test_support.dart';
|
|
|
|
void main() {
|
|
late OfferOutbox outbox;
|
|
setUp(() => outbox = OfferOutbox(InMemorySecretStore()));
|
|
|
|
test('starts empty', () async {
|
|
expect(await outbox.pending(), isEmpty);
|
|
});
|
|
|
|
test('enqueue adds ids; it is a set (no duplicates)', () async {
|
|
await outbox.enqueue(['a', 'b']);
|
|
await outbox.enqueue(['b', 'c']);
|
|
expect(await outbox.pending(), {'a', 'b', 'c'});
|
|
});
|
|
|
|
test('remove drops the given ids', () async {
|
|
await outbox.enqueue(['a', 'b', 'c']);
|
|
await outbox.remove(['b']);
|
|
expect(await outbox.pending(), {'a', 'c'});
|
|
});
|
|
|
|
test('clear empties it', () async {
|
|
await outbox.enqueue(['a', 'b']);
|
|
await outbox.clear();
|
|
expect(await outbox.pending(), isEmpty);
|
|
});
|
|
}
|