Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
ethicnology committed May 24, 2023
1 parent 508bf5a commit 5113922
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
1 change: 0 additions & 1 deletion lib/nostr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ export 'src/nips/nip_019.dart';
export 'src/nips/nip_020.dart';
export 'src/nips/nip_028.dart';
export 'src/nips/nip_051.dart';

3 changes: 2 additions & 1 deletion lib/src/nips/nip_005.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Nip5 {
List<dynamic> parts = dns.split('@');
String name = parts[0];
String domain = parts[1];
return DNS(name, domain, event.pubkey, relays.map((e) => e.toString()).toList());
return DNS(name, domain, event.pubkey,
relays.map((e) => e.toString()).toList());
}
} catch (e) {
throw Exception(e.toString());
Expand Down
8 changes: 4 additions & 4 deletions test/nips/nip_010_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ void main() {
group('nip010', () {
test('fromTags', () {
List<List<String>> tags = [
["e", '91cf9..4e5ca', 'wss://alicerelay.com', "root"],
["e", '14aeb..8dad4', 'wss://bobrelay.com/nostr', "reply"],
["p", '612ae..e610f', 'ws://carolrelay.com/ws'],
];
["e", '91cf9..4e5ca', 'wss://alicerelay.com', "root"],
["e", '14aeb..8dad4', 'wss://bobrelay.com/nostr', "reply"],
["p", '612ae..e610f', 'ws://carolrelay.com/ws'],
];
Thread thread = Nip10.fromTags(tags);
expect(thread.root.eventId, '91cf9..4e5ca');
expect(thread.root.relayURL, 'wss://alicerelay.com');
Expand Down
46 changes: 29 additions & 17 deletions test/nips/nip_051_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,30 @@ void main() {
"2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1");
Event event = Nip51.createCategorizedPeople("friends", [publicFriend],
[privateFriend], user.private, user.public);

Lists lists = Nip51.getLists(event, user.private);
expect(lists.people[0].pubkey, '2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1');
expect(lists.people[0].pubkey,
'2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1');
expect(lists.people[0].petName, 'alias');
expect(lists.people[1].pubkey, '0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181');
expect(lists.people[1].pubkey,
'0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181');
expect(lists.people[1].petName, 'bob');
});

test('createCategorizedBookmarks', () {
Keychain user = Keychain.generate();
String bookmark = '2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1';
String encryptedBookmark = '0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181';
String bookmark =
'2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1';
String encryptedBookmark =
'0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181';
Event event = Nip51.createCategorizedBookmarks("bookmarks", [bookmark],
[encryptedBookmark], user.private, user.public);

Lists lists = Nip51.getLists(event, user.private);
expect(lists.bookmarks[0], '2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1');
expect(lists.bookmarks[1], '0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181');
expect(lists.bookmarks[0],
'2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1');
expect(lists.bookmarks[1],
'0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181');
});

test('createMutePeople', () {
Expand All @@ -49,25 +55,31 @@ void main() {
'wss://example2.com',
'bob',
"2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1");
Event event = Nip51.createMutePeople([publicFriend],
[privateFriend], user.private, user.public);
Event event = Nip51.createMutePeople(
[publicFriend], [privateFriend], user.private, user.public);
Lists lists = Nip51.getLists(event, user.private);
expect(lists.people[0].pubkey, '2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1');
expect(lists.people[0].pubkey,
'2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1');
expect(lists.people[0].petName, 'alias');
expect(lists.people[1].pubkey, '0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181');
expect(lists.people[1].pubkey,
'0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181');
expect(lists.people[1].petName, 'bob');
});

test('createPinEvent', () {
Keychain user = Keychain.generate();
String bookmark = '2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1';
String encryptedBookmark = '0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181';
Event event = Nip51.createPinEvent([bookmark],
[encryptedBookmark], user.private, user.public);
String bookmark =
'2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1';
String encryptedBookmark =
'0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181';
Event event = Nip51.createPinEvent(
[bookmark], [encryptedBookmark], user.private, user.public);

Lists lists = Nip51.getLists(event, user.private);
expect(lists.bookmarks[0], '2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1');
expect(lists.bookmarks[1], '0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181');
expect(lists.bookmarks[0],
'2d38a56c4303bc722370c50c86fc8dd3327f06a8fe59b3ff3d670738d71dd1e1');
expect(lists.bookmarks[1],
'0f76c800a7ea76b83a3ae87de94c6046b98311bda8885cedd8420885b50de181');
});
});
}

0 comments on commit 5113922

Please sign in to comment.