From 088492f58bf23b07d8d4ed3c8585dd5e7dbfa48d Mon Sep 17 00:00:00 2001 From: Facundo Date: Fri, 21 Feb 2025 11:32:30 +0100 Subject: [PATCH] missing godoc --- test/dummy.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/dummy.go b/test/dummy.go index 0e0dd81..f290826 100644 --- a/test/dummy.go +++ b/test/dummy.go @@ -60,6 +60,24 @@ func (e *DummyExecutor) InitChain(ctx context.Context, genesisTime time.Time, in return e.stateRoot, e.maxBytes, nil } +// GetTxs returns the list of transactions (types.Tx) within the DummyExecutor instance and an error if any. +func (e *DummyExecutor) GetTxs(context.Context) ([]types.Tx, error) { + e.mu.RLock() + defer e.mu.RUnlock() + + txs := make([]types.Tx, len(e.injectedTxs)) + copy(txs, e.injectedTxs) + return txs, nil +} + +// InjectTx adds a transaction to the internal list of injected transactions in the DummyExecutor instance. +func (e *DummyExecutor) InjectTx(tx types.Tx) { + e.mu.Lock() + defer e.mu.Unlock() + + e.injectedTxs = append(e.injectedTxs, tx) +} + // ExecuteTxs simulate execution of transactions. func (e *DummyExecutor) ExecuteTxs(ctx context.Context, txs []types.Tx, blockHeight uint64, timestamp time.Time, prevStateRoot types.Hash) (types.Hash, uint64, error) { e.mu.Lock() @@ -111,24 +129,6 @@ func (e *DummyExecutor) SetFinal(ctx context.Context, blockHeight uint64) error return types.ErrBlockNotFound } -// GetTxs returns the list of transactions (types.Tx) within the DummyExecutor instance and an error if any. -func (e *DummyExecutor) GetTxs(context.Context) ([]types.Tx, error) { - e.mu.RLock() - defer e.mu.RUnlock() - - txs := make([]types.Tx, len(e.injectedTxs)) - copy(txs, e.injectedTxs) - return txs, nil -} - -// InjectTx adds a transaction to the internal list of injected transactions in the DummyExecutor instance. -func (e *DummyExecutor) InjectTx(tx types.Tx) { - e.mu.Lock() - defer e.mu.Unlock() - - e.injectedTxs = append(e.injectedTxs, tx) -} - func (e *DummyExecutor) removeExecutedTxs(txs []types.Tx) { e.injectedTxs = slices.DeleteFunc(e.injectedTxs, func(tx types.Tx) bool { return slices.ContainsFunc(txs, func(t types.Tx) bool { return bytes.Equal(tx, t) })