fix: slotsfull is occupancy, not free slots, and cover it end to end

Running the e2e suite against a real soulfind showed the per-member slots
field was implemented backwards. The wire field is `slotsfull` -- a boolean
that is true when the member's upload slots are all occupied -- not a count
of free ones. `slots_free: u32` named it, documented it and printed it as
the opposite of what the server means, so a caller reading it would pick the
busiest peer to download from.

- types: `slots_full: bool`, with the wire name in the doc comment
- the DTO, the `room users` output and SKILL.md follow
- a new e2e test joins a room with a member sharing a known three files and
  asserts the counts, the roster alignment and the slot flag against
  soulfind, so the parsing is checked against a real server rather than only
  against frames this repo wrote itself
This commit is contained in:
Michel de Graaf
2026-08-28 14:39:34 +00:00
parent 60f7100e30
commit 35a6fed3c3
10 changed files with 109 additions and 25 deletions
@@ -59,7 +59,8 @@ fn read_int32s(message: &mut Message) -> Vec<u32> {
/// Parse the per-member statistics that follow the membership list of a
/// `JoinRoom` (code 14) reply: statuses, then a record of share statistics per
/// member, then free upload slots, then country codes.
/// member, then whether each member's upload slots are full, then country
/// codes.
///
/// Each vector is independently length-prefixed and a server may send fewer
/// entries than there are members (or, on an older server, omit the country
@@ -87,7 +88,7 @@ fn parse_member_stats(
shares.push((average_speed, shared_files, shared_folders));
}
let slots_free = read_int32s(message);
let slots_full = read_int32s(message);
let countries = read_strings(message);
users
@@ -104,7 +105,7 @@ fn parse_member_stats(
average_speed,
shared_files,
shared_folders,
slots_free: slots_free.get(i).copied().unwrap_or(0),
slots_full: slots_full.get(i).copied().unwrap_or(0) != 0,
country: countries.get(i).cloned().filter(|c| !c.is_empty()),
}
})
@@ -156,7 +157,7 @@ mod tests {
.write_int64(0)
.write_int32(10)
.write_int32(2)
// free slots
// slots full
.write_int32(2)
.write_int32(1)
.write_int32(0)
@@ -188,7 +189,7 @@ mod tests {
average_speed: 1024,
shared_files: 4321,
shared_folders: 77,
slots_free: 1,
slots_full: true,
country: Some("NL".to_string()),
},
RoomUserStats {
@@ -197,7 +198,7 @@ mod tests {
average_speed: 50,
shared_files: 10,
shared_folders: 2,
slots_free: 0,
slots_full: false,
country: None,
},
]