OSDN Git Service

get BlockNode from database (#188)
[bytom/vapor.git] / wallet / utxo_test.go
index 4f76dd5..86450ba 100644 (file)
@@ -524,7 +524,7 @@ func TestTxOutToUtxos(t *testing.T) {
        cases := []struct {
                tx          *types.Tx
                statusFail  bool
-               vaildHeight uint64
+               blockHeight uint64
                wantUtxos   []*account.UTXO
        }{
                {
@@ -537,7 +537,7 @@ func TestTxOutToUtxos(t *testing.T) {
                                },
                        }),
                        statusFail:  false,
-                       vaildHeight: 98,
+                       blockHeight: 98,
                        wantUtxos: []*account.UTXO{
                                &account.UTXO{
                                        OutputID:       bc.Hash{V0: 1728735075694344097, V1: 884766857607786922, V2: 12293210594955921685, V3: 11109045974561998790},
@@ -546,7 +546,7 @@ func TestTxOutToUtxos(t *testing.T) {
                                        ControlProgram: []byte{0x51},
                                        SourceID:       bc.NewHash([32]byte{0xb4, 0x7e, 0x94, 0x31, 0x88, 0xfe, 0xd3, 0xe9, 0xac, 0x99, 0x7c, 0xfc, 0x99, 0x6d, 0xd7, 0x4d, 0x04, 0x10, 0x77, 0xcb, 0x1c, 0xf8, 0x95, 0x14, 0x00, 0xe3, 0x42, 0x00, 0x8d, 0x05, 0xec, 0xdc}),
                                        SourcePos:      0,
-                                       ValidHeight:    98,
+                                       ValidHeight:    198,
                                },
                        },
                },
@@ -564,7 +564,7 @@ func TestTxOutToUtxos(t *testing.T) {
                                },
                        }),
                        statusFail:  false,
-                       vaildHeight: 0,
+                       blockHeight: 0,
                        wantUtxos: []*account.UTXO{
                                &account.UTXO{
                                        OutputID:       bc.Hash{V0: 8675398163687045889, V1: 7549510466747714094, V2: 13693077838209211470, V3: 6878568403630757599},
@@ -614,7 +614,7 @@ func TestTxOutToUtxos(t *testing.T) {
                                },
                        }),
                        statusFail:  true,
-                       vaildHeight: 0,
+                       blockHeight: 0,
                        wantUtxos: []*account.UTXO{
                                &account.UTXO{
                                        OutputID:       bc.Hash{V0: 7067560744282869147, V1: 8991714784298240423, V2: 2595857933262917893, V3: 11490631006811252506},
@@ -648,7 +648,7 @@ func TestTxOutToUtxos(t *testing.T) {
                                },
                        }),
                        statusFail:  false,
-                       vaildHeight: 0,
+                       blockHeight: 0,
                        wantUtxos: []*account.UTXO{
                                &account.UTXO{
                                        OutputID:       bc.Hash{V0: 8675398163687045889, V1: 7549510466747714094, V2: 13693077838209211470, V3: 6878568403630757599},
@@ -671,8 +671,8 @@ func TestTxOutToUtxos(t *testing.T) {
                {
                        tx: types.NewTx(types.TxData{
                                Inputs: []*types.TxInput{
-                                       types.NewCrossChainInput([][]byte{}, bc.Hash{V0: 1}, bc.AssetID{V0: 1}, 5, 1, []byte{0x51}, []byte("asset1")),
-                                       types.NewCrossChainInput([][]byte{}, bc.Hash{V0: 2}, *consensus.BTMAssetID, 7, 1, []byte{0x51}, []byte("assetbtm"))},
+                                       types.NewCrossChainInput([][]byte{}, bc.Hash{V0: 1}, bc.AssetID{V0: 1}, 5, 1, 1, []byte("asset1"), []byte("IssuanceProgram")),
+                                       types.NewCrossChainInput([][]byte{}, bc.Hash{V0: 2}, *consensus.BTMAssetID, 7, 1, 1, []byte("assetbtm"), []byte("IssuanceProgram"))},
                                Outputs: []*types.TxOutput{
                                        types.NewIntraChainOutput(bc.AssetID{V0: 1}, 2, []byte{0x51}),
                                        types.NewIntraChainOutput(bc.AssetID{V0: 1}, 3, []byte{0x52}),
@@ -681,38 +681,38 @@ func TestTxOutToUtxos(t *testing.T) {
                                },
                        }),
                        statusFail:  false,
-                       vaildHeight: 0,
+                       blockHeight: 0,
                        wantUtxos: []*account.UTXO{
                                &account.UTXO{
-                                       OutputID:       bc.Hash{V0: 396952592194652166, V1: 9806684391645699244, V2: 484243382648745315, V3: 16988093808435014689},
+                                       OutputID:       bc.Hash{V0: 5429526025956869574, V1: 12188959875155232503, V2: 14722092106507294798, V3: 27876074648890075},
                                        AssetID:        bc.AssetID{V0: 1},
                                        Amount:         2,
                                        ControlProgram: []byte{0x51},
-                                       SourceID:       bc.Hash{V0: 15256474482236132139, V1: 14615963227748152009, V2: 1392768713126269609, V3: 3435801067785833027},
+                                       SourceID:       bc.Hash{V0: 10187915247323429348, V1: 4770401581694266753, V2: 4182269187154655368, V3: 9030883832705174512},
                                        SourcePos:      0,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.Hash{V0: 10880631720641638863, V1: 7783872056988487492, V2: 10925792818362846534, V3: 16483659407709834456},
+                                       OutputID:       bc.Hash{V0: 18100481287404207387, V1: 3365694797435565990, V2: 8136211093499423216, V3: 12028531817690438568},
                                        AssetID:        bc.AssetID{V0: 1},
                                        Amount:         3,
                                        ControlProgram: []byte{0x52},
-                                       SourceID:       bc.Hash{V0: 15256474482236132139, V1: 14615963227748152009, V2: 1392768713126269609, V3: 3435801067785833027},
+                                       SourceID:       bc.Hash{V0: 10187915247323429348, V1: 4770401581694266753, V2: 4182269187154655368, V3: 9030883832705174512},
                                        SourcePos:      1,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.Hash{V0: 6688768820716928311, V1: 7640171490156205612, V2: 6082620342644961312, V3: 6194446985740174532},
+                                       OutputID:       bc.Hash{V0: 15745816911932387102, V1: 5035893487696724781, V2: 10084725527786878517, V3: 11270352747873435606},
                                        AssetID:        *consensus.BTMAssetID,
                                        Amount:         2,
                                        ControlProgram: []byte{0x53},
-                                       SourceID:       bc.Hash{V0: 15256474482236132139, V1: 14615963227748152009, V2: 1392768713126269609, V3: 3435801067785833027},
+                                       SourceID:       bc.Hash{V0: 10187915247323429348, V1: 4770401581694266753, V2: 4182269187154655368, V3: 9030883832705174512},
                                        SourcePos:      2,
                                },
                                &account.UTXO{
-                                       OutputID:       bc.Hash{V0: 13540722642395030514, V1: 15412939347183859286, V2: 9545016219428105666, V3: 11940603522975438116},
+                                       OutputID:       bc.Hash{V0: 10165799535720725897, V1: 9618876671942765420, V2: 17982649347111502590, V3: 15837286550437859084},
                                        AssetID:        *consensus.BTMAssetID,
                                        Amount:         5,
                                        ControlProgram: []byte{0x54},
-                                       SourceID:       bc.Hash{V0: 15256474482236132139, V1: 14615963227748152009, V2: 1392768713126269609, V3: 3435801067785833027},
+                                       SourceID:       bc.Hash{V0: 10187915247323429348, V1: 4770401581694266753, V2: 4182269187154655368, V3: 9030883832705174512},
                                        SourcePos:      3,
                                },
                        },
@@ -720,7 +720,7 @@ func TestTxOutToUtxos(t *testing.T) {
        }
 
        for i, c := range cases {
-               if gotUtxos := txOutToUtxos(c.tx, c.statusFail, c.vaildHeight); !testutil.DeepEqual(gotUtxos, c.wantUtxos) {
+               if gotUtxos := txOutToUtxos(c.tx, c.statusFail, c.blockHeight); !testutil.DeepEqual(gotUtxos, c.wantUtxos) {
                        t.Errorf("case %d: got %v want %v", i, gotUtxos, c.wantUtxos)
 
                        for j, u := range gotUtxos {