Skip to content

Commit

Permalink
feat: sim to test relay only transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
Arqu committed Dec 16, 2024
1 parent f0fdc90 commit 6f425f7
Show file tree
Hide file tree
Showing 2 changed files with 371 additions and 2 deletions.
8 changes: 6 additions & 2 deletions netsim/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
TIMEOUT = 60 * 5


def setup_env_vars(prefix, node_name, temp_dir, debug=False):
def setup_env_vars(prefix, node_name, temp_dir, node_env, debug=False):
env_vars = os.environ.copy()
env_vars["RUST_LOG_STYLE"] = "never"
env_vars["SSLKEYLOGFILE"] = f"./logs/keylog_{prefix}_{node_name}.txt"
Expand All @@ -30,6 +30,8 @@ def setup_env_vars(prefix, node_name, temp_dir, debug=False):
if not "RUST_LOG" in env_vars:
env_vars["RUST_LOG"] = "warn"
env_vars["RUST_LOG"] += ",iroh_net::magicsock::node_map::endpoint=trace"
for key, value in node_env.items():
env_vars[key] = value
return env_vars


Expand Down Expand Up @@ -168,7 +170,9 @@ def run_case(nodes, runner_id, prefix, args, debug=False, visualize=False):
prefix="netsim", suffix=f"{prefix}_{node_name}_{runner_id}"
)
temp_dirs.append(temp_dir)
env_vars = setup_env_vars(prefix, node_name, temp_dir.name, debug)

node_env = node.get("env", {})
env_vars = setup_env_vars(prefix, node_name, temp_dir.name, node_env, debug)

p = execute_node_command(cmd, prefix, node_name, n, env_vars)
if "process" in node and node["process"] == "short":
Expand Down
365 changes: 365 additions & 0 deletions netsim/sims/iroh/iroh_relay_only.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,365 @@
{
"name": "iroh_relay_only",
"cases": [
{
"name": "1_to_1",
"description": "",
"nodes": [
{
"name": "1_r",
"count": 1,
"cmd": "./bins/iroh-relay --dev --config-path ./relay.cfg",
"type": "public",
"wait": 2,
"connect": {
"strategy": "none"
}
},
{
"name": "i_srv",
"count": 1,
"cmd": "./bins/iroh-transfer provide --size=1G --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"wait": 10,
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket_v2"
},
{
"name": "i_get",
"count": 1,
"cmd": "time ./bins/iroh-transfer fetch %s --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "params",
"node": "i_srv"
},
"process": "short",
"parser": "iroh_1gb"
}
]
},
{
"name": "1_to_3",
"description": "",
"nodes": [
{
"name": "1_r",
"count": 1,
"cmd": "./bins/iroh-relay --dev --config-path ./relay.cfg",
"type": "public",
"wait": 2,
"connect": {
"strategy": "none"
}
},
{
"name": "i_srv",
"count": 1,
"cmd": "./bins/iroh-transfer provide --size=1G --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"wait": 10,
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket_v2"
},
{
"name": "i_get",
"count": 3,
"cmd": "time ./bins/iroh-transfer fetch %s --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "params",
"node": "i_srv"
},
"process": "short",
"parser": "iroh_1gb"
}
]
},
{
"name": "1_to_5",
"description": "",
"nodes": [
{
"name": "1_r",
"count": 1,
"cmd": "./bins/iroh-relay --dev --config-path ./relay.cfg",
"type": "public",
"wait": 2,
"connect": {
"strategy": "none"
}
},
{
"name": "i_srv",
"count": 1,
"cmd": "./bins/iroh-transfer provide --size=1G --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"wait": 10,
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket_v2"
},
{
"name": "i_get",
"count": 5,
"cmd": "time ./bins/iroh-transfer fetch %s --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "params",
"node": "i_srv"
},
"process": "short",
"parser": "iroh_1gb"
}
]
},
{
"name": "1_to_10",
"description": "",
"nodes": [
{
"name": "1_r",
"count": 1,
"cmd": "./bins/iroh-relay --dev --config-path ./relay.cfg",
"type": "public",
"wait": 2,
"connect": {
"strategy": "none"
}
},
{
"name": "i_srv",
"count": 1,
"cmd": "./bins/iroh-transfer provide --size=1G --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"wait": 10,
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket_v2"
},
{
"name": "i_get",
"count": 10,
"cmd": "time ./bins/iroh-transfer fetch %s --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "params",
"node": "i_srv"
},
"process": "short",
"parser": "iroh_1gb"
}
]
},
{
"name": "2_to_2",
"description": "",
"nodes": [
{
"name": "1_r",
"count": 1,
"cmd": "./bins/iroh-relay --dev --config-path ./relay.cfg",
"type": "public",
"wait": 2,
"connect": {
"strategy": "none"
}
},
{
"name": "i_srv",
"count": 2,
"cmd": "./bins/iroh-transfer provide --size=1G --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"wait": 10,
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket_v2"
},
{
"name": "i_get",
"count": 2,
"cmd": "time ./bins/iroh-transfer fetch %s --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "params",
"node": "i_srv"
},
"process": "short",
"parser": "iroh_1gb"
}
]
},
{
"name": "2_to_4",
"description": "",
"nodes": [
{
"name": "1_r",
"count": 1,
"cmd": "./bins/iroh-relay --dev --config-path ./relay.cfg",
"type": "public",
"wait": 2,
"connect": {
"strategy": "none"
}
},
{
"name": "i_srv",
"count": 2,
"cmd": "./bins/iroh-transfer provide --size=1G --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"wait": 10,
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket_v2"
},
{
"name": "i_get",
"count": 4,
"cmd": "time ./bins/iroh-transfer fetch %s --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "params",
"node": "i_srv"
},
"process": "short",
"parser": "iroh_1gb"
}
]
},
{
"name": "2_to_6",
"description": "",
"nodes": [
{
"name": "1_r",
"count": 1,
"cmd": "./bins/iroh-relay --dev --config-path ./relay.cfg",
"type": "public",
"wait": 2,
"connect": {
"strategy": "none"
}
},
{
"name": "i_srv",
"count": 2,
"cmd": "./bins/iroh-transfer provide --size=1G --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"wait": 10,
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket_v2"
},
{
"name": "i_get",
"count": 6,
"cmd": "time ./bins/iroh-transfer fetch %s --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "params",
"node": "i_srv"
},
"process": "short",
"parser": "iroh_1gb"
}
]
},
{
"name": "2_to_10",
"description": "",
"nodes": [
{
"name": "1_r",
"count": 1,
"cmd": "./bins/iroh-relay --dev --config-path ./relay.cfg",
"type": "public",
"wait": 2,
"connect": {
"strategy": "none"
}
},
{
"name": "i_srv",
"count": 2,
"cmd": "./bins/iroh-transfer provide --size=1G --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"wait": 10,
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket_v2"
},
{
"name": "i_get",
"count": 10,
"cmd": "time ./bins/iroh-transfer fetch %s --relay-url=\"http://10.0.0.1:3340\"",
"type": "public",
"env": {
"DEV_RELAY_ONLY": "1"
},
"connect": {
"strategy": "params",
"node": "i_srv"
},
"process": "short",
"parser": "iroh_1gb"
}
]
}
]
}

0 comments on commit 6f425f7

Please sign in to comment.