"time"
. "github.com/bytom/protocol/bc"
- "github.com/bytom/protocol/bc/types"
+ "github.com/bytom/protocol/bc/legacy"
"github.com/bytom/protocol/vm"
)
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},
},
}
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
}
}
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