OSDN Git Service

update master (#487)
[bytom/bytom-spv.git] / protocol / bc / types / block_test.go
similarity index 83%
rename from protocol/bc/legacy/block_test.go
rename to protocol/bc/types/block_test.go
index 7cece43..29b2788 100644 (file)
@@ -1,4 +1,4 @@
-package legacy
+package types
 
 import (
        "bytes"
@@ -23,9 +23,9 @@ func TestMarshalBlock(t *testing.T) {
                Transactions: []*Tx{
                        NewTx(TxData{
                                Version:        1,
-                               SerializedSize: uint64(46),
+                               SerializedSize: uint64(44),
                                Outputs: []*TxOutput{
-                                       NewTxOutput(bc.AssetID{}, 1, nil, nil),
+                                       NewTxOutput(bc.AssetID{}, 1, nil),
                                },
                        }),
                }}
@@ -41,13 +41,10 @@ func TestMarshalBlock(t *testing.T) {
                "01" + // version
                "01" + // block height
                "0000000000000000000000000000000000000000000000000000000000000000" + // prev block hash
-               "0000000000000000000000000000000000000000000000000000000000000000" + // seed hash
                "00" + // timestamp
                "40" + // commitment extensible field length
                "0000000000000000000000000000000000000000000000000000000000000000" + // tx merkle root
-               "0000000000000000000000000000000000000000000000000000000000000000" + // assets merkle root
-               "01" + // tx status
-               "00" +
+               "0000000000000000000000000000000000000000000000000000000000000000" + // tx status root
                "00" + // nonce
                "00" + // bits
 
@@ -64,9 +61,7 @@ func TestMarshalBlock(t *testing.T) {
                "01" + // tx 0, output 0 commitment, amount
                "01" + // tx 0, output 0 commitment vm version
                "00" + // tx 0, output 0 control program
-               "00" + // tx 0, output 0 reference data
-               "00" + // tx 0, output 0 output witness
-               "00\"") // tx 0 reference data
+               "00\"") // tx 0, output 0 output witness
 
        if !bytes.Equal(got, []byte(wantHex)) {
                t.Errorf("marshaled block bytes = %s want %s", got, []byte(wantHex))
@@ -102,13 +97,10 @@ func TestEmptyBlock(t *testing.T) {
                "01" + // version
                "01" + // block height
                "0000000000000000000000000000000000000000000000000000000000000000" + // prev block hash
-               "0000000000000000000000000000000000000000000000000000000000000000" + // seed hash
                "00" + // timestamp
                "40" + // commitment extensible field length
                "0000000000000000000000000000000000000000000000000000000000000000" + // transactions merkle root
-               "0000000000000000000000000000000000000000000000000000000000000000" + // assets merkle root
-               "01" + // tx status
-               "00" +
+               "0000000000000000000000000000000000000000000000000000000000000000" + // tx status hash
                "00" + // nonce
                "00" + // bits
                "00") // num transactions
@@ -122,13 +114,10 @@ func TestEmptyBlock(t *testing.T) {
                "01" + // version
                "01" + // block height
                "0000000000000000000000000000000000000000000000000000000000000000" + // prev block hash
-               "0000000000000000000000000000000000000000000000000000000000000000" + // seed hash
                "00" + // timestamp
                "40" + // commitment extensible field length
                "0000000000000000000000000000000000000000000000000000000000000000" + // transactions merkle root
-               "0000000000000000000000000000000000000000000000000000000000000000" + // assets merkle root
-               "01" + // tx status
-               "00" +
+               "0000000000000000000000000000000000000000000000000000000000000000" + // tx status hash
                "00" + // nonce
                "00") // bits
        want, _ = hex.DecodeString(wantHex)
@@ -136,7 +125,7 @@ func TestEmptyBlock(t *testing.T) {
                t.Errorf("empty block header bytes = %x want %x", got, want)
        }
 
-       wantHash := mustDecodeHash("8ba2dd5c6f88f8e95e7647b9342ae473eff81105927b18832c2c884ab673b582")
+       wantHash := mustDecodeHash("9609d2e45760f34cbc6c6d948c3fb9b6d7b61552d9d17fdd5b7d0cb5d2e67244")
        if h := block.Hash(); h != wantHash {
                t.Errorf("got block hash %x, want %x", h.Bytes(), wantHash.Bytes())
        }
@@ -161,17 +150,14 @@ func TestSmallBlock(t *testing.T) {
                "01" + // version
                "01" + // block height
                "0000000000000000000000000000000000000000000000000000000000000000" + // prev block hash
-               "0000000000000000000000000000000000000000000000000000000000000000" + // seed hash
                "00" + // timestamp
                "40" + // commitment extensible field length
                "0000000000000000000000000000000000000000000000000000000000000000" + // transactions merkle root
-               "0000000000000000000000000000000000000000000000000000000000000000" + // assets merkle root
-               "01" + // tx status
-               "00" +
+               "0000000000000000000000000000000000000000000000000000000000000000" + // tx status hash
                "00" + // nonce
                "00" + // bits
                "01" + // num transactions
-               "07010000000000") // transaction
+               "070100000000") // transaction
        want, _ := hex.DecodeString(wantHex)
        if !bytes.Equal(got, want) {
                t.Errorf("small block bytes = %x want %x", got, want)