}
if !testutil.DeepEqual(gotState, c.state) {
- t.Errorf("case %v: got Delete Recovery Status, got: %v, want: %v.", i, gotState, c.state)
+ t.Errorf("case %v: got recovery status, got: %v, want: %v.", i, gotState, c.state)
}
ws = walletStore.InitBatch()
os.RemoveAll("temp")
}
}
+
+func TestGetWalletInfo(t *testing.T) {
+ cases := []struct {
+ state *wallet.StatusInfo
+ }{
+ {
+ state: &wallet.StatusInfo{},
+ },
+ {
+ state: &wallet.StatusInfo{
+ Version: uint(0),
+ WorkHeight: uint64(9),
+ WorkHash: bc.NewHash([32]byte{0x01, 0x01, 0x51, 0x31, 0x71, 0x30, 0xd4, 0x3b, 0x3d, 0xe3, 0xdd, 0x80, 0x67, 0x29, 0x9a, 0x5e, 0x09, 0xf9, 0xfb, 0x2b, 0xad, 0x5f, 0x92, 0xc8, 0x69, 0xd1, 0x42, 0x39, 0x74, 0x9a, 0xd1, 0x1c}),
+ BestHash: bc.NewHash([32]byte{0x01, 0x01, 0x51, 0x31, 0x71, 0x30, 0xd4, 0x3b, 0x3d, 0xe3, 0xdd, 0x80, 0x67, 0x29, 0x9a, 0x5e, 0x09, 0xf9, 0xfb, 0x2b, 0xad, 0x5f, 0x92, 0xc8, 0x69, 0xd1, 0x42, 0x39, 0x74, 0x9a, 0xd1, 0x1c}),
+ BestHeight: uint64(0),
+ },
+ },
+ {
+ state: &wallet.StatusInfo{
+ Version: uint(9),
+ WorkHeight: uint64(9999999),
+ WorkHash: bc.NewHash([32]byte{0x01, 0x01, 0x51, 0x31, 0x71, 0x30, 0xd4, 0x3b, 0x3d, 0xe3, 0xdd, 0x80, 0x67, 0x29, 0x9a, 0x5e, 0x09, 0xf9, 0xfb, 0x2b, 0xad, 0x5f, 0x92, 0xc8, 0x69, 0xd1, 0x42, 0x39, 0x74, 0x9a, 0xd1, 0x1c}),
+ BestHash: bc.NewHash([32]byte{0x01, 0x01, 0x51, 0x31, 0x71, 0x30, 0xd4, 0x3b, 0x3d, 0xe3, 0xdd, 0x80, 0x67, 0x29, 0x9a, 0x5e, 0x09, 0xf9, 0xfb, 0x2b, 0xad, 0x5f, 0x92, 0xc8, 0x69, 0xd1, 0x42, 0x39, 0x74, 0x9a, 0xd1, 0x1c}),
+ BestHeight: uint64(100000),
+ },
+ },
+ }
+
+ for i, c := range cases {
+ testDB := dbm.NewDB("testdb", "leveldb", "temp")
+ walletStore := NewWalletStore(testDB)
+ ws := walletStore.InitBatch()
+ if err := ws.SetWalletInfo(c.state); err != nil {
+ t.Fatal(err)
+ }
+
+ if err := ws.CommitBatch(); err != nil {
+ t.Fatal(err)
+ }
+
+ gotState, err := ws.GetWalletInfo()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if !testutil.DeepEqual(gotState, c.state) {
+ t.Errorf("case %v: got wallet info, got: %v, want: %v.", i, gotState, c.state)
+ }
+
+ testDB.Close()
+ os.RemoveAll("temp")
+ }
+}