You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crates/nostr/src/event/builder.rs
+3-8Lines changed: 3 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -876,9 +876,8 @@ mod tests {
876
876
#[cfg(feature = "std")]
877
877
use core::str::FromStr;
878
878
879
-
use bitcoin::secp256k1::Secp256k1;
880
879
#[cfg(feature = "std")]
881
-
use bitcoin::secp256k1::SecretKey;
880
+
use bitcoin::secp256k1::{Secp256k1,SecretKey};
882
881
883
882
usesuper::*;
884
883
@@ -935,14 +934,12 @@ mod tests {
935
934
936
935
#[test]
937
936
fntest_zap_event_builder(){
938
-
let secp = Secp256k1::new();
939
-
940
937
let bolt11 = String::from("lnbc10u1p3unwfusp5t9r3yymhpfqculx78u027lxspgxcr2n2987mx2j55nnfs95nxnzqpp5jmrh92pfld78spqs78v9euf2385t83uvpwk9ldrlvf6ch7tpascqhp5zvkrmemgth3tufcvflmzjzfvjt023nazlhljz2n9hattj4f8jq8qxqyjw5qcqpjrzjqtc4fc44feggv7065fqe5m4ytjarg3repr5j9el35xhmtfexc42yczarjuqqfzqqqqqqqqlgqqqqqqgq9q9qxpqysgq079nkq507a5tw7xgttmj4u990j7wfggtrasah5gd4ywfr2pjcn29383tphp4t48gquelz9z78p4cq7ml3nrrphw5w6eckhjwmhezhnqpy6gyf0");
let zap_request_json = String::from("{\"pubkey\":\"32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245\",\"content\":\"\",\"id\":\"d9cc14d50fcb8c27539aacf776882942c1a11ea4472f8cdec1dea82fab66279d\",\"created_at\":1674164539,\"sig\":\"77127f636577e9029276be060332ea565deaf89ff215a494ccff16ae3f757065e2bc59b2e8c113dd407917a010b3abd36c8d7ad84c0e3ab7dab3a0b0caa9835d\",\"kind\":9734,\"tags\":[[\"e\",\"3624762a1274dd9636e0c552b53086d70bc88c165bc4dc0f9e836a1eaf86c3b8\"],[\"p\",\"32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245\"],[\"relays\",\"wss://relay.damus.io\",\"wss://nostr-relay.wlvs.space\",\"wss://nostr.fmt.wiz.biz\",\"wss://relay.nostr.bg\",\"wss://nostr.oxtr.dev\",\"wss://nostr.v0l.io\",\"wss://brb.io\",\"wss://nostr.bitcoiner.social\",\"ws://monad.jb55.com:8080\",\"wss://relay.snort.social\"]]}");
945
-
let zap_request_event:Event = Event::from_json_with_ctx(&secp,zap_request_json).unwrap();
942
+
let zap_request_event:Event = Event::from_json(zap_request_json).unwrap();
946
943
let event_builder = EventBuilder::new_zap_receipt(bolt11, preimage, zap_request_event);
947
944
948
945
assert_eq!(5, event_builder.tags.len());
@@ -959,12 +956,10 @@ mod tests {
959
956
960
957
#[test]
961
958
fntest_zap_event_builder_without_preimage(){
962
-
let secp = Secp256k1::new();
963
-
964
959
let bolt11 = String::from("lnbc10u1p3unwfusp5t9r3yymhpfqculx78u027lxspgxcr2n2987mx2j55nnfs95nxnzqpp5jmrh92pfld78spqs78v9euf2385t83uvpwk9ldrlvf6ch7tpascqhp5zvkrmemgth3tufcvflmzjzfvjt023nazlhljz2n9hattj4f8jq8qxqyjw5qcqpjrzjqtc4fc44feggv7065fqe5m4ytjarg3repr5j9el35xhmtfexc42yczarjuqqfzqqqqqqqqlgqqqqqqgq9q9qxpqysgq079nkq507a5tw7xgttmj4u990j7wfggtrasah5gd4ywfr2pjcn29383tphp4t48gquelz9z78p4cq7ml3nrrphw5w6eckhjwmhezhnqpy6gyf0");
965
960
let preimage = None;
966
961
let zap_request_json = String::from("{\"pubkey\":\"32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245\",\"content\":\"\",\"id\":\"d9cc14d50fcb8c27539aacf776882942c1a11ea4472f8cdec1dea82fab66279d\",\"created_at\":1674164539,\"sig\":\"77127f636577e9029276be060332ea565deaf89ff215a494ccff16ae3f757065e2bc59b2e8c113dd407917a010b3abd36c8d7ad84c0e3ab7dab3a0b0caa9835d\",\"kind\":9734,\"tags\":[[\"e\",\"3624762a1274dd9636e0c552b53086d70bc88c165bc4dc0f9e836a1eaf86c3b8\"],[\"p\",\"32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245\"],[\"relays\",\"wss://relay.damus.io\",\"wss://nostr-relay.wlvs.space\",\"wss://nostr.fmt.wiz.biz\",\"wss://relay.nostr.bg\",\"wss://nostr.oxtr.dev\",\"wss://nostr.v0l.io\",\"wss://brb.io\",\"wss://nostr.bitcoiner.social\",\"ws://monad.jb55.com:8080\",\"wss://relay.snort.social\"]]}");
967
-
let zap_request_event = Event::from_json_with_ctx(&secp,zap_request_json).unwrap();
962
+
let zap_request_event = Event::from_json(zap_request_json).unwrap();
968
963
let event_builder = EventBuilder::new_zap_receipt(bolt11, preimage, zap_request_event);
let event:Self = serde_json::from_str(&json.into())?;
177
-
event.verify_with_ctx(secp)?;
178
-
Ok(event)
179
-
}
180
-
181
-
/// Get event as json string
182
-
pubfnas_json(&self) -> String{
183
-
serde_json::json!(self).to_string()
184
-
}
185
-
186
167
/// Returns `true` if the event has an expiration tag that is expired.
187
168
/// If an event has no `Expiration` tag, then it will return `false`.
188
169
#[cfg(feature = "std")]
@@ -283,11 +264,9 @@ mod tests {
283
264
284
265
#[test]
285
266
fntest_tags_deser_without_recommended_relay(){
286
-
let secp = Secp256k1::new();
287
-
288
267
//The TAG array has dynamic length because the third element(Recommended relay url) is optional
289
268
let sample_event = r#"{"content":"uRuvYr585B80L6rSJiHocw==?iv=oh6LVqdsYYol3JfFnXTbPA==","created_at":1640839235,"id":"2be17aa3031bdcb006f0fce80c146dea9c1c0268b0af2398bb673365c6444d45","kind":4,"pubkey":"f86c44a2de95d9149b51c6a29afeabba264c18e2fa7c49de93424a0c56947785","sig":"a5d9290ef9659083c490b303eb7ee41356d8778ff19f2f91776c8dc4443388a64ffcf336e61af4c25c05ac3ae952d1ced889ed655b67790891222aaa15b99fdd","tags":[["p","13adc511de7e1cfcf1c6b7f6365fb5a03442d7bcacf565ea57fa7770912c023d"]]}"#;
290
-
let ev_ser = Event::from_json_with_ctx(&secp,sample_event).unwrap();
269
+
let ev_ser = Event::from_json(sample_event).unwrap();
Copy file name to clipboardExpand all lines: crates/nostr/src/event/tag.rs
+1-3Lines changed: 1 addition & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1304,11 +1304,9 @@ mod tests {
1304
1304
1305
1305
#[test]
1306
1306
fntest_deserialize_tag_from_event(){
1307
-
let secp = Secp256k1::new();
1308
-
1309
1307
// Got this fresh off the wire
1310
1308
let event:&str = r#"{"id":"2be17aa3031bdcb006f0fce80c146dea9c1c0268b0af2398bb673365c6444d45","pubkey":"f86c44a2de95d9149b51c6a29afeabba264c18e2fa7c49de93424a0c56947785","created_at":1640839235,"kind":4,"tags":[["p","13adc511de7e1cfcf1c6b7f6365fb5a03442d7bcacf565ea57fa7770912c023d"]],"content":"uRuvYr585B80L6rSJiHocw==?iv=oh6LVqdsYYol3JfFnXTbPA==","sig":"a5d9290ef9659083c490b303eb7ee41356d8778ff19f2f91776c8dc4443388a64ffcf336e61af4c25c05ac3ae952d1ced889ed655b67790891222aaa15b99fdd"}"#;
1311
-
let event = Event::from_json_with_ctx(&secp,event).unwrap();
0 commit comments