mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
This commit adds robust input validation to the SetGasPrice method and implements comprehensive table-driven tests to ensure correct behavior. Changes in core/txpool/txpool.go: - Add nil gas price validation with graceful error handling - Add validation to reject negative gas prices - Add validation to reject gas prices exceeding 1000 GWei maximum - Return detailed error messages for each validation failure - Log warnings when invalid gas prices are rejected Changes in eth/api_miner.go: - Update MinerAPI.SetGasPrice to check error return from txPool.SetGasPrice - Return false when validation fails (when SetGasPrice returns error) - Return true when validation succeeds (when SetGasPrice returns nil) New tests in core/txpool/txpool_test.go: - Implement TestSetGasPrice using table-driven test pattern - Test 4 invalid cases: nil, negative, exceed max+1, exceed 10000 GWei - Test 7 valid cases: 0, 1 wei, 1 GWei, 100 GWei, 500 GWei, max-1, max - Each test case includes expected error value for precise validation - All 11 test cases verify both error returns and gas price state - Tests use isolated pool instances to ensure independence |
||
|---|---|---|
| .. | ||
| bft | ||
| downloader | ||
| ethconfig | ||
| fetcher | ||
| filters | ||
| gasestimator | ||
| gasprice | ||
| hooks | ||
| tracers | ||
| util | ||
| api.go | ||
| api_admin.go | ||
| api_backend.go | ||
| api_debug.go | ||
| api_debug_test.go | ||
| api_miner.go | ||
| backend.go | ||
| backend_test.go | ||
| bloombits.go | ||
| handler.go | ||
| handler_test.go | ||
| helper_test.go | ||
| metrics.go | ||
| peer.go | ||
| protocol.go | ||
| protocol_test.go | ||
| state_accessor.go | ||
| sync.go | ||
| sync_test.go | ||