2020-02-13 14:45:02 +00:00
|
|
|
package eth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
2020-03-11 10:31:49 +00:00
|
|
|
|
|
|
|
"github.com/davecgh/go-spew/spew"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
2020-02-13 14:45:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSetStorageModeIfNotExist(t *testing.T) {
|
|
|
|
db := ethdb.NewMemDatabase()
|
|
|
|
sm, err := getStorageModeFromDB(db)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(sm, StorageMode{}) {
|
|
|
|
t.Fatal()
|
|
|
|
}
|
|
|
|
|
|
|
|
err = setStorageModeIfNotExist(db, StorageMode{
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
sm, err = getStorageModeFromDB(db)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(sm, StorageMode{
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
}) {
|
|
|
|
spew.Dump(sm)
|
|
|
|
t.Fatal("not equal")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|