2020-06-09 13:11:09 +00:00
|
|
|
package ethdb
|
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"
|
2020-02-13 14:45:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSetStorageModeIfNotExist(t *testing.T) {
|
2021-05-23 05:41:42 +00:00
|
|
|
_, tx := NewTestTx(t)
|
|
|
|
sm, err := GetStorageModeFromDB(tx)
|
2020-02-13 14:45:02 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-05-08 22:07:16 +00:00
|
|
|
if !reflect.DeepEqual(sm, StorageMode{Initialised: true}) {
|
2020-02-13 14:45:02 +00:00
|
|
|
t.Fatal()
|
|
|
|
}
|
|
|
|
|
2021-05-23 05:41:42 +00:00
|
|
|
err = SetStorageModeIfNotExist(tx, 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-05-23 05:41:42 +00:00
|
|
|
sm, err = GetStorageModeFromDB(tx)
|
2020-02-13 14:45:02 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(sm, StorageMode{
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|