Skip to content

test(e2etest): stop the test server when a test ends - #5061

Open
envestcc wants to merge 1 commit into
iotexproject:masterfrom
envestcc:test/e2etest-teardown
Open

envestcc wants to merge 1 commit into
iotexproject:masterfrom
envestcc:test/e2etest-teardown

Conversation

@envestcc

Copy link
Copy Markdown
Member

Fourteen e2e tests start a server with newE2ETest and never call teardown(). The server keeps listening and keeps its DB paths until the package run ends. A later test that uses the default ports from initCfg then fails with listen tcp :14014: bind: address already in use, depending on test order. For example, any test run after TestNativeStakingVoteBug that uses the default gRPC port.

This adds defer test.teardown() right after newE2ETest in:

  • blobtx_test.go: TestBlobTx
  • dynamicfee_tx_test.go: TestDynamicFeeTx
  • erigon_test.go: TestErigonArchiveContract
  • native_staking_test.go: TestNativeStakingVoteBug, TestCandidateBLSPublicKey, TestCandidateBLSPoP
  • setcodetx_test.go: TestSetCodeTx_E2E, TestSetCodeTx_BatchTransfer, TestSetCodeTx_ERC20ApproveAndTransfer, TestSetCodeTx_GasSponsorship, TestEstimateGas
  • trace_block_test.go: TestTraceBlockByNumber, TestTraceBlockByNumberPrestateTracer, TestTraceBlockPerTxIsolation

The contract staking tests (TestContractStakingV1/V2/V3, TestStakingViewInit) are left unchanged. checkStakingViewInit already stops their server and tears down the one it restarts, so a deferred teardown would stop an already stopped service (service is in wrong state).

Test only, no production code. go test ./e2etest/ passes.

🤖 Generated with Claude Code

Fourteen tests started an e2e server and never called teardown, so the
server kept its ports and DB paths for the rest of the package run. A later
test that uses the default ports from initCfg then fails with "address
already in use", depending on test order. Defer teardown right after
newE2ETest in each of them.

The contract staking tests are left as they are: checkStakingViewInit
already stops their server and tears down the one it restarts.
@envestcc
envestcc requested a review from a team as a code owner October 23, 2026 03:18
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.84%. Comparing base (436e4d1) to head (8b7ec7a).
⚠️ Report is 377 commits behind head on master.

❌ Your project check has failed because the head coverage (62.84%) is below the target coverage (85.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5061       +/-   ##
===========================================
- Coverage   74.83%   62.84%   -12.00%     
===========================================
  Files         378      503      +125     
  Lines       31624    50389    +18765     
===========================================
+ Hits        23666    31667     +8001     
- Misses       6747    15000     +8253     
- Partials     1211     3722     +2511     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant