Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LGro committed Sep 21, 2024
1 parent e2de3ff commit 67631a4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
5 changes: 1 addition & 4 deletions test/mocked_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ import 'dart:convert';
import 'package:coagulate/data/models/coag_contact.dart';
import 'package:coagulate/data/models/contact_update.dart';
import 'package:coagulate/data/models/profile_sharing_settings.dart';
import 'package:coagulate/data/providers/distributed_storage/base.dart';
import 'package:coagulate/data/providers/distributed_storage/dht.dart';
import 'package:coagulate/data/providers/persistent_storage/base.dart';
import 'package:coagulate/data/providers/system_contacts/base.dart';
import 'package:coagulate/data/providers/system_contacts/system_contacts.dart';
import 'package:coagulate/data/repositories/contacts.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:uuid/v4.dart';

class DummyPersistentStorage extends PersistentStorage {
DummyPersistentStorage(this.contacts, {this.profileContactId});
Expand Down Expand Up @@ -127,7 +124,7 @@ class DummyDistributedStorage extends VeilidDhtStorage {
@override
Future<(String, String)> createDHTRecord() async {
log.add('createDHTRecord');
return ('key', 'writer');
return ('VLD0:DUMMYwPaM1X1-d45IYDGLAAKQRpW2bf8cNKCIPNuW0M', 'writer');
}

@override
Expand Down
35 changes: 19 additions & 16 deletions test/ui/receive_request_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,14 @@ void main() {
.dht;
expect(dht.length, 2);
// The requested sharing key and a key auto generated for receiving
expect(dht.keys.toSet(), {'requestedSharingKey', 'key'});
expect(dht.keys.toSet(), {
'requestedSharingKey',
'VLD0:DUMMYwPaM1X1-d45IYDGLAAKQRpW2bf8cNKCIPNuW0M'
});

expect(c.state.profile?.coagContactId, '1');
expect(c.state.profile?.dhtSettingsForReceiving?.key, 'key');
expect(c.state.profile?.dhtSettingsForReceiving?.key,
'VLD0:DUMMYwPaM1X1-d45IYDGLAAKQRpW2bf8cNKCIPNuW0M');
expect(c.state.profile?.dhtSettingsForSharing?.key,
'requestedSharingKey');
expect(
Expand Down Expand Up @@ -269,21 +273,20 @@ void main() {
act: (c) async => c.contactsRepository
.initialize()
.then((_) => c.linkExistingContactSharing('1')),
// Expect that contact to contain the dht settings for receiving more
// updates as well as the details from the DHT
expect: () => [
ReceiveRequestState(ReceiveRequestStatus.success,
profile: CoagContact(
coagContactId: '1',
dhtSettingsForReceiving: const ContactDHTSettings(
key: 'sharingOfferKey', psk: 'psk'),
details: ContactDetails(
displayName: 'From DHT',
name: Name(first: 'From', last: 'DHT'))))
],
// Verify that this is also reflected in the repository with still only
// one contact
verify: (c) {
// Verify that contact to contain the dht settings for receiving more
// updates as well as the details from the DHT
expect(c.state.status, ReceiveRequestStatus.success);
expect(c.state.profile?.coagContactId, '1');
expect(c.state.profile?.dhtSettingsForReceiving,
const ContactDHTSettings(key: 'sharingOfferKey', psk: 'psk'));
expect(
c.state.profile?.details,
ContactDetails(
displayName: 'From DHT',
name: Name(first: 'From', last: 'DHT')));
// Verify that this is also reflected in the repository with still only
// one contact
expect(
(c.contactsRepository.distributedStorage
as DummyDistributedStorage)
Expand Down

0 comments on commit 67631a4

Please sign in to comment.