lotus/lib/statestore/store_test.go

39 lines
610 B
Go
Raw Normal View History

2019-11-05 18:19:57 +00:00
package statestore
import (
"testing"
"github.com/ipfs/go-datastore"
"github.com/filecoin-project/lotus/chain/types"
2019-11-07 14:11:39 +00:00
"github.com/filecoin-project/lotus/lib/cborutil"
2019-11-05 18:19:57 +00:00
)
func TestList(t *testing.T) {
ds := datastore.NewMapDatastore()
2019-11-07 14:11:39 +00:00
e, err := cborutil.Dump(types.NewInt(7))
2019-11-05 18:19:57 +00:00
if err != nil {
t.Fatal(err)
}
if err := ds.Put(datastore.NewKey("/2"), e); err != nil {
t.Fatal(err)
}
2019-11-05 18:40:51 +00:00
st := &StateStore{ds: ds}
2019-11-05 18:19:57 +00:00
var out []types.BigInt
if err := st.List(&out); err != nil {
t.Fatal(err)
}
if len(out) != 1 {
t.Fatal("wrong len")
}
if out[0].Int64() != 7 {
t.Fatal("wrong data")
}
}