OSDN Git Service

V0.1 votetx utxo (#73)
[bytom/vapor.git] / wallet / utxo_test.go
index 825bf33..5f9928d 100644 (file)
@@ -18,7 +18,10 @@ import (
 
 func TestGetAccountUtxos(t *testing.T) {
        testDB := dbm.NewDB("testdb", "leveldb", "temp")
-       defer os.RemoveAll("temp")
+       defer func() {
+               testDB.Close()
+               os.RemoveAll("temp")
+       }()
 
        cases := []struct {
                dbUtxos          map[string]*account.UTXO
@@ -207,7 +210,10 @@ func TestGetAccountUtxos(t *testing.T) {
 
 func TestFilterAccountUtxo(t *testing.T) {
        testDB := dbm.NewDB("testdb", "leveldb", "temp")
-       defer os.RemoveAll("temp")
+       defer func() {
+               testDB.Close()
+               os.RemoveAll("temp")
+       }()
 
        cases := []struct {
                dbPrograms map[string]*account.CtrlProgram
@@ -475,6 +481,28 @@ func TestTxInToUtxos(t *testing.T) {
                                },
                        },
                },
+               {
+                       tx: types.NewTx(types.TxData{
+                               Inputs: []*types.TxInput{
+                                       types.NewUnvoteInput([][]byte{}, bc.Hash{V0: 1}, bc.AssetID{V0: 1}, 1, 1, []byte{0x51}, []byte("af594006a40837d9f028daabb6d589df0b9138daefad5683e5233c2646279217294a8d532e60863bcf196625a35fb8ceeffa3c09610eb92dcfb655a947f13269")),
+                               },
+                               Outputs: []*types.TxOutput{
+                                       types.NewIntraChainOutput(bc.AssetID{V0: 1}, 1, []byte{0x51}),
+                               },
+                       }),
+                       statusFail: false,
+                       wantUtxos: []*account.UTXO{
+                               &account.UTXO{
+                                       OutputID:       bc.NewHash([32]byte{0x95, 0x23, 0x06, 0xa5, 0x2f, 0xc4, 0xe2, 0x36, 0x03, 0x0f, 0xe3, 0xe6, 0xb8, 0x0b, 0xcc, 0x3c, 0x1e, 0x17, 0x3e, 0x25, 0x95, 0xd0, 0xbf, 0x08, 0x11, 0x73, 0x06, 0xd4, 0x64, 0x9c, 0xfb, 0x3b}),
+                                       AssetID:        bc.AssetID{V0: 1},
+                                       Amount:         1,
+                                       ControlProgram: []byte{0x51},
+                                       Vote:           []byte("af594006a40837d9f028daabb6d589df0b9138daefad5683e5233c2646279217294a8d532e60863bcf196625a35fb8ceeffa3c09610eb92dcfb655a947f13269"),
+                                       SourceID:       bc.Hash{V0: 1},
+                                       SourcePos:      1,
+                               },
+                       },
+               },
        }
 
        for i, c := range cases {