mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-15 15:28:19 +00:00
tests: one-liner to create tx (#644)
This commit is contained in:
parent
f05cd214bd
commit
cd20a6862f
@ -20,10 +20,9 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon-lib/kv/mdbx"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
)
|
||||
|
||||
func New() kv.RwDB {
|
||||
@ -47,6 +46,26 @@ func NewTestDB(tb testing.TB) kv.RwDB {
|
||||
return db
|
||||
}
|
||||
|
||||
func BeginRw(tb testing.TB, db kv.RwDB) kv.RwTx {
|
||||
tb.Helper()
|
||||
tx, err := db.BeginRw(context.Background())
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
tb.Cleanup(tx.Rollback)
|
||||
return tx
|
||||
}
|
||||
|
||||
func BeginRo(tb testing.TB, db kv.RoDB) kv.Tx {
|
||||
tb.Helper()
|
||||
tx, err := db.BeginRo(context.Background())
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
tb.Cleanup(tx.Rollback)
|
||||
return tx
|
||||
}
|
||||
|
||||
func NewTestPoolDB(tb testing.TB) kv.RwDB {
|
||||
tb.Helper()
|
||||
db := NewPoolDB()
|
||||
|
Loading…
Reference in New Issue
Block a user