|
|
@ -28,11 +28,11 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/crypto" |
|
|
|
"github.com/ethereum/go-ethereum/crypto" |
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/ethdb" |
|
|
|
"github.com/ethereum/go-ethereum/event" |
|
|
|
"github.com/ethereum/go-ethereum/event" |
|
|
|
"github.com/ethereum/go-ethereum/params" |
|
|
|
"github.com/ethereum/go-ethereum/params" |
|
|
|
"github.com/harmony-one/harmony/core/state" |
|
|
|
"github.com/harmony-one/harmony/core/state" |
|
|
|
"github.com/harmony-one/harmony/core/types" |
|
|
|
"github.com/harmony-one/harmony/core/types" |
|
|
|
"github.com/harmony-one/harmony/internal/db" |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// testTxPoolConfig is a transaction pool configuration without stateful disk
|
|
|
|
// testTxPoolConfig is a transaction pool configuration without stateful disk
|
|
|
@ -78,7 +78,7 @@ func pricedTransaction(nonce uint64, gaslimit uint64, gasprice *big.Int, key *ec |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func setupTxPool() (*TxPool, *ecdsa.PrivateKey) { |
|
|
|
func setupTxPool() (*TxPool, *ecdsa.PrivateKey) { |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
|
|
|
|
|
|
|
|
key, _ := crypto.GenerateKey() |
|
|
|
key, _ := crypto.GenerateKey() |
|
|
@ -163,7 +163,7 @@ func (c *testChain) State() (*state.StateDB, error) { |
|
|
|
// a state change between those fetches.
|
|
|
|
// a state change between those fetches.
|
|
|
|
stdb := c.statedb |
|
|
|
stdb := c.statedb |
|
|
|
if *c.trigger { |
|
|
|
if *c.trigger { |
|
|
|
c.statedb, _ = state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
c.statedb, _ = state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
// simulate that the new head block included tx0 and tx1
|
|
|
|
// simulate that the new head block included tx0 and tx1
|
|
|
|
c.statedb.SetNonce(c.address, 2) |
|
|
|
c.statedb.SetNonce(c.address, 2) |
|
|
|
c.statedb.SetBalance(c.address, new(big.Int).SetUint64(params.Ether)) |
|
|
|
c.statedb.SetBalance(c.address, new(big.Int).SetUint64(params.Ether)) |
|
|
@ -181,7 +181,7 @@ func TestStateChangeDuringTransactionPoolReset(t *testing.T) { |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
key, _ = crypto.GenerateKey() |
|
|
|
key, _ = crypto.GenerateKey() |
|
|
|
address = crypto.PubkeyToAddress(key.PublicKey) |
|
|
|
address = crypto.PubkeyToAddress(key.PublicKey) |
|
|
|
statedb, _ = state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ = state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
trigger = false |
|
|
|
trigger = false |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -335,7 +335,7 @@ func TestTransactionChainFork(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
addr := crypto.PubkeyToAddress(key.PublicKey) |
|
|
|
addr := crypto.PubkeyToAddress(key.PublicKey) |
|
|
|
resetState := func() { |
|
|
|
resetState := func() { |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
statedb.AddBalance(addr, big.NewInt(100000000000000)) |
|
|
|
statedb.AddBalance(addr, big.NewInt(100000000000000)) |
|
|
|
|
|
|
|
|
|
|
|
pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
@ -364,7 +364,7 @@ func TestTransactionDoubleNonce(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
addr := crypto.PubkeyToAddress(key.PublicKey) |
|
|
|
addr := crypto.PubkeyToAddress(key.PublicKey) |
|
|
|
resetState := func() { |
|
|
|
resetState := func() { |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
statedb.AddBalance(addr, big.NewInt(100000000000000)) |
|
|
|
statedb.AddBalance(addr, big.NewInt(100000000000000)) |
|
|
|
|
|
|
|
|
|
|
|
pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
@ -554,7 +554,7 @@ func TestTransactionPostponing(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
// Create the pool to test the postponing with
|
|
|
|
// Create the pool to test the postponing with
|
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
|
|
|
|
|
|
|
|
pool := NewTxPool(testTxPoolConfig, params.TestChainConfig, blockchain) |
|
|
|
pool := NewTxPool(testTxPoolConfig, params.TestChainConfig, blockchain) |
|
|
@ -712,7 +712,7 @@ func testTransactionQueueGlobalLimiting(t *testing.T, nolocals bool) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
// Create the pool to test the limit enforcement with
|
|
|
|
// Create the pool to test the limit enforcement with
|
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
|
|
|
|
|
|
|
|
config := testTxPoolConfig |
|
|
|
config := testTxPoolConfig |
|
|
@ -800,7 +800,7 @@ func testTransactionQueueTimeLimiting(t *testing.T, nolocals bool) { |
|
|
|
evictionInterval = time.Second |
|
|
|
evictionInterval = time.Second |
|
|
|
|
|
|
|
|
|
|
|
// Create the pool to test the non-expiration enforcement
|
|
|
|
// Create the pool to test the non-expiration enforcement
|
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
|
|
|
|
|
|
|
|
config := testTxPoolConfig |
|
|
|
config := testTxPoolConfig |
|
|
@ -913,7 +913,7 @@ func TestTransactionPendingGlobalLimiting(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
// Create the pool to test the limit enforcement with
|
|
|
|
// Create the pool to test the limit enforcement with
|
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
|
|
|
|
|
|
|
|
config := testTxPoolConfig |
|
|
|
config := testTxPoolConfig |
|
|
@ -959,7 +959,7 @@ func TestTransactionCapClearsFromAll(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
// Create the pool to test the limit enforcement with
|
|
|
|
// Create the pool to test the limit enforcement with
|
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
|
|
|
|
|
|
|
|
config := testTxPoolConfig |
|
|
|
config := testTxPoolConfig |
|
|
@ -993,7 +993,7 @@ func TestTransactionPendingMinimumAllowance(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
// Create the pool to test the limit enforcement with
|
|
|
|
// Create the pool to test the limit enforcement with
|
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
|
|
|
|
|
|
|
|
config := testTxPoolConfig |
|
|
|
config := testTxPoolConfig |
|
|
@ -1038,7 +1038,7 @@ func TestTransactionPoolRepricingKeepsLocals(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
// Create the pool to test the pricing enforcement with
|
|
|
|
// Create the pool to test the pricing enforcement with
|
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
|
|
|
|
|
|
|
|
pool := NewTxPool(testTxPoolConfig, params.TestChainConfig, blockchain) |
|
|
|
pool := NewTxPool(testTxPoolConfig, params.TestChainConfig, blockchain) |
|
|
@ -1112,7 +1112,7 @@ func testTransactionJournaling(t *testing.T, nolocals bool) { |
|
|
|
os.Remove(journal) |
|
|
|
os.Remove(journal) |
|
|
|
|
|
|
|
|
|
|
|
// Create the original pool to inject transaction into the journal
|
|
|
|
// Create the original pool to inject transaction into the journal
|
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
|
|
|
|
|
|
|
|
config := testTxPoolConfig |
|
|
|
config := testTxPoolConfig |
|
|
@ -1210,7 +1210,7 @@ func TestTransactionStatusCheck(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|
|
|
|
// Create the pool to test the status retrievals with
|
|
|
|
// Create the pool to test the status retrievals with
|
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db.NewMemDatabase())) |
|
|
|
statedb, _ := state.New(common.Hash{}, state.NewDatabase(ethdb.NewMemDatabase())) |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)} |
|
|
|
|
|
|
|
|
|
|
|
pool := NewTxPool(testTxPoolConfig, params.TestChainConfig, blockchain) |
|
|
|
pool := NewTxPool(testTxPoolConfig, params.TestChainConfig, blockchain) |
|
|
|