OSDN Git Service

update
authorChengcheng Zhang <943420582@qq.com>
Wed, 3 Jul 2019 14:57:43 +0000 (22:57 +0800)
committerChengcheng Zhang <943420582@qq.com>
Wed, 3 Jul 2019 14:57:43 +0000 (22:57 +0800)
test/mock/wallet_store.go
wallet/utxo.go
wallet/utxo_test.go

index 69d62f0..c2b4b43 100644 (file)
@@ -365,7 +365,6 @@ func (store *MockWalletStore) GetWalletInfo() []byte {
 
 // ListAccountUTXOs get all account unspent outputs
 func (store *MockWalletStore) ListAccountUTXOs(key string) ([]*acc.UTXO, error) {
-       fmt.Println("ListAccountUTXOs []byte(key):", []byte(key))
        accountUtxoIter := store.walletDB.IteratorPrefix([]byte(key))
        defer accountUtxoIter.Release()
 
index ed17049..a32baaa 100644 (file)
@@ -25,9 +25,11 @@ func (w *Wallet) GetAccountUtxos(accountID string, id string, unconfirmed, isSma
        if unconfirmed {
                accountUtxos = w.AccountMgr.ListUnconfirmedUtxo(accountID, isSmartContract)
        }
-       idBytes, _ := hex.DecodeString(id)
+       idBytes, err := hex.DecodeString(id)
+       if err != nil {
+               log.WithFields(log.Fields{"module": logModule, "err": err}).Error("GetAccountUtxos fail.")
+       }
 
-       // confirmedUTXOs, err := w.store.ListAccountUTXOs(string(prefix) + id)
        confirmedUTXOs, err := w.store.ListAccountUTXOs(string(append(prefix, idBytes...)))
        if err != nil {
                log.WithFields(log.Fields{"module": logModule, "err": err}).Error("GetAccountUtxos fail.")
index 30c55c8..aea08db 100644 (file)
@@ -107,19 +107,6 @@ func TestGetAccountUtxos(t *testing.T) {
                                string(mock.StandardUTXOKey(bc.Hash{V0: 2, V1: 2})): &account.UTXO{
                                        OutputID: bc.Hash{V0: 2, V1: 2},
                                },
-
-                               // hex.EncodeToString(mock.StandardUTXOKey(bc.Hash{V0: 1})): &account.UTXO{
-                               //      OutputID: bc.Hash{V0: 1},
-                               // },
-                               // hex.EncodeToString(mock.StandardUTXOKey(bc.Hash{V0: 1, V1: 2})): &account.UTXO{
-                               //      OutputID: bc.Hash{V0: 1, V1: 2},
-                               // },
-                               // hex.EncodeToString(mock.StandardUTXOKey(bc.Hash{V0: 2})): &account.UTXO{
-                               //      OutputID: bc.Hash{V0: 2},
-                               // },
-                               // hex.EncodeToString(mock.StandardUTXOKey(bc.Hash{V0: 2, V1: 2})): &account.UTXO{
-                               //      OutputID: bc.Hash{V0: 2, V1: 2},
-                               // },
                        },
                        unconfirmedUtxos: []*account.UTXO{
                                &account.UTXO{
@@ -208,10 +195,6 @@ func TestGetAccountUtxos(t *testing.T) {
                        if err != nil {
                                t.Error(err)
                        }
-                       fmt.Println("k:", []byte(k))
-                       // newKey, _ := hex.DecodeString(k)
-                       // fmt.Println("newkey:", newKey)
-                       // testDB.Set([]byte(k), data)
                        testDB.Set([]byte(k), data)
                }
 
@@ -224,8 +207,6 @@ func TestGetAccountUtxos(t *testing.T) {
                }
 
                for k := range c.dbUtxos {
-                       // newKey, _ := hex.DecodeString(k)
-                       // testDB.Delete([]byte(k))
                        testDB.Delete([]byte(k))
                }
        }