Skip to content

Commit b708614

Browse files
committed
core, les: fix les unit tests (ethereum#19823)
1 parent edaed4f commit b708614

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

core/tx_pool.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,13 +884,13 @@ func (pool *TxPool) AddRemotes(txs []*types.Transaction) []error {
884884
}
885885

886886
// This is like AddRemotes, but waits for pool reorganization. Tests use this method.
887-
func (pool *TxPool) addRemotesSync(txs []*types.Transaction) []error {
887+
func (pool *TxPool) AddRemotesSync(txs []*types.Transaction) []error {
888888
return pool.addTxs(txs, false, true)
889889
}
890890

891891
// This is like AddRemotes with a single transaction, but waits for pool reorganization. Tests use this method.
892-
func (pool *TxPool) addRemoteSync(tx *types.Transaction) error {
893-
errs := pool.addRemotesSync([]*types.Transaction{tx})
892+
func (pool *TxPool) AddRemoteSync(tx *types.Transaction) error {
893+
errs := pool.AddRemotesSync([]*types.Transaction{tx})
894894
return errs[0]
895895
}
896896

core/tx_pool_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func TestStateChangeDuringTransactionPoolReset(t *testing.T) {
220220
t.Fatalf("Invalid nonce, want 0, got %d", nonce)
221221
}
222222

223-
pool.addRemotesSync([]*types.Transaction{tx0, tx1})
223+
pool.AddRemotesSync([]*types.Transaction{tx0, tx1})
224224

225225
nonce = pool.Nonce(address)
226226
if nonce != 2 {
@@ -611,7 +611,7 @@ func TestTransactionPostponing(t *testing.T) {
611611
txs = append(txs, tx)
612612
}
613613
}
614-
for i, err := range pool.addRemotesSync(txs) {
614+
for i, err := range pool.AddRemotesSync(txs) {
615615
if err != nil {
616616
t.Fatalf("tx %d: failed to add transactions: %v", i, err)
617617
}
@@ -707,7 +707,7 @@ func TestTransactionGapFilling(t *testing.T) {
707707
defer sub.Unsubscribe()
708708

709709
// Create a pending and a queued transaction with a nonce-gap in between
710-
pool.addRemotesSync([]*types.Transaction{
710+
pool.AddRemotesSync([]*types.Transaction{
711711
transaction(0, 100000, key),
712712
transaction(2, 100000, key),
713713
})
@@ -725,7 +725,7 @@ func TestTransactionGapFilling(t *testing.T) {
725725
t.Fatalf("pool internal state corrupted: %v", err)
726726
}
727727
// Fill the nonce gap and ensure all transactions become pending
728-
if err := pool.addRemoteSync(transaction(1, 100000, key)); err != nil {
728+
if err := pool.AddRemoteSync(transaction(1, 100000, key)); err != nil {
729729
t.Fatalf("failed to add gapped transaction: %v", err)
730730
}
731731
pending, queued = pool.Stats()
@@ -757,7 +757,7 @@ func TestTransactionQueueAccountLimiting(t *testing.T) {
757757
testTxPoolConfig.AccountQueue = 10
758758
// Keep queuing up transactions and make sure all above a limit are dropped
759759
for i := uint64(1); i <= testTxPoolConfig.AccountQueue; i++ {
760-
if err := pool.addRemoteSync(transaction(i, 100000, key)); err != nil {
760+
if err := pool.AddRemoteSync(transaction(i, 100000, key)); err != nil {
761761
t.Fatalf("tx %d: failed to add transaction: %v", i, err)
762762
}
763763
if len(pool.pending) != 0 {
@@ -826,7 +826,7 @@ func testTransactionQueueGlobalLimiting(t *testing.T, nolocals bool) {
826826
nonces[addr]++
827827
}
828828
// Import the batch and verify that limits have been enforced
829-
pool.addRemotesSync(txs)
829+
pool.AddRemotesSync(txs)
830830

831831
queued := 0
832832
for addr, list := range pool.queue {
@@ -963,7 +963,7 @@ func TestTransactionPendingLimiting(t *testing.T) {
963963

964964
// Keep queuing up transactions and make sure all above a limit are dropped
965965
for i := uint64(0); i < testTxPoolConfig.AccountQueue; i++ {
966-
if err := pool.addRemoteSync(transaction(i, 100000, key)); err != nil {
966+
if err := pool.AddRemoteSync(transaction(i, 100000, key)); err != nil {
967967
t.Fatalf("tx %d: failed to add transaction: %v", i, err)
968968
}
969969
if pool.pending[account].Len() != int(i)+1 {
@@ -1019,7 +1019,7 @@ func TestTransactionPendingGlobalLimiting(t *testing.T) {
10191019
}
10201020
}
10211021
// Import the batch and verify that limits have been enforced
1022-
pool.addRemotesSync(txs)
1022+
pool.AddRemotesSync(txs)
10231023

10241024
pending := 0
10251025
for _, list := range pool.pending {
@@ -1101,7 +1101,7 @@ func TestTransactionPendingMinimumAllowance(t *testing.T) {
11011101
}
11021102
}
11031103
// Import the batch and verify that limits have been enforced
1104-
pool.addRemotesSync(txs)
1104+
pool.AddRemotesSync(txs)
11051105

11061106
for addr, list := range pool.pending {
11071107
if list.Len() != int(config.AccountSlots) {
@@ -1158,7 +1158,7 @@ func TestTransactionPoolRepricing(t *testing.T) {
11581158
ltx := pricedTransaction(0, 100000, big.NewInt(1), keys[3])
11591159

11601160
// Import the batch and that both pending and queued transactions match up
1161-
pool.addRemotesSync(txs)
1161+
pool.AddRemotesSync(txs)
11621162
pool.AddLocal(ltx)
11631163

11641164
pending, queued := pool.Stats()
@@ -1442,7 +1442,7 @@ func TestTransactionPoolStableUnderpricing(t *testing.T) {
14421442
for i := uint64(0); i < config.GlobalSlots; i++ {
14431443
txs = append(txs, pricedTransaction(i, 100000, big.NewInt(1), keys[0]))
14441444
}
1445-
pool.addRemotesSync(txs)
1445+
pool.AddRemotesSync(txs)
14461446

14471447
pending, queued := pool.Stats()
14481448
if pending != int(config.GlobalSlots) {
@@ -1458,7 +1458,7 @@ func TestTransactionPoolStableUnderpricing(t *testing.T) {
14581458
t.Fatalf("pool internal state corrupted: %v", err)
14591459
}
14601460
// Ensure that adding high priced transactions drops a cheap, but doesn't produce a gap
1461-
if err := pool.addRemoteSync(pricedTransaction(0, 100000, big.NewInt(3), keys[1])); err != nil {
1461+
if err := pool.AddRemoteSync(pricedTransaction(0, 100000, big.NewInt(3), keys[1])); err != nil {
14621462
t.Fatalf("failed to add well priced transaction: %v", err)
14631463
}
14641464
pending, queued = pool.Stats()
@@ -1502,7 +1502,7 @@ func TestTransactionReplacement(t *testing.T) {
15021502
price := int64(100)
15031503
threshold := (price * (100 + int64(testTxPoolConfig.PriceBump))) / 100
15041504

1505-
if err := pool.addRemoteSync(pricedTransaction(0, 100000, big.NewInt(1), key)); err != nil {
1505+
if err := pool.AddRemoteSync(pricedTransaction(0, 100000, big.NewInt(1), key)); err != nil {
15061506
t.Fatalf("failed to add original cheap pending transaction: %v", err)
15071507
}
15081508
if err := pool.AddRemote(pricedTransaction(0, 100001, big.NewInt(1), key)); err != ErrReplaceUnderpriced {
@@ -1515,7 +1515,7 @@ func TestTransactionReplacement(t *testing.T) {
15151515
t.Fatalf("cheap replacement event firing failed: %v", err)
15161516
}
15171517

1518-
if err := pool.addRemoteSync(pricedTransaction(0, 100000, big.NewInt(price), key)); err != nil {
1518+
if err := pool.AddRemoteSync(pricedTransaction(0, 100000, big.NewInt(price), key)); err != nil {
15191519
t.Fatalf("failed to add original proper pending transaction: %v", err)
15201520
}
15211521
if err := pool.AddRemote(pricedTransaction(0, 100001, big.NewInt(threshold-1), key)); err != ErrReplaceUnderpriced {
@@ -1606,7 +1606,7 @@ func testTransactionJournaling(t *testing.T, nolocals bool) {
16061606
if err := pool.AddLocal(pricedTransaction(2, 100000, big.NewInt(1), local)); err != nil {
16071607
t.Fatalf("failed to add local transaction: %v", err)
16081608
}
1609-
if err := pool.addRemoteSync(pricedTransaction(0, 100000, big.NewInt(1), remote)); err != nil {
1609+
if err := pool.AddRemoteSync(pricedTransaction(0, 100000, big.NewInt(1), remote)); err != nil {
16101610
t.Fatalf("failed to add remote transaction: %v", err)
16111611
}
16121612
pending, queued := pool.Stats()
@@ -1699,7 +1699,7 @@ func TestTransactionStatusCheck(t *testing.T) {
16991699
txs = append(txs, pricedTransaction(2, 100000, big.NewInt(1), keys[2])) // Queued only
17001700

17011701
// Import the transaction and ensure they are correctly added
1702-
pool.addRemotesSync(txs)
1702+
pool.AddRemotesSync(txs)
17031703

17041704
pending, queued := pool.Stats()
17051705
if pending != 2 {

les/handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ type BlockChain interface {
9191

9292
type txPool interface {
9393
AddRemotes(txs []*types.Transaction) []error
94+
AddRemotesSync(txs []*types.Transaction) []error
9495
Status(hashes []common.Hash) []core.TxStatus
9596
}
9697

0 commit comments

Comments
 (0)