Pass 1 on PATH integration

This commit is contained in:
Jack Kingsman
2026-03-18 19:15:02 -07:00
parent b832239e22
commit 69e09378f5
48 changed files with 1353 additions and 412 deletions
+28 -24
View File
@@ -200,16 +200,16 @@ class TestParseExplicitHopRoute:
class TestContactToRadioDictHashMode:
"""Test that Contact.to_radio_dict() preserves the stored out_path_hash_mode."""
"""Test that Contact.to_radio_dict() preserves the stored direct-route hash mode."""
def test_preserves_1byte_mode(self):
from app.models import Contact
c = Contact(
public_key="aa" * 32,
last_path="1a2b3c",
last_path_len=3,
out_path_hash_mode=0,
direct_path="1a2b3c",
direct_path_len=3,
direct_path_hash_mode=0,
)
d = c.to_radio_dict()
assert d["out_path_hash_mode"] == 0
@@ -219,9 +219,9 @@ class TestContactToRadioDictHashMode:
c = Contact(
public_key="bb" * 32,
last_path="1a2b3c4d",
last_path_len=2,
out_path_hash_mode=1,
direct_path="1a2b3c4d",
direct_path_len=2,
direct_path_hash_mode=1,
)
d = c.to_radio_dict()
assert d["out_path_hash_mode"] == 1
@@ -231,9 +231,9 @@ class TestContactToRadioDictHashMode:
c = Contact(
public_key="cc" * 32,
last_path="1a2b3c4d5e6f",
last_path_len=2,
out_path_hash_mode=2,
direct_path="1a2b3c4d5e6f",
direct_path_len=2,
direct_path_hash_mode=2,
)
d = c.to_radio_dict()
assert d["out_path_hash_mode"] == 2
@@ -243,9 +243,9 @@ class TestContactToRadioDictHashMode:
c = Contact(
public_key="dd" * 32,
last_path=None,
last_path_len=-1,
out_path_hash_mode=-1,
direct_path=None,
direct_path_len=-1,
direct_path_hash_mode=-1,
)
d = c.to_radio_dict()
assert d["out_path_hash_mode"] == -1
@@ -255,9 +255,9 @@ class TestContactToRadioDictHashMode:
c = Contact(
public_key="ee" * 32,
last_path="aa00bb00",
last_path_len=2,
out_path_hash_mode=1,
direct_path="aa00bb00",
direct_path_len=2,
direct_path_hash_mode=1,
)
d = c.to_radio_dict()
assert d["out_path_hash_mode"] == 1
@@ -267,9 +267,9 @@ class TestContactToRadioDictHashMode:
c = Contact(
public_key="ff" * 32,
last_path="3f3f69de1c7b7e7662",
last_path_len=-125,
out_path_hash_mode=2,
direct_path="3f3f69de1c7b7e7662",
direct_path_len=-125,
direct_path_hash_mode=2,
)
d = c.to_radio_dict()
assert d["out_path"] == "3f3f69de1c7b7e7662"
@@ -281,9 +281,9 @@ class TestContactToRadioDictHashMode:
c = Contact(
public_key="11" * 32,
last_path="aabb",
last_path_len=1,
out_path_hash_mode=0,
direct_path="aabb",
direct_path_len=1,
direct_path_hash_mode=0,
route_override_path="cc00dd00",
route_override_len=2,
route_override_hash_mode=1,
@@ -309,7 +309,9 @@ class TestContactFromRadioDictHashMode:
"out_path_hash_mode": 1,
},
)
assert d["out_path_hash_mode"] == 1
assert d["direct_path"] == "aa00bb00"
assert d["direct_path_len"] == 2
assert d["direct_path_hash_mode"] == 1
def test_flood_falls_back_to_minus_one(self):
from app.models import Contact
@@ -322,4 +324,6 @@ class TestContactFromRadioDictHashMode:
"out_path_len": -1,
},
)
assert d["out_path_hash_mode"] == -1
assert d["direct_path"] == ""
assert d["direct_path_len"] == -1
assert d["direct_path_hash_mode"] == -1