Skip to content

Commit 1a64f23

Browse files
committed
jolteon: clean up/refactor jolteon tests
1 parent 535d215 commit 1a64f23

File tree

2 files changed

+32
-57
lines changed

2 files changed

+32
-57
lines changed

e2e-tests/src/substrate_api.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,32 +47,32 @@ def __init__(self, config: ApiConfig, secrets, db_sync: Session):
4747
substrate_url = config.nodes_config.node.url
4848

4949
# Handle different URL schemes and convert to appropriate WebSocket scheme
50-
if substrate_url.startswith('https://'):
51-
# HTTPS to WSS
52-
substrate_url = substrate_url.replace('https://', 'wss://')
53-
if not substrate_url.endswith('/ws'):
54-
substrate_url += '/ws'
55-
elif substrate_url.startswith('http://'):
56-
# HTTP to WS
57-
substrate_url = substrate_url.replace('http://', 'ws://')
58-
if not substrate_url.endswith('/ws'):
59-
substrate_url += '/ws'
60-
elif substrate_url.startswith('ws://'):
61-
# Plain WS - check if port suggests HTTPS (443) and upgrade to WSS
62-
if ':443' in substrate_url:
63-
substrate_url = substrate_url.replace('ws://', 'wss://')
64-
if not substrate_url.endswith('/ws'):
65-
substrate_url += '/ws'
66-
elif substrate_url.startswith('wss://'):
67-
# Already WSS, just ensure /ws path
68-
if not substrate_url.endswith('/ws'):
69-
substrate_url += '/ws'
70-
else:
71-
# No protocol specified, assume secure WebSocket for port 443, otherwise plain WS
72-
if ':443' in substrate_url or substrate_url.endswith(':443'):
73-
substrate_url = f'wss://{substrate_url}/ws'
74-
else:
75-
substrate_url = f'ws://{substrate_url}/ws'
50+
def ensure_ws_path(url: str) -> str:
51+
"""Ensure the URL ends with /ws path"""
52+
return url if url.endswith('/ws') else f"{url}/ws"
53+
54+
match substrate_url.split('://', 1):
55+
case ['https', rest]:
56+
# HTTPS to WSS
57+
substrate_url = ensure_ws_path(f'wss://{rest}')
58+
case ['http', rest]:
59+
# HTTP to WS
60+
substrate_url = ensure_ws_path(f'ws://{rest}')
61+
case ['ws', rest]:
62+
# Plain WS - check if port suggests HTTPS (443) and upgrade to WSS
63+
if ':443' in rest:
64+
substrate_url = ensure_ws_path(f'wss://{rest}')
65+
else:
66+
substrate_url = ensure_ws_path(f'ws://{rest}')
67+
case ['wss', rest]:
68+
# Already WSS, just ensure /ws path
69+
substrate_url = ensure_ws_path(f'wss://{rest}')
70+
case _:
71+
# No protocol specified, assume secure WebSocket for port 443, otherwise plain WS
72+
if ':443' in substrate_url or substrate_url.endswith(':443'):
73+
substrate_url = f'wss://{substrate_url}/ws'
74+
else:
75+
substrate_url = f'ws://{substrate_url}/ws'
7676

7777
self.url = substrate_url
7878
logger.info(f"Substrate WebSocket URL: {self.url}")

e2e-tests/tests/README_jolteon_consensus.md

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,6 @@ pytest tests/ -m jolteon --env jolteon_docker
6868
pytest tests/ -m jolteon --blockchain substrate
6969
```
7070

71-
## Test Implementation Strategy
72-
73-
### Phase 1: Basic Functionality (Current)
74-
- ✅ QC formation and round advancement
75-
- ✅ Authority rotation verification
76-
- ✅ Metadata availability exploration
77-
78-
### Phase 2: Core Protocol Rules (Next)
79-
- 🔄 2-chain commit rule verification
80-
- 🔄 Safety properties validation
81-
- 🔄 Liveness guarantees testing
82-
83-
### Phase 3: Fault Tolerance (Future)
84-
- ⏳ Timeout mechanism testing
85-
- ⏳ TC formation verification
86-
- ⏳ Byzantine leader handling
87-
88-
### Phase 4: Performance and Limits (Future)
89-
- ⏳ Asynchronous condition testing
90-
- ⏳ DDoS attack simulation
91-
- ⏳ Performance benchmarking
92-
9371
## Understanding the Tests
9472

9573
### What These Tests Verify
@@ -108,9 +86,8 @@ pytest tests/ -m jolteon --blockchain substrate
10886

10987
### Adding New Test Cases
11088
1. Follow the existing test structure and naming conventions
111-
2. Use appropriate test keys (JOLTEON-XXX)
112-
3. Include comprehensive logging for debugging
113-
4. Add proper error handling and graceful degradation
89+
2. Include comprehensive logging for debugging
90+
3. Add proper error handling and graceful degradation
11491

11592
### Modifying Test Parameters
11693
- Adjust wait times based on your network characteristics
@@ -142,15 +119,13 @@ pytest tests/test_jolteon_consensus.py::TestJolteonConsensus::test_qc_formation_
142119
## Contributing
143120

144121
When adding new test cases:
145-
1. Follow the Tachyeon test case document structure
146-
2. Implement tests incrementally (simple → complex)
147-
3. Include proper documentation and logging
148-
4. Test thoroughly in your Jolteon environment
149-
5. Update this README with new test information
122+
1. Implement tests incrementally (simple → complex)
123+
2. Include proper documentation and logging
124+
3. Test thoroughly in your Jolteon environment
125+
4. Update this README with new test information
150126

151127
## References
152128

153-
- [Tachyeon Test Cases Document](../docs/tachyeon-test-cases.md)
154129
- [Jolteon Consensus Protocol Specification](https://eprint.iacr.org/2021/319)
155130
- [Substrate Interface Documentation](https://github.com/polkascan/py-substrate-interface)
156131
- [Partner Chains E2E Testing Guide](../README.md)

0 commit comments

Comments
 (0)