erigon-pulse/cl/persistence/db_config/db_config_test.go

25 lines
566 B
Go
Raw Normal View History

package db_config
import (
"context"
"testing"
2023-10-18 21:10:53 +00:00
"github.com/ledgerwatch/erigon-lib/kv/memdb"
"github.com/stretchr/testify/require"
2023-09-06 21:20:26 +00:00
_ "modernc.org/sqlite"
)
func TestDBConfig(t *testing.T) {
2023-10-18 21:10:53 +00:00
db := memdb.NewTestDB(t)
defer db.Close()
2023-10-18 21:10:53 +00:00
tx, err := db.BeginRw(context.Background())
defer tx.Rollback()
require.NoError(t, err)
2023-10-18 21:10:53 +00:00
c := DatabaseConfiguration{PruneDepth: 69}
require.NoError(t, WriteConfigurationIfNotExist(context.Background(), tx, c))
cfg, err := ReadConfiguration(context.Background(), tx)
require.NoError(t, err)
require.Equal(t, cfg, c)
}