refactor(trust): ego-centric trust replaces the global Duniter membership
The global membership rule (curated bootstrap referents + sigQty/stepMax parameters) solved sybil-proof identity for a UBI — a problem this app doesn't have — and its screen leaked graph jargon (npub roots, parameter steppers). Trust is now computed from the user's own position only: you vouch / vouched by people you know (distance <=2) / vouched by N. - TrustCubit: drop networkMember tier, referents and params; keep the circle rule and the 365-day vouch expiry (renewable, self-pruning). - Delete TrustReferents, WotSettings, TrustNetworkScreen and the bundled referents asset; unwire injector/bootstrap/app/chat. - New 'Your people' screen (/your-people, from the profile): who you vouch for (revocable) and who vouches for you, names via ProfileCache. - i18n: wot.* removed, yourPeople.* added (en/es/pt/ast); trust.member removed. Kind 30777 events on relays stay fully compatible — only the interpretation changes.
This commit is contained in:
parent
4af90876f4
commit
dc7b2eee27
25 changed files with 595 additions and 863 deletions
174
apps/app_seeds/test/ui/your_people_screen_test.dart
Normal file
174
apps/app_seeds/test/ui/your_people_screen_test.dart
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
import 'package:commons_core/commons_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tane/i18n/strings.g.dart';
|
||||
import 'package:tane/services/profile_cache.dart';
|
||||
import 'package:tane/services/social_connection.dart';
|
||||
import 'package:tane/services/social_service.dart';
|
||||
import 'package:tane/services/social_settings.dart';
|
||||
import 'package:tane/ui/your_people_screen.dart';
|
||||
|
||||
import '../support/test_support.dart';
|
||||
|
||||
/// In-memory [TrustTransport] with a mutable certification graph.
|
||||
class FakeTrustTransport implements TrustTransport {
|
||||
FakeTrustTransport(this.selfId);
|
||||
final String selfId;
|
||||
final List<Certification> certs = [];
|
||||
|
||||
void addCert(String issuer, String subject) => certs.add(Certification(
|
||||
issuer: issuer,
|
||||
subject: subject,
|
||||
issuedAt: DateTime(2026),
|
||||
));
|
||||
|
||||
@override
|
||||
Future<List<Certification>> allCertifications() async => List.of(certs);
|
||||
|
||||
@override
|
||||
Future<Set<String>> certifiersOf(String subjectPubkey) async => {
|
||||
for (final c in certs)
|
||||
if (c.subject == subjectPubkey) c.issuer,
|
||||
};
|
||||
|
||||
@override
|
||||
Future<void> certify({
|
||||
required String subjectPubkey,
|
||||
Duration validity = const Duration(days: 365),
|
||||
String note = '',
|
||||
}) async =>
|
||||
addCert(selfId, subjectPubkey);
|
||||
|
||||
@override
|
||||
Future<void> revoke({required String subjectPubkey}) async => certs
|
||||
.removeWhere((c) => c.issuer == selfId && c.subject == subjectPubkey);
|
||||
|
||||
@override
|
||||
Future<void> close() async {}
|
||||
}
|
||||
|
||||
/// A [SocialSession] stand-in that only carries the trust transport — the
|
||||
/// screen under test never touches the other transports.
|
||||
class FakeSession implements SocialSession {
|
||||
FakeSession(this.trust);
|
||||
|
||||
@override
|
||||
final TrustTransport trust;
|
||||
|
||||
@override
|
||||
OfferTransport get offers => throw UnimplementedError();
|
||||
@override
|
||||
MessageTransport get messages => throw UnimplementedError();
|
||||
@override
|
||||
ProfileTransport get profile => throw UnimplementedError();
|
||||
@override
|
||||
SyncTransport get sync => throw UnimplementedError();
|
||||
@override
|
||||
Future<void> close() async {}
|
||||
}
|
||||
|
||||
void main() {
|
||||
const seedHex =
|
||||
'000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f';
|
||||
final peerA = 'aa' * 32;
|
||||
final peerB = 'bb' * 32;
|
||||
|
||||
late SocialService social;
|
||||
|
||||
setUp(() async {
|
||||
social = await SocialService.fromRootSeedHex(seedHex);
|
||||
LocaleSettings.setLocaleSync(AppLocale.en);
|
||||
});
|
||||
|
||||
Widget app(SocialConnection connection, {ProfileCache? cache}) =>
|
||||
TranslationProvider(
|
||||
child: MaterialApp(
|
||||
locale: AppLocale.en.flutterLocale,
|
||||
supportedLocales: AppLocaleUtils.supportedLocales,
|
||||
localizationsDelegates: const [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
home: YourPeopleScreen(
|
||||
social: social,
|
||||
connection: connection,
|
||||
profileCache: cache,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
SocialConnection online(TrustTransport trust) => SocialConnection(
|
||||
social: social,
|
||||
settings: SocialSettings(InMemorySecretStore()),
|
||||
open: (_) async => FakeSession(trust) as SocialSession,
|
||||
);
|
||||
|
||||
testWidgets('offline shows the friendly note', (tester) async {
|
||||
final settings = SocialSettings(InMemorySecretStore());
|
||||
await settings.setRelayUrls(const []); // offline: don't hit the network
|
||||
final connection = SocialConnection(social: social, settings: settings);
|
||||
|
||||
await tester.pumpWidget(app(connection));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
find.text("You're offline — try again when you're connected"),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('lists who you vouch for and who vouches for you, with names',
|
||||
(tester) async {
|
||||
final trust = FakeTrustTransport(social.publicKeyHex)
|
||||
..addCert(social.publicKeyHex, peerA) // you vouch for A
|
||||
..addCert(peerB, social.publicKeyHex) // B vouches for you
|
||||
..addCert(peerA, peerB); // unrelated edge, must not show
|
||||
final cache = ProfileCache(InMemorySecretStore());
|
||||
await cache.setName(peerA, 'Alice');
|
||||
|
||||
await tester.pumpWidget(app(online(trust), cache: cache));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('You vouch for'), findsOneWidget);
|
||||
expect(find.text('They vouch for you'), findsOneWidget);
|
||||
expect(find.text('Alice'), findsOneWidget); // cached name wins
|
||||
expect(find.text(shortPubkey(peerB)), findsOneWidget); // fallback
|
||||
expect(find.byKey(Key('yourPeople.given.$peerA')), findsOneWidget);
|
||||
expect(find.byKey(Key('yourPeople.received.$peerB')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('empty states show gentle notes', (tester) async {
|
||||
await tester
|
||||
.pumpWidget(app(online(FakeTrustTransport(social.publicKeyHex))));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
find.textContaining("You don't vouch for anyone yet"),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('No one vouches for you yet'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('revoking removes the vouch after confirming', (tester) async {
|
||||
final trust = FakeTrustTransport(social.publicKeyHex)
|
||||
..addCert(social.publicKeyHex, peerA);
|
||||
|
||||
await tester.pumpWidget(app(online(trust)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.text('Stop vouching'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Stop vouching for this person?'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Stop vouching').last); // dialog action
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(trust.certs, isEmpty);
|
||||
expect(
|
||||
find.textContaining("You don't vouch for anyone yet"),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue