mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/txpool/legacypool: add testcase for expensive tx
This commit is contained in:
parent
bab22bc7a8
commit
9f164a6326
1 changed files with 17 additions and 0 deletions
|
|
@ -17,9 +17,11 @@
|
||||||
package legacypool
|
package legacypool
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
|
|
@ -51,6 +53,21 @@ func TestStrictListAdd(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestListAddVeryExpensive tests adding txs which exceed 256 bits in cost. It is
|
||||||
|
// expected that the list does not panic.
|
||||||
|
func TestListAddVeryExpensive(t *testing.T) {
|
||||||
|
key, _ := crypto.GenerateKey()
|
||||||
|
list := newList(true)
|
||||||
|
for i := 0; i < 3; i++ {
|
||||||
|
value := big.NewInt(100)
|
||||||
|
gasprice, _ := new(big.Int).SetString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 0)
|
||||||
|
gaslimit := uint64(i)
|
||||||
|
tx, _ := types.SignTx(types.NewTransaction(uint64(i), common.Address{}, value, gaslimit, gasprice, nil), types.HomesteadSigner{}, key)
|
||||||
|
t.Logf("cost: %x bitlen: %d\n", tx.Cost(), tx.Cost().BitLen())
|
||||||
|
list.Add(tx, DefaultConfig.PriceBump)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkListAdd(b *testing.B) {
|
func BenchmarkListAdd(b *testing.B) {
|
||||||
// Generate a list of transactions to insert
|
// Generate a list of transactions to insert
|
||||||
key, _ := crypto.GenerateKey()
|
key, _ := crypto.GenerateKey()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue