From b0b3cf2eeb74e45b373d4708375e899688c7f9c8 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 22 Jun 2017 10:14:31 +0200 Subject: core: add testcase for txpool --- core/tx_pool.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core/tx_pool.go') diff --git a/core/tx_pool.go b/core/tx_pool.go index 04ffa8a98..86a2ed232 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -301,6 +301,19 @@ func (pool *TxPool) Stats() (int, int) { return pool.stats() } +// validateInternals checks if the content in pool.all +// is consistent with the numbers reported in pending and queued +func (pool *TxPool) validateInternals() error { + pool.mu.RLock() + defer pool.mu.RUnlock() + p, q := pool.stats() + a := len(pool.all) + if a != p+q { + return fmt.Errorf("Pool.all size %d != %d pending + %d queued", a, p, q) + } + return nil +} + // stats retrieves the current pool stats, namely the number of pending and the // number of queued (non-executable) transactions. func (pool *TxPool) stats() (int, int) { -- cgit v1.2.3