Commit 2e05837
committed
[S3-E.2] algorand: REST template fixed + 2 cli.py contract bugs
S3-E wave-E, chain 2/5. Surface objective: switch single method to
GET /v2/accounts/{address} and add _meta.rest_paths. Real work: while
verifying, discovered TWO latent production bugs in cli.py + tests that
were silently masking REST-chain correctness across all 5 REST chains.
Changes:
1. config/chains/algorand.json
- rpc_methods.single: 'GET /v2/status' (health probe, no addr)
-> 'GET /v2/accounts/{address}' (account info with address)
- Added _meta.rest_paths: 6 entries (5 bench methods + health).
Note: algorand path templates already use {address} (matches
RestAdapter's only-substituted placeholder), unlike aptos where
param_formats keys say {addr} but path values must say {address}.
- Added _meta.health_probe: GET /v2/status + parse_jq
'.[\"last-round\"]' (algod 节点 status endpoint).
2. tools/chain_adapters/cli.py — fix env-poisoning contract bug
All 3 commands (cmd_build_target / cmd_build_targets_batch /
cmd_health_probe) used os.environ.setdefault(\"BLOCKCHAIN_NODE\",
args.chain). This is silently wrong: if the parent process had
BLOCKCHAIN_NODE already set to chain X, then `cli.py --chain Y`
would set adapter=Y but BLOCKCHAIN_NODE=X, so RestAdapter would
query chain X's _meta.rest_paths for chain Y's methods. Result:
either ValueError (method not in X's map) or silent wrong-chain
target generation. Fixed: always override BLOCKCHAIN_NODE with
args.chain — explicit user intent must win over inherited env.
3. tests/test_chain_adapters.py — fix env-leak from test_7 → test_10
test_rest_requires_env_and_path_map() set os.environ['BLOCKCHAIN_NODE']
= 'aptos' without cleanup. The test_10 subprocess inherited this,
triggering exactly the cli.py setdefault bug above. Wrapped the test
body in try/finally to restore the env to its pre-test state.
This explains why S3-E.1 reported 'aptos healthy': the cli.py
queries all flowed through aptos's rest_paths, so any chain whose
single method name happened to also exist in aptos's map looked
healthy. Real correctness signal had been suppressed.
4. tests/test_chain_adapters.py KNOWN_BROKEN_CLI
- Removed 'algorand' (now healthy via cli.py).
- len() assertion: 15 -> 14.
Verification:
- L1 (unit): 10/10 PASS
- L1-CLI gate: healthy 21->22, broken 15->14, set matches
- L3 (real target_generator.sh pipeline):
exit=0, \"Using single method: GET /v2/accounts/{address}\"
\"Successfully generated 2 test targets\"
out file: {\"method\":\"GET\",\"url\":\"http://.../v2/accounts/Q5W\",...}
{\"method\":\"GET\",\"url\":\"http://.../v2/accounts/TESTADDR2\",...}
Diagnostic credit: L1-CLI invariant ledger caught both bugs immediately.
Without the monotonic-shrink guard, the wrong-chain target generation
would have shipped silently and only surfaced in S4 e2e against live
nodes.1 parent 32e21be commit 2e05837
3 files changed
Lines changed: 45 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
59 | 68 | | |
60 | 69 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
227 | 220 | | |
| 221 | + | |
228 | 222 | | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
233 | 243 | | |
234 | 244 | | |
235 | 245 | | |
| |||
333 | 343 | | |
334 | 344 | | |
335 | 345 | | |
336 | | - | |
337 | 346 | | |
338 | 347 | | |
339 | 348 | | |
| |||
359 | 368 | | |
360 | 369 | | |
361 | 370 | | |
362 | | - | |
| 371 | + | |
363 | 372 | | |
364 | 373 | | |
365 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| |||
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
67 | | - | |
| 73 | + | |
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
| |||
92 | 98 | | |
93 | 99 | | |
94 | 100 | | |
95 | | - | |
| 101 | + | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
| |||
0 commit comments