diff --git a/vms/avm/txs/mempool/mempool.go b/vms/avm/txs/mempool/mempool.go index 254313322f9b..b4b05a72d2a3 100644 --- a/vms/avm/txs/mempool/mempool.go +++ b/vms/avm/txs/mempool/mempool.go @@ -35,10 +35,10 @@ const ( var ( _ Mempool = (*mempool)(nil) - errDuplicateTx = errors.New("duplicate tx") - errTxTooLarge = errors.New("tx too large") - errMempoolFull = errors.New("mempool is full") - errConflictsWithOtherTx = errors.New("tx conflicts with other tx") + ErrDuplicateTx = errors.New("duplicate tx") + ErrTxTooLarge = errors.New("tx too large") + ErrMempoolFull = errors.New("mempool is full") + ErrConflictsWithOtherTx = errors.New("tx conflicts with other tx") ) // Mempool contains transactions that have not yet been put into a block. @@ -114,13 +114,13 @@ func (m *mempool) Add(tx *txs.Tx) error { defer m.lock.Unlock() if _, ok := m.unissuedTxs.Get(txID); ok { - return fmt.Errorf("%w: %s", errDuplicateTx, txID) + return fmt.Errorf("%w: %s", ErrDuplicateTx, txID) } txSize := len(tx.Bytes()) if txSize > MaxTxSize { return fmt.Errorf("%w: %s size (%d) > max size (%d)", - errTxTooLarge, + ErrTxTooLarge, txID, txSize, MaxTxSize, @@ -128,7 +128,7 @@ func (m *mempool) Add(tx *txs.Tx) error { } if txSize > m.bytesAvailable { return fmt.Errorf("%w: %s size (%d) > available space (%d)", - errMempoolFull, + ErrMempoolFull, txID, txSize, m.bytesAvailable, @@ -137,7 +137,7 @@ func (m *mempool) Add(tx *txs.Tx) error { inputs := tx.Unsigned.InputIDs() if m.consumedUTXOs.Overlaps(inputs) { - return fmt.Errorf("%w: %s", errConflictsWithOtherTx, txID) + return fmt.Errorf("%w: %s", ErrConflictsWithOtherTx, txID) } m.bytesAvailable -= txSize diff --git a/vms/avm/txs/mempool/mempool_test.go b/vms/avm/txs/mempool/mempool_test.go index fff0f9f21248..ae1a75dbba17 100644 --- a/vms/avm/txs/mempool/mempool_test.go +++ b/vms/avm/txs/mempool/mempool_test.go @@ -37,25 +37,25 @@ func TestAdd(t *testing.T) { name: "attempt adding duplicate tx", initialTxs: []*txs.Tx{tx0}, tx: tx0, - err: errDuplicateTx, + err: ErrDuplicateTx, }, { name: "attempt adding too large tx", initialTxs: nil, tx: newTx(0, MaxTxSize+1), - err: errTxTooLarge, + err: ErrTxTooLarge, }, { name: "attempt adding tx when full", initialTxs: newTxs(maxMempoolSize/MaxTxSize, MaxTxSize), tx: newTx(maxMempoolSize/MaxTxSize, MaxTxSize), - err: errMempoolFull, + err: ErrMempoolFull, }, { name: "attempt adding conflicting tx", initialTxs: []*txs.Tx{tx0}, tx: newTx(0, 32), - err: errConflictsWithOtherTx, + err: ErrConflictsWithOtherTx, }, } for _, test := range tests {