Skip to content

Commit f67a5bc

Browse files
FrandoArqu
andauthored
fix: updates for changed transfer example (#75)
* fix: updates for changed transfer example * try to fix bytesize parsing * fix ticket parsing --------- Co-authored-by: Asmir Avdicevic <asmir.avdicevic64@gmail.com>
1 parent 1f54f59 commit f67a5bc

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

netsim/main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ def parse_node_params(node, prefix, node_params, runner_id):
5252
].strip()
5353
break
5454
if node["param_parser"] == "iroh_ticket_v2" and line.startswith(
55-
"NodeTicket"
55+
"Ticket with our home relay and direct addresses:"
5656
):
57-
node_params[node_name] = line[
58-
len("NodeTicket: ") :
59-
].strip()
57+
next_line = next(f)
58+
node_params[node_name] = next_line.strip()
6059
break
6160
return node_params
6261

netsim/parsing/netsim.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import re
23
import os
34
import humanfriendly
45

@@ -35,7 +36,7 @@ def parse_iroh_output(lines, size):
3536
transfer_lines = [
3637
line
3738
for line in lines
38-
if "Transferred" in line and "in" in line and "/s" in line
39+
if ("Transferred" in line or "Received" in line) and "in" in line and "/s" in line
3940
]
4041
if not transfer_lines:
4142
raise Exception("bad run")
@@ -51,7 +52,12 @@ def parse_iroh_output(lines, size):
5152

5253
def parse_humanized_output(line):
5354
"""Convert human-readable size to megabits."""
54-
bytes_size = humanfriendly.parse_size(line.split(", ")[-1], binary=True)
55+
x = re.search("\((.*)\/s", line)
56+
if x is None:
57+
raise Exception("Line does not match bytesize pattern")
58+
59+
match = x.groups()[0]
60+
bytes_size = humanfriendly.parse_size(match, binary=True)
5561
return bytes_size * 8 / 1e6
5662

5763

@@ -84,7 +90,7 @@ def parse_magic_iroh_client(lines):
8490
s["transfer_success"] = (
8591
"true"
8692
if any(
87-
"Transferred" in line and "in" in line and "/s" in line for line in lines
93+
"Received" in line and "in" in line and "/s" in line for line in lines
8894
)
8995
else "false"
9096
)

0 commit comments

Comments
 (0)