mirror of
https://github.com/ratspeak/rsLXMF
synced 2026-11-22 23:10:35 +00:00
discovery: delegate both-form stamp validation
This commit is contained in:
1 parent
eee86a37c2
commit
bc07d04396
1 file changed
+16
@@ -58,6 +58,10 @@ impl DiscoveryStamper for LxmfDiscoveryStamper {
|
||||
fn valid(&self, infohash: &[u8; 32], stamp: &[u8], required_value: f64) -> bool {
|
||||
rns_transport::discovery::RnsDiscoveryStamper.valid(infohash, stamp, required_value)
|
||||
}
|
||||
|
||||
fn validate(&self, infohash: &[u8; 32], stamp: &[u8], required_value: f64) -> Option<f64> {
|
||||
rns_transport::discovery::RnsDiscoveryStamper.validate(infohash, stamp, required_value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Synchronous discovery stamp search with 20 HKDF workblock rounds and an
|
||||
@@ -140,6 +144,18 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn non_expanded_stamps_validate_with_their_own_value() {
|
||||
let infohash = mk_infohash(b"non-expanded");
|
||||
let (stamp, value) =
|
||||
rns_identity::stamps::generate_stamp(&infohash, 6.0, 0, 32, &StampControl::default())
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let stamper = LxmfDiscoveryStamper::default();
|
||||
assert_eq!(stamper.validate(&infohash, &stamp, 6.0), Some(value));
|
||||
assert!(stamper.valid(&infohash, &stamp, 6.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn workblock_constant_matches_python() {
|
||||
assert_eq!(DISCOVERY_WORKBLOCK_EXPAND_ROUNDS, 20);
|
||||
|
||||
Reference in new issue
Block a user