core: add testcase for txpool

This commit is contained in:
Martin Holst Swende
2017-06-22 10:14:31 +02:00
committed by Péter Szilágyi
parent 58a1e13e6d
commit b0b3cf2eeb
2 changed files with 79 additions and 0 deletions

View File

@ -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) {