Skip to content

Commit

Permalink
test(pkarr): add unit test for maximum_ttl = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuhvi committed Dec 16, 2024
1 parent aac62e7 commit 9dde7e5
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkarr/src/client/dht.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,4 +772,38 @@ mod tests {

assert_eq!(resolved, Some(signed_packet));
}

#[tokio::test]
async fn ttl_0_test() {
let testnet = Testnet::new(10).unwrap();

let client = Client::builder()
.testnet(&testnet)
.maximum_ttl(0)
.build()
.unwrap();

let keypair = Keypair::random();
let signed_packet = SignedPacket::builder().sign(&keypair).unwrap();

client.publish(&signed_packet).await.unwrap();

// First Call
let resolved = client
.resolve(&signed_packet.public_key())
.await
.unwrap()
.unwrap();

assert_eq!(resolved.encoded_packet(), signed_packet.encoded_packet());

thread::sleep(Duration::from_secs(1));

let second = client
.resolve(&signed_packet.public_key())
.await
.unwrap()
.unwrap();
assert_eq!(second.encoded_packet(), signed_packet.encoded_packet());
}
}

0 comments on commit 9dde7e5

Please sign in to comment.