Skip to content

Standardize API env sourcing, fix genesis duplication, add pytest framework, and expand .gitignore#118

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/standardize-api-env-sourcing
Draft

Standardize API env sourcing, fix genesis duplication, add pytest framework, and expand .gitignore#118
Copilot wants to merge 2 commits intomainfrom
copilot/standardize-api-env-sourcing

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 4, 2026

Nine scripts hardcoded 127.0.0.1:9650, info.peers.sh embedded node IDs and public endpoints, genesis/ duplicated chains/testnet/, devnet genesis had an internal gasLimit mismatch, and the test files lacked any framework or assertions.

API env sourcing

  • env.sh: URL="127.0.0.1:9650"URL="${URL:-127.0.0.1:9650}" (environment-overridable)
  • All 11 scripts that hardcoded the URL now source env.sh and use ${URL}
  • info.peers.sh: hardcoded node IDs and public Avalanche endpoints replaced with NODE_IDS="$1" / ENDPOINT="${2:-${URL}}"
  • platform.getValidatorsAt.sh: height parameterized as HEIGHT="${2:-1}"

Genesis cleanup

  • Removed genesis/ root directory (byte-for-byte identical to chains/testnet/)
  • Updated subnet-cli/subnet-cli-wizard.sh reference: ../genesis/../chains/testnet/
  • Fixed chains/devnet/genesis.json header gasLimit: 0x7a1200 (8 M) → 0x1312D00 (20 M) to match its own feeConfig.gasLimit

Python test framework

  • rpc/rpc_test.py: refactored to pytest; fixed test_chain_id which was passing chain_id as the JSON-RPC id field instead of validating the returned value:
    # Before — chain_id used as request id, no assertion
    payload = {"jsonrpc": "2.0", "method": "eth_chainId", "id": chain_id}
    
    # After — proper params field, assert returned value matches expected
    payload = {"jsonrpc": "2.0", "method": "eth_chainId", "params": [], "id": 1}
    assert int(response_data["result"], 16) == TESTNET_CHAIN_ID
  • rpc/websocket_test.py: refactored to pytest + pytest-asyncio with assertions on subscription response
  • Added rpc/requirements.txt: pytest, pytest-asyncio, requests, websockets

Miscellaneous

  • .github/workflows/add-issue-to-backlog.yml: actions/add-to-project@v0.5.0v1.0.2
  • .gitignore: added OS artifacts, editor dirs, *.tar.gz, Python caches, and secret file patterns (*.pem, *.key, .env)
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature][Medium] Standardize API env sourcing, add test framework, fix genesis duplication, and expand .gitignore</issue_title>
<issue_description>## Feature/Improvement Findings — Medium Priority

Eight medium-priority improvements were identified that are not covered by existing issues (#96, #97, #103, #104, #108).


1. API Scripts Inconsistently Source env.sh for URL Configuration

Files: All api/*.sh files

Only 4 of 13 API scripts source env.sh. The rest hardcode URL="127.0.0.1:9650" locally or inline. Changing the node endpoint requires editing 9+ files.

Fix: Have all scripts source env.sh. Update env.sh to support overriding: URL="${URL:-127.0.0.1:9650}".


2. Python Test Files Have No Assertions, No Framework, No Exit Codes

Files: rpc/rpc_test.py, rpc/websocket_test.py

Tests use print() for output with no assertions, no test framework (pytest/unittest), no exit codes. The test_chain_id() function sends chain_id as the JSON-RPC id field instead of validating the returned chain ID. No requirements.txt exists.

Fix: Refactor tests to use pytest, add assertions, fix the chain ID test logic, add requirements.txt.


3. Genesis File Duplication Between genesis/ and chains/testnet/

Files: genesis/*.json vs chains/testnet/*.json

Three genesis files are byte-for-byte identical across these two directories. The genesis/ root directory appears to be a leftover from before the chains/ reorganization.

Fix: Remove the genesis/ root directory. Update references (e.g., subnet-cli/subnet-cli-wizard.sh line 8) to point to chains/testnet/.


4. info.peers.sh Hardcodes Specific Node IDs and Uses Different Endpoints

File: api/info.peers.sh (lines 10–15, 27–29)

Unlike other API scripts that accept parameters via $1, this script embeds node IDs directly and uses public Avalanche API endpoints (api.avax-test.network, api.avax.network) instead of 127.0.0.1:9650.

Fix: Accept node IDs and endpoint as command-line arguments. Use ${URL} from env.sh.


5. Devnet Genesis gasLimit Inconsistency (8M header vs 20M feeConfig)

File: chains/devnet/genesis.json (line 47 vs line 5)

The devnet genesis block header gasLimit is 0x7a1200 (8M) while its own feeConfig.gasLimit is 20M (matching all other environments). This internal inconsistency could cause unexpected contract behavior on devnet.

Fix: Align the header gasLimit to 0x1312D00 (20M) to match feeConfig and other environments.


6. GitHub Actions Workflow Uses Outdated add-to-project@v0.5.0

File: .github/workflows/add-issue-to-backlog.yml (line 14)

The actions/add-to-project action is at v1.0.2+ but the workflow pins to v0.5.0, missing security patches. The action is also pinned to a mutable tag rather than a commit SHA.

Fix: Update to actions/add-to-project@v1.0.2 or pin to a specific commit SHA.


7. .gitignore Only Contains a Single Entry

File: .gitignore

Only excludes .subnet-cli.pk. Missing: OS files (.DS_Store), editor files (.vscode/, .idea/), download artifacts (*.tar.gz), Python caches (__pycache__/), environment files (.env, *.pem, *.key).

Fix: Expand .gitignore to cover OS artifacts, editor files, build artifacts, Python caches, and broader secret file patterns.


8. platform.getValidatorsAt.sh Hardcodes height:1

File: api/platform.getValidatorsAt.sh (lines 8–10)

The height parameter is hardcoded to 1, making the script unable to query validators at any other height. The subnetID is properly parameterized via $1 but height is not.

Fix: Accept height as a second argument: HEIGHT="${2:-1}".


Generated by Health Monitor with Omni</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…tion, and expand .gitignore

Co-authored-by: numbers-official <181934381+numbers-official@users.noreply.github.com>
Copilot AI changed the title [WIP] Standardize API env sourcing and add test framework Standardize API env sourcing, fix genesis duplication, add pytest framework, and expand .gitignore Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature][Medium] Standardize API env sourcing, add test framework, fix genesis duplication, and expand .gitignore

2 participants