mempooltest

package
v0.27.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: ISC Imports: 7 Imported by: 0

Documentation

Overview

Package mempooltest provides test helpers for code that uses the mempool package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockTxMempool

type MockTxMempool struct {
	mock.Mock
}

MockTxMempool is a mock implementation of the TxMempool interface.

func (*MockTxMempool) CheckMempoolAcceptance

func (m *MockTxMempool) CheckMempoolAcceptance(
	tx *btcutil.Tx) (*mempool.MempoolAcceptResult, error)

CheckMempoolAcceptance behaves similarly to bitcoind's `testmempoolaccept` RPC method. It will perform a series of checks to decide whether this transaction can be accepted to the mempool. If not, the specific error is returned and the caller needs to take actions based on it.

func (*MockTxMempool) CheckSpend

func (m *MockTxMempool) CheckSpend(op wire.OutPoint) *btcutil.Tx

CheckSpend checks whether the passed outpoint is already spent by a transaction in the mempool. If that's the case the spending transaction will be returned, if not nil will be returned.

func (*MockTxMempool) Count

func (m *MockTxMempool) Count() int

Count returns the number of transactions in the main pool. It does not include the orphan pool.

func (*MockTxMempool) FetchTransaction

func (m *MockTxMempool) FetchTransaction(
	txHash *chainhash.Hash) (*btcutil.Tx, error)

FetchTransaction returns the requested transaction from the transaction pool. This only fetches from the main transaction pool and does not include orphans.

func (*MockTxMempool) HaveTransaction

func (m *MockTxMempool) HaveTransaction(hash *chainhash.Hash) bool

HaveTransaction returns whether or not the passed transaction already exists in the main pool or in the orphan pool.

func (*MockTxMempool) LastUpdated

func (m *MockTxMempool) LastUpdated() time.Time

LastUpdated returns the last time a transaction was added to or removed from the source pool.

func (*MockTxMempool) ProcessTransaction

func (m *MockTxMempool) ProcessTransaction(tx *btcutil.Tx, allowOrphan,
	rateLimit bool, tag mempool.Tag) ([]*mempool.TxDesc, error)

ProcessTransaction is the main workhorse for handling insertion of new free-standing transactions into the memory pool. It includes functionality such as rejecting duplicate transactions, ensuring transactions follow all rules, orphan transaction handling, and insertion into the memory pool.

func (*MockTxMempool) RawMempoolVerbose

func (m *MockTxMempool) RawMempoolVerbose() map[string]*btcjson.
	GetRawMempoolVerboseResult

RawMempoolVerbose returns all the entries in the mempool as a fully populated btcjson result.

func (*MockTxMempool) RemoveTransaction

func (m *MockTxMempool) RemoveTransaction(tx *btcutil.Tx,
	removeRedeemers bool)

RemoveTransaction removes the passed transaction from the mempool. When the removeRedeemers flag is set, any transactions that redeem outputs from the removed transaction will also be removed recursively from the mempool, as they would otherwise become orphans.

func (*MockTxMempool) TxDescs

func (m *MockTxMempool) TxDescs() []*mempool.TxDesc

TxDescs returns a slice of descriptors for all the transactions in the pool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL