diff options
author | gary rong <garyrong0905@gmail.com> | 2019-07-22 20:45:40 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-07-22 20:45:40 +0800 |
commit | b80c840af33aae1ff99ce9879fecc6161a0c1620 (patch) | |
tree | d7cf356018f011c60f264d76ba2c7722c56feb67 /les | |
parent | a32a2b933ad6793a2fe4172cd46c5c5906da259a (diff) | |
download | go-tangerine-b80c840af33aae1ff99ce9879fecc6161a0c1620.tar go-tangerine-b80c840af33aae1ff99ce9879fecc6161a0c1620.tar.gz go-tangerine-b80c840af33aae1ff99ce9879fecc6161a0c1620.tar.bz2 go-tangerine-b80c840af33aae1ff99ce9879fecc6161a0c1620.tar.lz go-tangerine-b80c840af33aae1ff99ce9879fecc6161a0c1620.tar.xz go-tangerine-b80c840af33aae1ff99ce9879fecc6161a0c1620.tar.zst go-tangerine-b80c840af33aae1ff99ce9879fecc6161a0c1620.zip |
core, les: fix les unit tests (#19823)
Diffstat (limited to 'les')
-rw-r--r-- | les/handler.go | 11 | ||||
-rw-r--r-- | les/handler_test.go | 1 | ||||
-rwxr-xr-x | les/transactions.rlp | 0 |
3 files changed, 11 insertions, 1 deletions
diff --git a/les/handler.go b/les/handler.go index 743776bd0..53e2911e4 100644 --- a/les/handler.go +++ b/les/handler.go @@ -85,6 +85,7 @@ type BlockChain interface { type txPool interface { AddRemotes(txs []*types.Transaction) []error + AddRemotesSync(txs []*types.Transaction) []error Status(hashes []common.Hash) []core.TxStatus } @@ -125,6 +126,9 @@ type ProtocolManager struct { // Callbacks synced func() bool + + // Testing fields + addTxsSync bool } // NewProtocolManager returns a new ethereum sub protocol manager. The Ethereum sub protocol manages peers capable @@ -1044,7 +1048,12 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { hash := tx.Hash() stats[i] = pm.txStatus(hash) if stats[i].Status == core.TxStatusUnknown { - if errs := pm.txpool.AddRemotes([]*types.Transaction{tx}); errs[0] != nil { + addFn := pm.txpool.AddRemotes + // Add txs synchronously for testing purpose + if pm.addTxsSync { + addFn = pm.txpool.AddRemotesSync + } + if errs := addFn([]*types.Transaction{tx}); errs[0] != nil { stats[i].Error = errs[0].Error() continue } diff --git a/les/handler_test.go b/les/handler_test.go index 4e16a8979..dae583f6d 100644 --- a/les/handler_test.go +++ b/les/handler_test.go @@ -496,6 +496,7 @@ func TestGetBloombitsProofs(t *testing.T) { func TestTransactionStatusLes2(t *testing.T) { server, tearDown := newServerEnv(t, 0, 2, nil) defer tearDown() + server.pm.addTxsSync = true chain := server.pm.blockchain.(*core.BlockChain) config := core.DefaultTxPoolConfig diff --git a/les/transactions.rlp b/les/transactions.rlp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/les/transactions.rlp |