diff options
| author | eunhhu <[email protected]> | 2026-09-28 19:16:39 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-28 19:16:39 +0100 |
| commit | 09b754f2490dec5582ba79c9cde55b32bac12bcf (patch) | |
| tree | 51f93709b1375648a5f2e61d625d908c0a676085 /tests | |
| parent | ec210a8aed62c301e9ae384d4d157e379fa58f54 (diff) | |
| download | pure-09b754f2490dec5582ba79c9cde55b32bac12bcf.tar.gz pure-09b754f2490dec5582ba79c9cde55b32bac12bcf.zip | |
Let a link at rest cost the listener only its allowing
A sender allowed is now a peer of 48 bytes (its key, its key's id, its
sources), found through an index by key id; ids are 32 bits, so keys that
share one are each tried. What a sending peer needs besides (the secret
its key shares with the node's, its runs' keys and addresses, its
streams) is made at its first packet and let go once it has been quiet
for the idle period (--link-idle-ms, 30 s at first) with nothing of it
waiting: the next packet makes it again, one X25519, no handshake. The
listener hands over and answers only the streams and runs that changed,
not every one at each turn. --senders FILE allows senders a line each.
The UDP link checks take their sender from such a file among a thousand
others, let it go after 400 ms of quiet, and see an order after a longer
pause arrive all the same.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/check.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/check.py b/tests/check.py index 53e04b0..e46622b 100644 --- a/tests/check.py +++ b/tests/check.py @@ -781,7 +781,10 @@ def server_links_udp(aup, pure, work, netem=None): sender saved exactly once, the refused order (count 150) did not hold back the one after it, and every acknowledged order is among the saved ones. With netem (in a network namespace of its own), the loopback - delays, loses and reorders packets meanwhile.""" + delays, loses and reorders packets meanwhile. The receiver takes its + senders from a file (--senders, the sender among a thousand others) and + lets a sender's keys and streams go after 400 ms of quiet + (--link-idle-ms): the order after a longer pause arrives all the same.""" import select import signal import socket @@ -830,9 +833,13 @@ def server_links_udp(aup, pure, work, netem=None): process.terminate() process.communicate(timeout=30) port_a, port_b, link_port = free_port(), free_port(), free_port(socket.SOCK_DGRAM) + others = random.Random(4242) + senders = [f'other{n} {others.getrandbits(256):064x}' for n in range(1000)] + senders.insert(500, f'udp-sender.ordered {keys["sender"]}') + (work / f'{tag}-senders').write_text('\n'.join(senders) + '\n') receiver = [pure / 'build/pure-serve', '--module', receiver_module, '--store', work / f'{tag}-b', '--threads', '2', '--key', work / f'{tag}-receiver.key', '--link-port', link_port, - '--sender', f'udp-sender.ordered={keys["sender"]}'] + '--senders', work / f'{tag}-senders', '--link-idle-ms', '400'] sender = [pure / 'build/pure-serve', '--module', sender_module, '--store', work / f'{tag}-a', '--key', work / f'{tag}-sender.key', '--send', f'ordered=pure://127.0.0.1:{link_port}/order', '--seal', f'ordered={keys["receiver"]}'] @@ -883,6 +890,12 @@ def server_links_udp(aup, pure, work, netem=None): time.sleep(0.1) assert (count, total) == (sent - 1, sent_total - 150), (count, total, sent, sent_total) assert sent_total >= sum(acknowledged) + 157 and sum(acknowledged) > 0, (sent_total, acknowledged) + time.sleep(1.2) # the receiver lets the quiet sender go + assert post(port_a, '/inputs/buy', {'item': 'late', 'count': 3}) == 200 + deadline = time.time() + 30 + while (number(port_b, 'count'), number(port_b, 'total')) != (sent, sent_total - 147) and time.time() < deadline: + time.sleep(0.05) + assert (number(port_b, 'count'), number(port_b, 'total')) == (sent, sent_total - 147) finally: stats = {} for name, process in hosts.items(): @@ -890,9 +903,11 @@ def server_links_udp(aup, pure, work, netem=None): _, error = process.communicate(timeout=30) assert process.returncode == 0, error[-1000:] stats[name] = [json.loads(line) for line in error.decode().splitlines() if line.startswith('{"active"')][-1] + assert stats['b']['listener_swept'] >= 1 and stats['b']['listener_woken'] >= 2, stats['b'] return {'orders': sent, 'acknowledged_total': sum(acknowledged), 'packets_after_restart': stats['a']['link_packets'], 'resent_after_restart': stats['a']['link_resent'], - 'lost_after_restart': stats['a']['link_lost'], 'received_after_restart': stats['b']['listener_received']} + 'lost_after_restart': stats['a']['link_lost'], 'received_after_restart': stats['b']['listener_received'], + 'woken_after_restart': stats['b']['listener_woken'], 'swept_after_restart': stats['b']['listener_swept']} def server_links_udp_lossy(aup, pure, work): |
