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