fix: scope server pins by port (fumi-core rev 1468f3c)

This commit is contained in:
randogoth 2026-09-30 08:52:57 +03:00
parent 996e879509
commit 7d2a147fec
16 changed files with 109 additions and 79 deletions

View file

@ -86,8 +86,8 @@ mod tests {
let alice_addr =
Address::parse(&format!("a{run}@127.0.0.1:19619")).unwrap();
let bob_addr = Address::parse(&format!("b{run}@127.0.0.1:19619")).unwrap();
alice_store.pin_server("127.0.0.1", &server).unwrap();
bob_store.pin_server("127.0.0.1", &server).unwrap();
alice_store.pin_server("127.0.0.1", 19619, &server).unwrap();
bob_store.pin_server("127.0.0.1", 19619, &server).unwrap();
register(&alice_store, &alice_addr, &alice, None, 5).unwrap();
register(&bob_store, &bob_addr, &bob, None, 5).unwrap();
@ -168,8 +168,8 @@ mod tests {
let run = fumi_core::crypto::b32(&suffix);
let alice_addr = Address::parse(&format!("a{run}@127.0.0.1:19619")).unwrap();
let bob_addr = Address::parse(&format!("b{run}@127.0.0.1:19619")).unwrap();
alice_store.pin_server("127.0.0.1", &server).unwrap();
bob_store.pin_server("127.0.0.1", &server).unwrap();
alice_store.pin_server("127.0.0.1", 19619, &server).unwrap();
bob_store.pin_server("127.0.0.1", 19619, &server).unwrap();
register(&alice_store, &alice_addr, &alice, None, 5).unwrap();
register(&bob_store, &bob_addr, &bob, None, 5).unwrap();
@ -272,7 +272,7 @@ mod tests {
fumi_core::address::Address::parse(&format!("u{run}@{host}:19619"))
.unwrap()
.with_dial("127.0.0.1");
store.pin_server(&host, &server).unwrap();
store.pin_server(&host, 19619, &server).unwrap();
register(&store, &addr, &account, None, 5).unwrap();
assert_eq!(store.account().unwrap().unwrap().short(),
format!("u{run}@{host}:19619"));
@ -296,7 +296,10 @@ mod tests {
let unpinned = Store::open_in_memory().unwrap();
match connect(&unpinned, &addr, true, 5) {
Err(Error::NotPinned { host }) => assert_eq!(host, "127.0.0.1"),
Err(Error::NotPinned { host, port }) => {
assert_eq!(host, "127.0.0.1");
assert_eq!(port, 19619);
}
Err(err) => panic!("expected NotPinned, got {err}"),
Ok(_) => panic!("expected NotPinned, connected"),
}
@ -304,7 +307,7 @@ mod tests {
let mut wrong = [0u8; KEY_LEN];
OsRng.fill_bytes(&mut wrong);
let mismatched = Store::open_in_memory().unwrap();
mismatched.pin_server("127.0.0.1", &wrong).unwrap();
mismatched.pin_server("127.0.0.1", 19619, &wrong).unwrap();
match connect(&mismatched, &addr, true, 5) {
Err(Error::PinMismatch { .. }) => {}
Err(err) => panic!("expected PinMismatch, got {err}"),
@ -348,8 +351,8 @@ mod tests {
let run = fumi_core::crypto::b32(&suffix);
let carol_addr = Address::parse(&format!("c{run}@127.0.0.1:19619")).unwrap();
let alice_addr = Address::parse(&format!("d{run}@127.0.0.1:19619")).unwrap();
carol_store.pin_server("127.0.0.1", &server).unwrap();
alice_store.pin_server("127.0.0.1", &server).unwrap();
carol_store.pin_server("127.0.0.1", 19619, &server).unwrap();
alice_store.pin_server("127.0.0.1", 19619, &server).unwrap();
register(&carol_store, &carol_addr, &carol, None, 5).unwrap();
register(&alice_store, &alice_addr, &alice, None, 5).unwrap();