diff --git a/tests/network/01-ping-node/MIGRATION_SUMMARY.md b/tests/network/01-ping-node/MIGRATION_SUMMARY.md index a0f2bed9..d097a797 100644 --- a/tests/network/01-ping-node/MIGRATION_SUMMARY.md +++ b/tests/network/01-ping-node/MIGRATION_SUMMARY.md @@ -91,7 +91,7 @@ Comprehensive documentation covering: | **Node1 Port** | 10101 | 4040 | | **Node2 Port** | 10102 | 4040 (only used for ping, not listening) | | **Config Source** | `fixtures/network-node-configs/devnet1/node1.json` | Generated by `modal node create` | -| **Passfile** | `fixtures/passfiles/node1.mod_passfile` | Generated in `./tmp/node1/node.passfile` | +| **Passfile** | `fixtures/passfiles/node1.mod_passfile` | Generated in `./tmp/node1/node.modal_passfile` | **Note:** Port 4040 is the default from `modal node create`. This can be customized by editing the generated `config.json`. @@ -117,12 +117,12 @@ Comprehensive documentation covering: └── tmp/ # NEW: Created by scripts (gitignored) ├── node1/ │ ├── config.json # Generated - │ ├── node.passfile # Generated (keep secure!) + │ ├── node.modal_passfile # Generated (keep secure!) │ ├── storage/ # RocksDB datastore │ └── logs/ # Node logs └── node2/ ├── config.json - ├── node.passfile + ├── node.modal_passfile ├── storage/ └── logs/ ``` diff --git a/tests/network/01-ping-node/test.sh b/tests/network/01-ping-node/test.sh index 43757987..d341cc27 100755 --- a/tests/network/01-ping-node/test.sh +++ b/tests/network/01-ping-node/test.sh @@ -29,6 +29,7 @@ echo "" echo "Test 2: Verifying node1 structure..." assert_file_exists "./tmp/node1/config.json" "Node1 config.json should exist" assert_file_exists "./tmp/node1/node.modal_passfile" "Node1 passfile should exist" +assert_node_passfile_config "./tmp/node1" "node1 config should resolve to its generated passfile" assert_file_exists "./tmp/node1/data" "Node1 data directory should exist" # Test 3: Verify node1 has the standard peer ID diff --git a/tests/network/02-run-devnet1/test.sh b/tests/network/02-run-devnet1/test.sh index d9859628..6cbe03d9 100755 --- a/tests/network/02-run-devnet1/test.sh +++ b/tests/network/02-run-devnet1/test.sh @@ -27,6 +27,7 @@ echo "" echo "Test 2: Verifying node1 structure..." assert_file_exists "./tmp/node1/config.json" "Node1 config.json should exist" assert_file_exists "./tmp/node1/node.modal_passfile" "Node1 passfile should exist" +assert_node_passfile_config "./tmp/node1" "node1 config should resolve to its generated passfile" assert_file_exists "./tmp/node1/data" "Node1 data directory should exist" # Test 3: Verify node1 has the standard peer ID diff --git a/tests/network/05-mining/test.sh b/tests/network/05-mining/test.sh index 20215326..add34982 100755 --- a/tests/network/05-mining/test.sh +++ b/tests/network/05-mining/test.sh @@ -52,6 +52,7 @@ PYCONFIG assert_file_exists "./tmp/miner/config.json" "Node config should be created" assert_file_exists "./tmp/miner/node.modal_passfile" "Node passfile should be created" +assert_node_passfile_config "./tmp/miner" "miner config should resolve to its generated passfile" # Test 3: Start miner echo "" diff --git a/tests/network/10-hybrid-devnet1/01-run-hybrid-node.sh b/tests/network/10-hybrid-devnet1/01-run-hybrid-node.sh index 1b858e54..e339b25d 100755 --- a/tests/network/10-hybrid-devnet1/01-run-hybrid-node.sh +++ b/tests/network/10-hybrid-devnet1/01-run-hybrid-node.sh @@ -27,6 +27,8 @@ if [ ! -f "./tmp/node1/config.json" ]; then EOF fi +python3 ../check-node-passfile.py ./tmp/node1 || exit 1 + # Clear storage for clean test modal node clear-storage --dir ./tmp/node1 --yes diff --git a/tests/network/check-node-passfile.py b/tests/network/check-node-passfile.py new file mode 100644 index 00000000..835e4d97 --- /dev/null +++ b/tests/network/check-node-passfile.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +"""Check that a created node uses its generated passfile, not a stale path.""" + +import json +import sys +from pathlib import Path + + +def main(node_dir: Path) -> None: + config = json.loads((node_dir / "config.json").read_text()) + configured = config.get("passfile_path") + if not isinstance(configured, str) or not configured: + raise ValueError("config has no passfile_path") + expected = node_dir / "node.modal_passfile" + actual = Path(configured) + if not actual.is_absolute(): + actual = node_dir / actual + if actual.resolve() != expected.resolve(): + raise ValueError(f"passfile_path resolves to {actual}, expected {expected}") + if not actual.is_file(): + raise ValueError(f"configured passfile does not exist: {actual}") + + +if __name__ == "__main__": + if len(sys.argv) != 2: + sys.exit("usage: check-node-passfile.py NODE_DIR") + main(Path(sys.argv[1])) diff --git a/tests/network/test-lib.sh b/tests/network/test-lib.sh index b513c2c3..7108074c 100755 --- a/tests/network/test-lib.sh +++ b/tests/network/test-lib.sh @@ -225,6 +225,14 @@ assert_file_exists() { fi } +# Verify the generated config resolves to the generated node identity. +# A file-existence check alone misses a stale passfile_path in config.json. +assert_node_passfile_config() { + local node_dir="$1" + local msg="${2:-Node config should use its generated passfile}" + assert_success "python3 ../check-node-passfile.py '$node_dir'" "$msg" +} + # Assert numeric comparison assert_number() { local actual="$1"