aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_transfer_slots.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-11 15:42:52 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-11 15:43:06 +0200
commit9d38418817d1894b31c93ece0113e503d82167cd (patch)
treeadf4c8126c90d60f6a16724d14eafb80f33d5289 /packages/meshbay-node/tests/test_transfer_slots.py
parentb39e73cbb279ab0274e8cd0b84304a602fe1d5ef (diff)
downloadmeshbay-9d38418817d1894b31c93ece0113e503d82167cd.tar.gz
feat(node): log what a transfer moved when it ends
One INFO line per lease: bytes, duration, rate, and the SCTP association's window, round trip, losses and T3 expirations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/tests/test_transfer_slots.py')
-rw-r--r--packages/meshbay-node/tests/test_transfer_slots.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_transfer_slots.py b/packages/meshbay-node/tests/test_transfer_slots.py
index 08e7e70..68d8858 100644
--- a/packages/meshbay-node/tests/test_transfer_slots.py
+++ b/packages/meshbay-node/tests/test_transfer_slots.py
@@ -369,3 +369,26 @@ def test_using_a_lease_forgives_its_earlier_misses(_=None):
assert s.leases["slow"].missed_grants == 2
s.touch("slow", now=2 * GRANT_DEADLINE_SECS + 3)
assert s.leases["slow"].missed_grants == 0
+
+
+# ── what the end-of-transfer line is built from ─────────────────────────────
+
+def test_a_lease_counts_what_moved_and_for_how_long():
+ slots = TransferSlots()
+ slots.open(tr="t1", kind=DOWNLOAD, session_key="s1", user_id="alice",
+ group_id="g1", now=0.0)
+ slots.touch("t1", now=10.0)
+ slots.account("t1", 1_000_000, now=10.5)
+ slots.touch("t1", now=11.0)
+ slots.account("t1", 500_000, now=12.0)
+ lease = slots.leases["t1"]
+ assert lease.moved == 1_500_000
+ assert lease.elapsed == 2.0
+
+
+def test_a_lease_nothing_moved_under_has_no_duration():
+ slots = TransferSlots()
+ lease, _ = slots.open(tr="t1", kind=DOWNLOAD, session_key="s1",
+ user_id="alice", group_id="g1", now=0.0)
+ assert (lease.moved, lease.elapsed) == (0, 0.0)
+ slots.account("unknown", 10)