mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
ethclient/simulated: fix failing test due the min tip change
This commit is contained in:
parent
27f702311f
commit
264bfafa2b
2 changed files with 18 additions and 2 deletions
|
|
@ -52,7 +52,7 @@ func newTx(sim *Backend, key *ecdsa.PrivateKey) (*types.Transaction, error) {
|
||||||
|
|
||||||
// create a signed transaction to send
|
// create a signed transaction to send
|
||||||
head, _ := client.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
head, _ := client.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
|
||||||
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
|
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(params.GWei))
|
||||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||||
chainid, _ := client.ChainID(context.Background())
|
chainid, _ := client.ChainID(context.Background())
|
||||||
nonce, err := client.PendingNonceAt(context.Background(), addr)
|
nonce, err := client.PendingNonceAt(context.Background(), addr)
|
||||||
|
|
@ -62,7 +62,7 @@ func newTx(sim *Backend, key *ecdsa.PrivateKey) (*types.Transaction, error) {
|
||||||
tx := types.NewTx(&types.DynamicFeeTx{
|
tx := types.NewTx(&types.DynamicFeeTx{
|
||||||
ChainID: chainid,
|
ChainID: chainid,
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
GasTipCap: big.NewInt(1),
|
GasTipCap: big.NewInt(params.GWei),
|
||||||
GasFeeCap: gasPrice,
|
GasFeeCap: gasPrice,
|
||||||
Gas: 21000,
|
Gas: 21000,
|
||||||
To: &addr,
|
To: &addr,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
package simulated
|
package simulated
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
)
|
)
|
||||||
|
|
@ -37,3 +39,17 @@ func WithCallGasLimit(gaslimit uint64) func(nodeConf *node.Config, ethConf *ethc
|
||||||
ethConf.RPCGasCap = gaslimit
|
ethConf.RPCGasCap = gaslimit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithMinerMinTip configures the simulated backend to require a specific minimum
|
||||||
|
// gas tip for a transaction to be included.
|
||||||
|
//
|
||||||
|
// 0 is not possible as a live Geth node would reject that due to DoS protection,
|
||||||
|
// so the simulated backend will replicate that behavior for consisntency.
|
||||||
|
func WithMinerMinTip(tip *big.Int) func(nodeConf *node.Config, ethConf *ethconfig.Config) {
|
||||||
|
if tip == nil || tip.Cmp(new(big.Int)) <= 0 {
|
||||||
|
panic("invalid miner minimum tip")
|
||||||
|
}
|
||||||
|
return func(nodeConf *node.Config, ethConf *ethconfig.Config) {
|
||||||
|
ethConf.Miner.GasPrice = tip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue