OSDN Git Service

edht tx txoutput (#1966)
[bytom/bytom.git] / wallet / utxo_test.go
index 980d84b..27a1dfc 100644 (file)
@@ -410,7 +410,7 @@ func TestTxInToUtxos(t *testing.T) {
                        statusFail: false,
                        wantUtxos: []*account.UTXO{
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0x73, 0xf6, 0x02, 0xfc, 0x7c, 0x25, 0x98, 0xf4, 0xe6, 0xc5, 0xab, 0xa9, 0x31, 0x9f, 0x70, 0x3d, 0x64, 0x9a, 0xd6, 0x4a, 0xbd, 0x20, 0x5a, 0x72, 0x26, 0xba, 0x36, 0x5c, 0xc7, 0xb5, 0x92, 0xdf}),
+                                       OutputID:       testutil.MustDecodeHash("d7317174b78e6efdd060f19031b9b4d8dfdc8218b8fe7d86324f8c35b9cc572c"),
                                        AssetID:        bc.AssetID{V0: 1},
                                        Amount:         1,
                                        ControlProgram: []byte{0x51},
@@ -418,7 +418,7 @@ func TestTxInToUtxos(t *testing.T) {
                                        SourcePos:      1,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0xb5, 0x53, 0xe5, 0xb3, 0xb2, 0xc0, 0x9d, 0xc1, 0x04, 0x02, 0xd8, 0xc3, 0x99, 0xb7, 0x0e, 0xe1, 0x14, 0xcc, 0xc8, 0xe9, 0x4d, 0x3d, 0x26, 0x51, 0x56, 0xd7, 0xf1, 0xf1, 0x03, 0xfa, 0xc1, 0x4b}),
+                                       OutputID:       testutil.MustDecodeHash("2170b5a9ed124f4c2f691292dc44cc9a5b834c286a39738aa159c646cce14d95"),
                                        AssetID:        bc.AssetID{V0: 1},
                                        Amount:         3,
                                        ControlProgram: []byte{0x52},
@@ -426,7 +426,7 @@ func TestTxInToUtxos(t *testing.T) {
                                        SourcePos:      2,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0xad, 0x0f, 0x82, 0xe6, 0x82, 0xee, 0xc0, 0xf8, 0xef, 0x21, 0xaa, 0x8b, 0xcd, 0xa0, 0x4b, 0x25, 0x58, 0x4d, 0x69, 0x2a, 0x6b, 0x4a, 0x17, 0x0e, 0xd3, 0x4c, 0x1e, 0x2c, 0x57, 0x74, 0x7a, 0x52}),
+                                       OutputID:       testutil.MustDecodeHash("e07a0c076fcee0faccf6fc329875c3273120faaee87d273ff1cea5c64b2fb1e3"),
                                        AssetID:        *consensus.BTMAssetID,
                                        Amount:         5,
                                        ControlProgram: []byte{0x53},
@@ -434,7 +434,7 @@ func TestTxInToUtxos(t *testing.T) {
                                        SourcePos:      3,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0x27, 0x4e, 0x45, 0xa2, 0xd3, 0xe8, 0xe4, 0xb3, 0x54, 0x3c, 0xe2, 0x58, 0xc9, 0xcb, 0xd7, 0xed, 0xd9, 0xe2, 0x83, 0x78, 0xfb, 0x7a, 0xfa, 0xf3, 0x05, 0x29, 0xf9, 0xf1, 0x1e, 0xdb, 0x81, 0x7c}),
+                                       OutputID:       testutil.MustDecodeHash("30fe2e3180356a847f152ce2dabab99ebe8df97ebbf100881d9591527f9fd738"),
                                        AssetID:        *consensus.BTMAssetID,
                                        Amount:         7,
                                        ControlProgram: []byte{0x54},
@@ -457,7 +457,7 @@ func TestTxInToUtxos(t *testing.T) {
                        statusFail: true,
                        wantUtxos: []*account.UTXO{
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0xad, 0x0f, 0x82, 0xe6, 0x82, 0xee, 0xc0, 0xf8, 0xef, 0x21, 0xaa, 0x8b, 0xcd, 0xa0, 0x4b, 0x25, 0x58, 0x4d, 0x69, 0x2a, 0x6b, 0x4a, 0x17, 0x0e, 0xd3, 0x4c, 0x1e, 0x2c, 0x57, 0x74, 0x7a, 0x52}),
+                                       OutputID:       testutil.MustDecodeHash("e07a0c076fcee0faccf6fc329875c3273120faaee87d273ff1cea5c64b2fb1e3"),
                                        AssetID:        *consensus.BTMAssetID,
                                        Amount:         5,
                                        ControlProgram: []byte{0x53},
@@ -465,7 +465,7 @@ func TestTxInToUtxos(t *testing.T) {
                                        SourcePos:      3,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0x27, 0x4e, 0x45, 0xa2, 0xd3, 0xe8, 0xe4, 0xb3, 0x54, 0x3c, 0xe2, 0x58, 0xc9, 0xcb, 0xd7, 0xed, 0xd9, 0xe2, 0x83, 0x78, 0xfb, 0x7a, 0xfa, 0xf3, 0x05, 0x29, 0xf9, 0xf1, 0x1e, 0xdb, 0x81, 0x7c}),
+                                       OutputID:       testutil.MustDecodeHash("30fe2e3180356a847f152ce2dabab99ebe8df97ebbf100881d9591527f9fd738"),
                                        AssetID:        *consensus.BTMAssetID,
                                        Amount:         7,
                                        ControlProgram: []byte{0x54},
@@ -486,6 +486,7 @@ func TestTxInToUtxos(t *testing.T) {
                                data, _ := json.Marshal(v)
                                fmt.Println(k, string(data))
                        }
+
                        t.Errorf("case %d: got %v want %v", i, gotUtxos, c.wantUtxos)
                }
        }
@@ -511,7 +512,7 @@ func TestTxOutToUtxos(t *testing.T) {
                        blockHeight: 0,
                        wantUtxos: []*account.UTXO{
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0x9c, 0xab, 0x55, 0xdc, 0x72, 0xb1, 0x42, 0x6d, 0x2a, 0x41, 0x92, 0xc3, 0x40, 0x32, 0x29, 0xf4, 0xa4, 0x11, 0xae, 0x54, 0x41, 0x54, 0x1a, 0xfe, 0x7c, 0x93, 0x4b, 0x8f, 0x6c, 0x61, 0x69, 0x9f}),
+                                       OutputID:       testutil.MustDecodeHash("5ad31f023737c301190026c6e97da10715d5455d9bb32ace3104454faefd2bb6"),
                                        AssetID:        *consensus.BTMAssetID,
                                        Amount:         41250000000,
                                        ControlProgram: []byte{0x51},
@@ -538,35 +539,35 @@ func TestTxOutToUtxos(t *testing.T) {
                        blockHeight: 0,
                        wantUtxos: []*account.UTXO{
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0x49, 0x33, 0x66, 0x49, 0x4b, 0xaa, 0x57, 0x26, 0xc7, 0x21, 0x74, 0x75, 0x4e, 0x15, 0x59, 0xa4, 0x24, 0xa1, 0x92, 0xda, 0xb1, 0x88, 0x8f, 0xea, 0x51, 0xaf, 0xcf, 0x95, 0x21, 0xab, 0xe4, 0xe2}),
+                                       OutputID:       testutil.MustDecodeHash("55de32fa7e96499be625063bc4c7f66bbe5d7b60f233d3a3d7265a9501c77e96"),
                                        AssetID:        bc.AssetID{V0: 1},
                                        Amount:         2,
                                        ControlProgram: []byte{0x51},
-                                       SourceID:       bc.NewHash([32]byte{0x45, 0xe7, 0xf8, 0x36, 0x9c, 0x5c, 0x79, 0x9c, 0xf5, 0xd7, 0x5b, 0x95, 0x02, 0x77, 0x5e, 0xd6, 0x39, 0x08, 0x03, 0x97, 0x6f, 0xf7, 0x47, 0x54, 0xc6, 0xa4, 0xcf, 0x6e, 0x5b, 0x0b, 0x4e, 0x0b}),
+                                       SourceID:       testutil.MustDecodeHash("c0e16f80a168dad26194f9ba5a4244d9d52e08e4636aa50aa58a5b8d65e969d4"),
                                        SourcePos:      0,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0xca, 0x72, 0xfb, 0x89, 0xfc, 0x83, 0xda, 0x24, 0x01, 0x63, 0x8f, 0xac, 0x5e, 0xd2, 0x84, 0xad, 0x27, 0x6d, 0x41, 0xc0, 0x01, 0x45, 0x93, 0x08, 0x3e, 0x37, 0x8f, 0xe8, 0x00, 0x46, 0x6a, 0xfd}),
+                                       OutputID:       testutil.MustDecodeHash("f256f40aa36df9cf954fdf82d5835815adfd21579289063525c64cff59bc6d96"),
                                        AssetID:        bc.AssetID{V0: 1},
                                        Amount:         3,
                                        ControlProgram: []byte{0x52},
-                                       SourceID:       bc.NewHash([32]byte{0x45, 0xe7, 0xf8, 0x36, 0x9c, 0x5c, 0x79, 0x9c, 0xf5, 0xd7, 0x5b, 0x95, 0x02, 0x77, 0x5e, 0xd6, 0x39, 0x08, 0x03, 0x97, 0x6f, 0xf7, 0x47, 0x54, 0xc6, 0xa4, 0xcf, 0x6e, 0x5b, 0x0b, 0x4e, 0x0b}),
+                                       SourceID:       testutil.MustDecodeHash("c0e16f80a168dad26194f9ba5a4244d9d52e08e4636aa50aa58a5b8d65e969d4"),
                                        SourcePos:      1,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0xb1, 0x7a, 0xbf, 0xa, 0x36, 0x78, 0x76, 0xa3, 0x59, 0xfd, 0xa8, 0x1c, 0x50, 0xba, 0xc4, 0x5f, 0x60, 0xbb, 0x79, 0x6, 0x79, 0x6c, 0x26, 0x1b, 0x7e, 0x73, 0x87, 0x54, 0xbd, 0xbf, 0xe5, 0xd8}),
+                                       OutputID:       testutil.MustDecodeHash("60da633ce48a8bf995a23c040c1b52d543e5818abd7fc0b0faa355cf54acbcca"),
                                        AssetID:        *consensus.BTMAssetID,
                                        Amount:         2,
                                        ControlProgram: []byte{0x53},
-                                       SourceID:       bc.NewHash([32]byte{0x45, 0xe7, 0xf8, 0x36, 0x9c, 0x5c, 0x79, 0x9c, 0xf5, 0xd7, 0x5b, 0x95, 0x02, 0x77, 0x5e, 0xd6, 0x39, 0x08, 0x03, 0x97, 0x6f, 0xf7, 0x47, 0x54, 0xc6, 0xa4, 0xcf, 0x6e, 0x5b, 0x0b, 0x4e, 0x0b}),
+                                       SourceID:       testutil.MustDecodeHash("c0e16f80a168dad26194f9ba5a4244d9d52e08e4636aa50aa58a5b8d65e969d4"),
                                        SourcePos:      2,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0x24, 0xb1, 0x96, 0x33, 0x99, 0xaa, 0xee, 0xbd, 0x88, 0xcb, 0xa2, 0x7f, 0x66, 0xfa, 0x87, 0xa8, 0xce, 0x3, 0x83, 0x7e, 0x18, 0x8e, 0x36, 0xae, 0x92, 0xda, 0xe0, 0x99, 0xa5, 0xec, 0x8f, 0x08}),
+                                       OutputID:       testutil.MustDecodeHash("550c883fd09fdccd4a5671c698d0874de9d713fa0b194f0ddffeae8ae79b57fc"),
                                        AssetID:        *consensus.BTMAssetID,
                                        Amount:         5,
                                        ControlProgram: []byte{0x54},
-                                       SourceID:       bc.NewHash([32]byte{0x45, 0xe7, 0xf8, 0x36, 0x9c, 0x5c, 0x79, 0x9c, 0xf5, 0xd7, 0x5b, 0x95, 0x02, 0x77, 0x5e, 0xd6, 0x39, 0x08, 0x03, 0x97, 0x6f, 0xf7, 0x47, 0x54, 0xc6, 0xa4, 0xcf, 0x6e, 0x5b, 0x0b, 0x4e, 0x0b}),
+                                       SourceID:       testutil.MustDecodeHash("c0e16f80a168dad26194f9ba5a4244d9d52e08e4636aa50aa58a5b8d65e969d4"),
                                        SourcePos:      3,
                                },
                        },
@@ -588,35 +589,35 @@ func TestTxOutToUtxos(t *testing.T) {
                        blockHeight: 0,
                        wantUtxos: []*account.UTXO{
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0x49, 0x33, 0x66, 0x49, 0x4b, 0xaa, 0x57, 0x26, 0xc7, 0x21, 0x74, 0x75, 0x4e, 0x15, 0x59, 0xa4, 0x24, 0xa1, 0x92, 0xda, 0xb1, 0x88, 0x8f, 0xea, 0x51, 0xaf, 0xcf, 0x95, 0x21, 0xab, 0xe4, 0xe2}),
+                                       OutputID:       testutil.MustDecodeHash("55de32fa7e96499be625063bc4c7f66bbe5d7b60f233d3a3d7265a9501c77e96"),
                                        AssetID:        bc.AssetID{V0: 1},
                                        Amount:         2,
                                        ControlProgram: []byte{0x51},
-                                       SourceID:       bc.NewHash([32]byte{0x45, 0xe7, 0xf8, 0x36, 0x9c, 0x5c, 0x79, 0x9c, 0xf5, 0xd7, 0x5b, 0x95, 0x02, 0x77, 0x5e, 0xd6, 0x39, 0x08, 0x03, 0x97, 0x6f, 0xf7, 0x47, 0x54, 0xc6, 0xa4, 0xcf, 0x6e, 0x5b, 0x0b, 0x4e, 0x0b}),
+                                       SourceID:       testutil.MustDecodeHash("c0e16f80a168dad26194f9ba5a4244d9d52e08e4636aa50aa58a5b8d65e969d4"),
                                        SourcePos:      0,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0xca, 0x72, 0xfb, 0x89, 0xfc, 0x83, 0xda, 0x24, 0x01, 0x63, 0x8f, 0xac, 0x5e, 0xd2, 0x84, 0xad, 0x27, 0x6d, 0x41, 0xc0, 0x01, 0x45, 0x93, 0x08, 0x3e, 0x37, 0x8f, 0xe8, 0x00, 0x46, 0x6a, 0xfd}),
+                                       OutputID:       testutil.MustDecodeHash("f256f40aa36df9cf954fdf82d5835815adfd21579289063525c64cff59bc6d96"),
                                        AssetID:        bc.AssetID{V0: 1},
                                        Amount:         3,
                                        ControlProgram: []byte{0x52},
-                                       SourceID:       bc.NewHash([32]byte{0x45, 0xe7, 0xf8, 0x36, 0x9c, 0x5c, 0x79, 0x9c, 0xf5, 0xd7, 0x5b, 0x95, 0x02, 0x77, 0x5e, 0xd6, 0x39, 0x08, 0x03, 0x97, 0x6f, 0xf7, 0x47, 0x54, 0xc6, 0xa4, 0xcf, 0x6e, 0x5b, 0x0b, 0x4e, 0x0b}),
+                                       SourceID:       testutil.MustDecodeHash("c0e16f80a168dad26194f9ba5a4244d9d52e08e4636aa50aa58a5b8d65e969d4"),
                                        SourcePos:      1,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0xb1, 0x7a, 0xbf, 0x0a, 0x36, 0x78, 0x76, 0xa3, 0x59, 0xfd, 0xa8, 0x1c, 0x50, 0xba, 0xc4, 0x5f, 0x60, 0xbb, 0x79, 0x06, 0x79, 0x6c, 0x26, 0x1b, 0x7e, 0x73, 0x87, 0x54, 0xbd, 0xbf, 0xe5, 0xd8}),
+                                       OutputID:       testutil.MustDecodeHash("60da633ce48a8bf995a23c040c1b52d543e5818abd7fc0b0faa355cf54acbcca"),
                                        AssetID:        *consensus.BTMAssetID,
                                        Amount:         2,
                                        ControlProgram: []byte{0x53},
-                                       SourceID:       bc.NewHash([32]byte{0x45, 0xe7, 0xf8, 0x36, 0x9c, 0x5c, 0x79, 0x9c, 0xf5, 0xd7, 0x5b, 0x95, 0x02, 0x77, 0x5e, 0xd6, 0x39, 0x08, 0x03, 0x97, 0x6f, 0xf7, 0x47, 0x54, 0xc6, 0xa4, 0xcf, 0x6e, 0x5b, 0x0b, 0x4e, 0x0b}),
+                                       SourceID:       testutil.MustDecodeHash("c0e16f80a168dad26194f9ba5a4244d9d52e08e4636aa50aa58a5b8d65e969d4"),
                                        SourcePos:      2,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.NewHash([32]byte{0x24, 0xb1, 0x96, 0x33, 0x99, 0xaa, 0xee, 0xbd, 0x88, 0xcb, 0xa2, 0x7f, 0x66, 0xfa, 0x87, 0xa8, 0xce, 0x03, 0x83, 0x7e, 0x18, 0x8e, 0x36, 0xae, 0x92, 0xda, 0xe0, 0x99, 0xa5, 0xec, 0x8f, 0x08}),
+                                       OutputID:       testutil.MustDecodeHash("550c883fd09fdccd4a5671c698d0874de9d713fa0b194f0ddffeae8ae79b57fc"),
                                        AssetID:        *consensus.BTMAssetID,
                                        Amount:         5,
                                        ControlProgram: []byte{0x54},
-                                       SourceID:       bc.NewHash([32]byte{0x45, 0xe7, 0xf8, 0x36, 0x9c, 0x5c, 0x79, 0x9c, 0xf5, 0xd7, 0x5b, 0x95, 0x02, 0x77, 0x5e, 0xd6, 0x39, 0x08, 0x03, 0x97, 0x6f, 0xf7, 0x47, 0x54, 0xc6, 0xa4, 0xcf, 0x6e, 0x5b, 0x0b, 0x4e, 0x0b}),
+                                       SourceID:       testutil.MustDecodeHash("c0e16f80a168dad26194f9ba5a4244d9d52e08e4636aa50aa58a5b8d65e969d4"),
                                        SourcePos:      3,
                                },
                        },
@@ -626,7 +627,6 @@ func TestTxOutToUtxos(t *testing.T) {
        for i, c := range cases {
                if gotUtxos := txOutToUtxos(c.tx, c.blockHeight); !testutil.DeepEqual(gotUtxos, c.wantUtxos) {
                        for k, v := range gotUtxos {
-
                                data, _ := json.Marshal(v)
                                fmt.Println("got:", k, string(data))
                        }
@@ -634,6 +634,7 @@ func TestTxOutToUtxos(t *testing.T) {
                                data, _ := json.Marshal(v)
                                fmt.Println("want:", k, string(data))
                        }
+
                        t.Errorf("case %d: got %v want %v", i, gotUtxos, c.wantUtxos)
                }
        }