2021-06-19 08:21:53 +00:00
|
|
|
package ethdb_test
|
2020-02-13 14:45:02 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
2020-03-11 10:31:49 +00:00
|
|
|
|
|
|
|
"github.com/davecgh/go-spew/spew"
|
2021-06-19 08:21:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/ethdb"
|
|
|
|
"github.com/ledgerwatch/erigon/ethdb/kv"
|
2020-02-13 14:45:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSetStorageModeIfNotExist(t *testing.T) {
|
2021-06-19 08:21:53 +00:00
|
|
|
_, tx := kv.NewTestTx(t)
|
|
|
|
sm, err := ethdb.GetStorageModeFromDB(tx)
|
2020-02-13 14:45:02 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-06-19 08:21:53 +00:00
|
|
|
if !reflect.DeepEqual(sm, ethdb.StorageMode{Initialised: true}) {
|
2020-02-13 14:45:02 +00:00
|
|
|
t.Fatal()
|
|
|
|
}
|
|
|
|
|
2021-06-19 08:21:53 +00:00
|
|
|
err = ethdb.SetStorageModeIfNotExist(tx, ethdb.StorageMode{
|
2020-02-13 14:45:02 +00:00
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
2020-10-12 08:39:04 +00:00
|
|
|
true,
|
2021-05-07 21:07:49 +00:00
|
|
|
true,
|
2021-05-27 13:54:55 +00:00
|
|
|
false,
|
2020-02-13 14:45:02 +00:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-06-19 08:21:53 +00:00
|
|
|
sm, err = ethdb.GetStorageModeFromDB(tx)
|
2020-02-13 14:45:02 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-06-19 08:21:53 +00:00
|
|
|
if !reflect.DeepEqual(sm, ethdb.StorageMode{
|
2020-02-13 14:45:02 +00:00
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
2020-10-12 08:39:04 +00:00
|
|
|
true,
|
2021-05-07 21:07:49 +00:00
|
|
|
true,
|
2021-05-27 13:54:55 +00:00
|
|
|
false,
|
2020-02-13 14:45:02 +00:00
|
|
|
}) {
|
|
|
|
spew.Dump(sm)
|
|
|
|
t.Fatal("not equal")
|
|
|
|
}
|
|
|
|
}
|