go-ethereum/eth
Daniel Liu 835579e304
core/txpool: add validation and comprehensive tests for SetGasPrice (#1876)
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
2025-12-23 15:40:24 +05:30
..
bft all: fix goimports (#1560) 2025-09-24 07:51:10 +08:00
downloader all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
ethconfig eth/ethconfig: update file gen_config.go (#1822) 2025-12-08 12:54:20 +05:30
fetcher all: fix whitespace error of golangci-lint, remove extra empty lines (#1676) 2025-11-17 11:16:09 +05:30
filters all: use FinalizedBlockNumber instead of CommittedBlockNumber (#1847) 2025-12-11 16:19:51 +05:30
gasestimator internal/ethapi: eth_simulateV1 #27720 (#1606) 2025-11-08 16:09:18 +05:30
gasprice all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
hooks all: use 0x-prefix string for type Address in log message (#1874) 2025-12-19 08:55:21 +04:00
tracers core, eth/tracers: support debug_traceCall for special tx, fix #1870 (#1872) 2025-12-22 12:02:05 +05:30
util feat: add TIPEpochHalving, better style 2025-03-25 22:16:35 +08:00
api.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
api_admin.go eth: split api.go into namespace based files #27263 (#1601) 2025-10-30 21:27:14 +05:30
api_backend.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
api_debug.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
api_debug_test.go eth: use slices package for sorting #27490 (#1702) 2025-12-07 15:43:37 +05:30
api_miner.go core/txpool: add validation and comprehensive tests for SetGasPrice (#1876) 2025-12-23 15:40:24 +05:30
backend.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
backend_test.go Move consensus hooks to its own package 2021-10-10 16:04:32 +11:00
bloombits.go core, eth, params: make indexer configurable (#17188) 2025-03-10 15:41:53 +08:00
handler.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
handler_test.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
helper_test.go core: move genesis alloc types to core/types (#29003) 2025-01-24 16:54:12 +08:00
metrics.go metrics, cmd/XDC: change init-process of metrics (#30814) 2024-12-13 14:00:14 +08:00
peer.go all: use github.com/deckarep/golang-set/v2 (generic set) (#26159) 2025-01-24 16:54:11 +08:00
protocol.go core: remove unused error from TxPool.Pending (#23720) 2024-11-01 11:36:53 +08:00
protocol_test.go all: use WaigGroup.Go() to simplify code (#1699) 2025-11-29 17:17:08 +05:30
state_accessor.go all: rework trc21 (#1777) 2025-11-18 11:24:56 +05:30
sync.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
sync_test.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00