Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/network/01-ping-node/MIGRATION_SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand All @@ -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/
```
Expand Down
1 change: 1 addition & 0 deletions tests/network/01-ping-node/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/network/02-run-devnet1/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/network/05-mining/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
2 changes: 2 additions & 0 deletions tests/network/10-hybrid-devnet1/01-run-hybrid-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 27 additions & 0 deletions tests/network/check-node-passfile.py
Original file line number Diff line number Diff line change
@@ -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]))
8 changes: 8 additions & 0 deletions tests/network/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading