X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=protocol%2Fbc%2Fmerkle_test.go;h=7b1c72f85430bf9cf08b2e3dcafc5cf62e67a202;hb=eed5312542ad10b3f62275eadeab226b119a22fd;hp=40ad6500f2583a296973c10910940c2fe6397063;hpb=01180396e6e36d20c8a666286c985637e6186bfd;p=bytom%2Fbytom.git diff --git a/protocol/bc/merkle_test.go b/protocol/bc/merkle_test.go index 40ad6500..7b1c72f8 100644 --- a/protocol/bc/merkle_test.go +++ b/protocol/bc/merkle_test.go @@ -5,7 +5,7 @@ import ( "time" . "github.com/bytom/protocol/bc" - "github.com/bytom/protocol/bc/types" + "github.com/bytom/protocol/bc/legacy" "github.com/bytom/protocol/vm" ) @@ -15,49 +15,49 @@ func TestMerkleRoot(t *testing.T) { want Hash }{{ witnesses: [][][]byte{ - { + [][]byte{ {1}, []byte("00000"), }, }, - want: mustDecodeHash("dd26282725467a18bf98ed14e022da9493436dd09372cfeae13080cbaaded00f"), + want: mustDecodeHash("ddf6b62a276929250336a294b1f1863fe979a0f418f02aa9d098fca775573c3c"), }, { witnesses: [][][]byte{ - { + [][]byte{ {1}, []byte("000000"), }, - { + [][]byte{ {1}, []byte("111111"), }, }, - want: mustDecodeHash("a112fb9aea40e6d8b2e9f443ec326d49bea7b61cd616b4bddeb9ebb010e76bf5"), + want: mustDecodeHash("c5ca521b644f9b3a393e046566a9ca8f2eafd9f46c7cebbed38fa5cc2ebb3e4c"), }, { witnesses: [][][]byte{ - { + [][]byte{ {1}, []byte("000000"), }, - { + [][]byte{ {2}, []byte("111111"), []byte("222222"), }, }, - want: mustDecodeHash("a112fb9aea40e6d8b2e9f443ec326d49bea7b61cd616b4bddeb9ebb010e76bf5"), + want: mustDecodeHash("c5ca521b644f9b3a393e046566a9ca8f2eafd9f46c7cebbed38fa5cc2ebb3e4c"), }} for _, c := range cases { var txs []*Tx for _, wit := range c.witnesses { - txs = append(txs, types.NewTx(types.TxData{ - Inputs: []*types.TxInput{ - &types.TxInput{ + txs = append(txs, legacy.NewTx(legacy.TxData{ + Inputs: []*legacy.TxInput{ + &legacy.TxInput{ AssetVersion: 1, - TypedInput: &types.SpendInput{ + TypedInput: &legacy.SpendInput{ Arguments: wit, - SpendCommitment: types.SpendCommitment{ + SpendCommitment: legacy.SpendCommitment{ AssetAmount: AssetAmount{ AssetId: &AssetID{V0: 0}, }, @@ -79,15 +79,16 @@ func TestMerkleRoot(t *testing.T) { } func TestDuplicateLeaves(t *testing.T) { + var initialBlockHash Hash trueProg := []byte{byte(vm.OP_TRUE)} - assetID := ComputeAssetID(trueProg, 1, &EmptyStringHash) + assetID := ComputeAssetID(trueProg, &initialBlockHash, 1, &EmptyStringHash) txs := make([]*Tx, 6) for i := uint64(0); i < 6; i++ { now := []byte(time.Now().String()) - txs[i] = types.NewTx(types.TxData{ + txs[i] = legacy.NewTx(legacy.TxData{ Version: 1, - Inputs: []*types.TxInput{types.NewIssuanceInput(now, i, trueProg, nil, nil)}, - Outputs: []*types.TxOutput{types.NewTxOutput(assetID, i, trueProg)}, + Inputs: []*legacy.TxInput{legacy.NewIssuanceInput(now, i, nil, initialBlockHash, trueProg, nil, nil)}, + Outputs: []*legacy.TxOutput{legacy.NewTxOutput(assetID, i, trueProg, nil)}, }).Tx } @@ -111,15 +112,16 @@ func TestDuplicateLeaves(t *testing.T) { } func TestAllDuplicateLeaves(t *testing.T) { + var initialBlockHash Hash trueProg := []byte{byte(vm.OP_TRUE)} - assetID := ComputeAssetID(trueProg, 1, &EmptyStringHash) + assetID := ComputeAssetID(trueProg, &initialBlockHash, 1, &EmptyStringHash) now := []byte(time.Now().String()) - issuanceInp := types.NewIssuanceInput(now, 1, trueProg, nil, nil) + issuanceInp := legacy.NewIssuanceInput(now, 1, nil, initialBlockHash, trueProg, nil, nil) - tx := types.NewTx(types.TxData{ + tx := legacy.NewTx(legacy.TxData{ Version: 1, - Inputs: []*types.TxInput{issuanceInp}, - Outputs: []*types.TxOutput{types.NewTxOutput(assetID, 1, trueProg)}, + Inputs: []*legacy.TxInput{issuanceInp}, + Outputs: []*legacy.TxOutput{legacy.NewTxOutput(assetID, 1, trueProg, nil)}, }).Tx tx1, tx2, tx3, tx4, tx5, tx6 := tx, tx, tx, tx, tx, tx