@@ -62,6 +62,13 @@ def test_source_exchange_summary_counts_embedded_sx2_requests(tmp_path: Path) ->
6262 module = load_live_wire_module ()
6363 dump_path = tmp_path / "emulebb-rust-ed2k-tcp-dump-test.jsonl"
6464 request_filename_ext_info = bytes ([1 , 0 , 0 , 0 , 0 ])
65+ answer_sources2_payload = (
66+ bytes ([4 ])
67+ + bytes (range (16 ))
68+ + (2 ).to_bytes (2 , "little" )
69+ + (bytes ([192 , 0 , 2 , 1 ]) + (4662 ).to_bytes (2 , "little" ) + bytes (23 ))
70+ + (bytes ([192 , 0 , 2 , 2 ]) + (4663 ).to_bytes (2 , "little" ) + bytes (23 ))
71+ )
6572 multipacket_ext_payload = (
6673 bytes (range (16 ))
6774 + (12345 ).to_bytes (8 , "little" )
@@ -79,7 +86,7 @@ def test_source_exchange_summary_counts_embedded_sx2_requests(tmp_path: Path) ->
7986 {
8087 "direction" : "recv" ,
8188 "opcode" : module .OP_ANSWERSOURCES2 ,
82- "payload_hex" : "" ,
89+ "payload_hex" : answer_sources2_payload . hex () ,
8390 },
8491 ]
8592 dump_path .write_text ("\n " .join (json .dumps (row ) for row in records ), encoding = "utf-8" )
@@ -90,6 +97,8 @@ def test_source_exchange_summary_counts_embedded_sx2_requests(tmp_path: Path) ->
9097 assert summary ["embeddedRequestSources2Sent" ] == 1
9198 assert summary ["standaloneRequestSources2Sent" ] == 0
9299 assert summary ["answerSources2Received" ] == 1
100+ assert summary ["answerSources2SourceCount" ] == 2
101+ assert summary ["emptyAnswerSources2Received" ] == 0
93102
94103
95104def test_source_exchange_summary_counts_ext2_embedded_sx2_requests (tmp_path : Path ) -> None :
@@ -120,6 +129,28 @@ def test_source_exchange_summary_counts_ext2_embedded_sx2_requests(tmp_path: Pat
120129 assert summary ["embeddedRequestSources2Sent" ] == 1
121130
122131
132+ def test_source_exchange_summary_counts_empty_sx2_answers (tmp_path : Path ) -> None :
133+ module = load_live_wire_module ()
134+ dump_path = tmp_path / "emulebb-rust-ed2k-tcp-dump-test.jsonl"
135+ answer_sources2_payload = bytes ([4 ]) + bytes (range (16 )) + (0 ).to_bytes (2 , "little" )
136+ dump_path .write_text (
137+ json .dumps (
138+ {
139+ "direction" : "recv" ,
140+ "opcode" : module .OP_ANSWERSOURCES2 ,
141+ "payload_hex" : answer_sources2_payload .hex (),
142+ }
143+ ),
144+ encoding = "utf-8" ,
145+ )
146+
147+ summary = module .summarize_source_exchange_packets (tmp_path )
148+
149+ assert summary ["answerSources2Received" ] == 1
150+ assert summary ["answerSources2SourceCount" ] == 0
151+ assert summary ["emptyAnswerSources2Received" ] == 1
152+
153+
123154def test_run_downloads_returns_after_first_completion (monkeypatch ) -> None :
124155 module = load_live_wire_module ()
125156 transfer_hashes = [
0 commit comments