Skip to content

Commit 21d1b26

Browse files
test(db): use canonical channel roster fixtures
Signed-off-by: tornquist <[email protected]>
1 parent da01840 commit 21d1b26

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

‎crates/buzz-db/src/channel.rs‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,11 +2434,35 @@ mod tests {
24342434

24352435
let stale_tags: Vec<serde_json::Value> =
24362436
std::iter::once(serde_json::json!(["d", channel.id.to_string()]))
2437-
.chain((0..1_000).map(|n| serde_json::json!(["p", format!("{n:064x}")])))
2437+
.chain(std::iter::once(serde_json::json!([
2438+
"p",
2439+
hex::encode(&creator),
2440+
"",
2441+
"owner"
2442+
])))
2443+
.chain(
2444+
(1..1_000).map(|n| serde_json::json!(["p", format!("{n:064x}"), "", "member"])),
2445+
)
24382446
.collect();
24392447
let complete_tags: Vec<serde_json::Value> =
24402448
std::iter::once(serde_json::json!(["d", channel.id.to_string()]))
2441-
.chain((0..1_501).map(|n| serde_json::json!(["p", format!("{n:064x}")])))
2449+
.chain(std::iter::once(serde_json::json!([
2450+
"p",
2451+
hex::encode(&creator),
2452+
"",
2453+
"owner"
2454+
])))
2455+
.chain(
2456+
(1..=1_500)
2457+
.map(|n| serde_json::json!(["p", format!("{n:064x}"), "", "member"])),
2458+
)
2459+
.collect();
2460+
let other_complete_tags: Vec<serde_json::Value> =
2461+
std::iter::once(serde_json::json!(["d", channel.id.to_string()]))
2462+
.chain(
2463+
(0..=1_500)
2464+
.map(|n| serde_json::json!(["p", format!("{n:064x}"), "", "member"])),
2465+
)
24422466
.collect();
24432467

24442468
// Insert canonical-looking history first, then corrupt the newest row
@@ -2517,7 +2541,7 @@ mod tests {
25172541
.bind(other_community_id)
25182542
.bind(random_pubkey())
25192543
.bind(&relay_pubkey)
2520-
.bind(serde_json::Value::Array(complete_tags.clone()))
2544+
.bind(serde_json::Value::Array(other_complete_tags))
25212545
.bind(vec![0u8; 64])
25222546
.bind(channel.id)
25232547
.bind(channel.id.to_string())
@@ -3102,7 +3126,7 @@ mod tests {
31023126
let event = nostr::EventBuilder::new(nostr::Kind::Custom(39002), "")
31033127
.tags(vec![
31043128
nostr::Tag::parse(["d", &channel.id.to_string()]).expect("d tag"),
3105-
nostr::Tag::parse(["p", &hex::encode(&owner)]).expect("p tag"),
3129+
nostr::Tag::parse(["p", &hex::encode(&owner), "", "owner"]).expect("p tag"),
31063130
])
31073131
.sign_with_keys(&relay_keys)
31083132
.expect("sign roster");

0 commit comments

Comments
 (0)