Skip to content

Commit

Permalink
nostr: fix benches
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Dec 9, 2024
1 parent 636b904 commit 0d12a1d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/nostr/src/event/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ mod benches {
pub fn builder_to_event(bh: &mut Bencher) {
let keys = Keys::generate();
bh.iter(|| {
black_box(EventBuilder::text_note("hello", []).sign_with_keys(&keys)).unwrap();
black_box(EventBuilder::text_note("hello").sign_with_keys(&keys)).unwrap();
});
}
}
6 changes: 3 additions & 3 deletions crates/nostr/src/event/tag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ mod benches {

#[bench]
pub fn parse_p_tag(bh: &mut Bencher) {
let tag = &[
let tag = [
"p",
"13adc511de7e1cfcf1c6b7f6365fb5a03442d7bcacf565ea57fa7770912c023d",
];
Expand All @@ -576,7 +576,7 @@ mod benches {

#[bench]
pub fn parse_e_tag(bh: &mut Bencher) {
let tag = &[
let tag = [
"e",
"378f145897eea948952674269945e88612420db35791784abf0616b4fed56ef7",
"wss://relay.damus.io",
Expand All @@ -600,7 +600,7 @@ mod benches {

#[bench]
pub fn parse_a_tag(bh: &mut Bencher) {
let tag = &[
let tag = [
"a",
"30023:a695f6b60119d9521934a691347d9f78e8770b56da16bb255ee286ddf9fda919:ipsum",
"wss://relay.nostr.org",
Expand Down
8 changes: 4 additions & 4 deletions crates/nostr/src/message/relay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,9 @@ mod tests {
// Event JSON with incomplete content
let invalid_event_msg_content = r#"["EVENT", "random_string", {"id":"70b10f70c1318967eddf12527799411b1a9780ad9c43858f5e5fcd45486a13a5","pubkey":"379e863e8357163b5bce5d2688dc4f1dcc2d505222fb8d74db600f30535dfdfe"}]"#;

assert!(RelayMessage::from_json(invalid_event_msg).is_err(),);
assert!(RelayMessage::from_json(invalid_event_msg).is_err());

assert!(RelayMessage::from_json(invalid_event_msg_content).is_err(),);
assert!(RelayMessage::from_json(invalid_event_msg_content).is_err());
}

#[test]
Expand Down Expand Up @@ -514,13 +514,13 @@ mod tests {
assert!(RelayMessage::from_json(
r#"["OK", "b1a649ebe8b435ec71d3784793f3bbf4b93e64e17568a741aecd4c7ddeafce30"]"#
)
.is_err(),);
.is_err());

// Invalid event_id
assert!(RelayMessage::from_json(
r#"["OK", "b1a649ebe8b435ec71d3784793f3bbf4b93e64e17568a741aecd4c7dde", true, ""]"#
)
.is_err(),);
.is_err());

// Invalid status
assert!(
Expand Down
2 changes: 1 addition & 1 deletion crates/nostr/src/types/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ mod benches {
Tag::public_key(PublicKey::from_hex("b2d670de53b27691c0c3400225b65c35a26d06093bcc41f48ffc71e0907f9d4a").unwrap()),
Tag::public_key(PublicKey::from_hex("379e863e8357163b5bce5d2688dc4f1dcc2d505222fb8d74db600f30535dfdfe").unwrap()),
Tag::event(EventId::from_hex("7469af3be8c8e06e1b50ef1caceba30392ddc0b6614507398b7d7daa4c218e96").unwrap()),
Tag::from_standardized(TagStandard::Kind(Kind::TextNote)),
Tag::from_standardized(TagStandard::Kind { kind: Kind::TextNote, uppercase: false }),
],
"test",
Signature::from_str("273a9cd5d11455590f4359500bccb7a89428262b96b3ea87a756b770964472f8c3e87f5d5e64d8d2e859a71462a3f477b554565c4f2f326cb01dd7620db71502").unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion crates/nostr/src/util/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ mod benches {
#[bench]
pub fn hex_encode(bh: &mut Bencher) {
bh.iter(|| {
black_box(encode(EVENT_JSON));
black_box(encode(EVENT_JSON.as_bytes()));
});
}

Expand Down

0 comments on commit 0d12a1d

Please sign in to comment.