Skip to content

Commit 7341609

Browse files
committed
unit test for invalid relay
If invalid relay/url is given , program should continue gracefully. this captures the recent fix for issue #77 .
1 parent 87b018f commit 7341609

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ To get all encrypted messages:
142142
./nostr_console_elf64 --prikey=K --request='["REQ","cn",{"limit":20000,"kinds":[104,140,141,142],"since":1663417739}]' # run on linux/bash
143143
```
144144

145+
To run unit tests using Dart, in main/top level directory, run:
146+
147+
```
148+
dart run test -r expanded
149+
```
150+
145151
# Troubleshooting
146152

147153
In case program is not sending events:

test/nostr_console_test.dart

+16-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:nostr_console/settings.dart';
33
import 'package:nostr_console/utils.dart';
44
import 'package:test/test.dart';
55
import 'package:nostr_console/tree_ds.dart';
6+
import 'package:nostr_console/relays.dart';
67

78

89
EventData exampleEdata = EventData("id1", "pubkey", 1111111, 1, "content", [], [], [], [[]], {});
@@ -16,8 +17,18 @@ Tree exampleTree = Tree.withoutStore(exampleEvent, []);
1617

1718
//bool skipTest = true;
1819

20+
Relays relays = Relays({}, {}, {});
21+
1922
void main() {
20-
23+
24+
test('invalid_relay', () async {
25+
26+
String req = '["REQ","latest_live_all",{"limit":40000,"kinds":[0,1,3,4,5,6,7,40,41,42,104,140,141,142],"since":${getTimeSecondsAgo(gSecsLatestLive).toString()}}]';
27+
sendRequest({"wss://invalidurl1234123134.com"}, req);
28+
29+
});
30+
31+
2132
test('printEventNode', () {
2233
Store store = exampleStore;
2334
Tree tree = exampleTree;
@@ -323,6 +334,10 @@ String expectedResult =
323334
expect (expandLNInvoices(lnInvoice1),lnQrCodeResult1, reason: "testing ln qr code function");
324335

325336
});
337+
338+
339+
326340
return ;
341+
327342
} // end main
328343

0 commit comments

Comments
 (0)