From d3e343fbb36877d03468e27a3bc8df62cb5943bd Mon Sep 17 00:00:00 2001 From: Paladz Date: Wed, 16 Jun 2021 14:56:44 +0800 Subject: [PATCH] edht tx txoutput (#1966) Co-authored-by: paladz --- account/builder.go | 2 +- api/block_retrieve.go | 2 +- api/query.go | 2 +- protocol/bc/bc.pb.go | 127 ++++++++++++++-------------- protocol/bc/bc.proto | 2 +- protocol/bc/entry_test.go | 6 +- protocol/bc/output.go | 16 ++-- protocol/bc/tx.go | 6 +- protocol/bc/types/map.go | 6 +- protocol/bc/types/map_test.go | 6 +- protocol/bc/types/merkle_test.go | 2 +- protocol/bc/types/transaction_test.go | 4 +- protocol/bc/types/txoutput.go | 2 +- protocol/bc/types/txoutput_test.go | 4 +- protocol/state/utxo_view.go | 8 +- protocol/state/utxo_view_test.go | 14 ++-- protocol/txpool.go | 2 +- protocol/validation/block.go | 6 +- protocol/validation/tx.go | 6 +- protocol/validation/tx_scene_test.go | 150 +++++++++++++--------------------- protocol/validation/tx_test.go | 22 ++--- protocol/validation/vmcontext.go | 4 +- test/tx_test_util.go | 2 +- test/utxo_view/utxo_view_test_util.go | 4 +- wallet/annotated.go | 2 +- wallet/utxo.go | 6 +- wallet/utxo_test.go | 49 +++++------ 27 files changed, 215 insertions(+), 247 deletions(-) diff --git a/account/builder.go b/account/builder.go index b8032990..03312c8b 100644 --- a/account/builder.go +++ b/account/builder.go @@ -126,7 +126,7 @@ func (m *Manager) buildBtmTxChain(utxos []*UTXO, signer *signers.Signer) ([]*txb return nil, nil, err } - bcOut, err := tpl.Transaction.Output(*tpl.Transaction.ResultIds[0]) + bcOut, err := tpl.Transaction.OriginalOutput(*tpl.Transaction.ResultIds[0]) if err != nil { return nil, nil, err } diff --git a/api/block_retrieve.go b/api/block_retrieve.go index ef03654f..9e2e4334 100644 --- a/api/block_retrieve.go +++ b/api/block_retrieve.go @@ -85,7 +85,7 @@ func (a *API) getBlock(ins BlockReq) Response { } resOutID := orig.ResultIds[0] - resOut, ok := orig.Entries[*resOutID].(*bc.Output) + resOut, ok := orig.Entries[*resOutID].(*bc.OriginalOutput) if ok { tx.MuxID = *resOut.Source.Ref } else { diff --git a/api/query.go b/api/query.go index 83154b34..237e6bf9 100644 --- a/api/query.go +++ b/api/query.go @@ -200,7 +200,7 @@ func (a *API) getUnconfirmedTx(ctx context.Context, filter struct { resOutID := txDesc.Tx.ResultIds[0] resOut := txDesc.Tx.Entries[*resOutID] switch out := resOut.(type) { - case *bc.Output: + case *bc.OriginalOutput: tx.MuxID = *out.Source.Ref case *bc.Retirement: tx.MuxID = *out.Source.Ref diff --git a/protocol/bc/bc.pb.go b/protocol/bc/bc.pb.go index d55dbc9b..0c113ffb 100644 --- a/protocol/bc/bc.pb.go +++ b/protocol/bc/bc.pb.go @@ -19,7 +19,7 @@ It has these top-level messages: TxHeader Mux Coinbase - Output + OriginalOutput VoteOutput VetoInput Retirement @@ -416,40 +416,40 @@ func (m *Coinbase) GetArbitrary() []byte { return nil } -type Output struct { +type OriginalOutput struct { Source *ValueSource `protobuf:"bytes,1,opt,name=source" json:"source,omitempty"` ControlProgram *Program `protobuf:"bytes,2,opt,name=control_program,json=controlProgram" json:"control_program,omitempty"` Ordinal uint64 `protobuf:"varint,3,opt,name=ordinal" json:"ordinal,omitempty"` StateData [][]byte `protobuf:"bytes,4,rep,name=state_data,json=stateData,proto3" json:"state_data,omitempty"` } -func (m *Output) Reset() { *m = Output{} } -func (m *Output) String() string { return proto.CompactTextString(m) } -func (*Output) ProtoMessage() {} -func (*Output) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } +func (m *OriginalOutput) Reset() { *m = OriginalOutput{} } +func (m *OriginalOutput) String() string { return proto.CompactTextString(m) } +func (*OriginalOutput) ProtoMessage() {} +func (*OriginalOutput) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } -func (m *Output) GetSource() *ValueSource { +func (m *OriginalOutput) GetSource() *ValueSource { if m != nil { return m.Source } return nil } -func (m *Output) GetControlProgram() *Program { +func (m *OriginalOutput) GetControlProgram() *Program { if m != nil { return m.ControlProgram } return nil } -func (m *Output) GetOrdinal() uint64 { +func (m *OriginalOutput) GetOrdinal() uint64 { if m != nil { return m.Ordinal } return 0 } -func (m *Output) GetStateData() [][]byte { +func (m *OriginalOutput) GetStateData() [][]byte { if m != nil { return m.StateData } @@ -676,7 +676,7 @@ func init() { proto.RegisterType((*TxHeader)(nil), "bc.TxHeader") proto.RegisterType((*Mux)(nil), "bc.Mux") proto.RegisterType((*Coinbase)(nil), "bc.Coinbase") - proto.RegisterType((*Output)(nil), "bc.Output") + proto.RegisterType((*OriginalOutput)(nil), "bc.OriginalOutput") proto.RegisterType((*VoteOutput)(nil), "bc.VoteOutput") proto.RegisterType((*VetoInput)(nil), "bc.VetoInput") proto.RegisterType((*Retirement)(nil), "bc.Retirement") @@ -687,58 +687,59 @@ func init() { func init() { proto.RegisterFile("bc.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 846 bytes of a gzipped FileDescriptorProto + // 852 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xdd, 0x6e, 0x1b, 0x45, 0x14, 0xd6, 0xda, 0xeb, 0xbf, 0xe3, 0x10, 0x27, 0x93, 0xaa, 0x5a, 0x55, 0x45, 0xaa, 0x56, 0x2a, - 0x01, 0x21, 0x45, 0xa9, 0x53, 0xb8, 0xe2, 0x26, 0x10, 0xa0, 0xbe, 0x88, 0x8a, 0x26, 0x28, 0xb7, - 0xab, 0xf1, 0xee, 0xd4, 0x1e, 0x61, 0xcf, 0x2c, 0x33, 0xb3, 0x4b, 0xc9, 0x7b, 0x70, 0xcf, 0x5b, - 0xc0, 0x1b, 0x20, 0x81, 0x78, 0x27, 0x34, 0x67, 0x67, 0xbd, 0xfe, 0x2b, 0x6d, 0x84, 0x10, 0xe2, - 0xce, 0xe7, 0x67, 0xcf, 0x7c, 0xe7, 0x3b, 0xdf,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0x7b, 0xa5, 0xd8, 0xde, 0x2f, 0xc5, 0x75, 0x02, + 0xc2, 0x0d, 0x02, 0xe2, 0x1b, 0x00, 0xca, 0xad, 0xd0, 0xdc, 0x25, 0xbe, 0xfd, 0x1e, 0xd6, 0x0a, + 0xb6, 0x36, 0x0b, 0xfe, 0xd2, 0x82, 0xfe, 0xc4, 0xbf, 0x1e, 0xee, 0xec, 0x4b, 0xe5, 0xde, 0x9a, + 0x39, 0x33, 0xf3, 0x1d, 0x62, 0x06, 0x18, 0xc3, 0x27, 0xfc, 0x2d, 0xef, 0xe8, 0xd7, 0x70, 0xd7, + 0x7e, 0x47, 0xee, 0xae, 0x21, 0x5a, 0x71, 0x87, 0x0f, 0x6c, 0xb6, 0x7a, 0x21, 0x91, 0x9f, 0xe1, + 0xf8, 0x64, 0x05, 0xa0, 0x79, 0x3c, 0xe9, 0xc3, 0x9a, 0xd7, 0xad, 0x47, 0x75, 0xef, 0x2a, 0x3a, + 0x6f, 0x5e, 0x45, 0x77, 0x93, 0xb9, 0xdf, 0x02, 0xe8, 0xdc, 0xe6, 0x5c, 0x66, 0xff, 0x77, 0x51, + 0x4d, 0xbb, 0xf8, 0x1f, 0xed, 0xe2, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8e, 0xe5, 0xe4, 0x4f, + 0xaf, 0x09, 0x00, 0x00, } diff --git a/protocol/bc/bc.proto b/protocol/bc/bc.proto index fe89936f..2392e4c1 100644 --- a/protocol/bc/bc.proto +++ b/protocol/bc/bc.proto @@ -75,7 +75,7 @@ message Coinbase { bytes arbitrary = 2; } -message Output { +message OriginalOutput { ValueSource source = 1; Program control_program = 2; uint64 ordinal = 3; diff --git a/protocol/bc/entry_test.go b/protocol/bc/entry_test.go index 20719935..44d58f33 100644 --- a/protocol/bc/entry_test.go +++ b/protocol/bc/entry_test.go @@ -12,7 +12,7 @@ func BenchmarkEntryID(b *testing.B) { NewIssuance(nil, &AssetAmount{}, 0), m, NewTxHeader(1, 1, 0, nil), - NewOutput(&ValueSource{}, &Program{Code: []byte{1}, VmVersion: 1}, [][]byte{{1}}, 0), + NewOriginalOutput(&ValueSource{}, &Program{Code: []byte{1}, VmVersion: 1}, [][]byte{{1}}, 0), NewRetirement(&ValueSource{}, 1), NewSpend(&Hash{}, 0), } @@ -50,7 +50,7 @@ func TestEntryID(t *testing.T) { expectEntryID: "16c4265a8a90916434c2a904a90132c198c7ebf8512aa1ba4485455b0beff388", }, { - entry: NewOutput( + entry: NewOriginalOutput( &ValueSource{ Ref: &Hash{V0: 4, V1: 5, V2: 6, V3: 7}, Value: &AssetAmount{&AssetID{V0: 1, V1: 1, V2: 1, V3: 1}, 10}, @@ -60,7 +60,7 @@ func TestEntryID(t *testing.T) { [][]byte{{3, 4}}, 1, ), - expectEntryID: "02c6841bcbdc3231a7beecefdfb4785876153080ebdc04bcd3dab308d18c8846", + expectEntryID: "63fbfda2cf0acc573f2a514ddff8ee64c33e713aebe4c85670507545c38841b2", }, { entry: NewRetirement( diff --git a/protocol/bc/output.go b/protocol/bc/output.go index 0c98fa78..74457b97 100644 --- a/protocol/bc/output.go +++ b/protocol/bc/output.go @@ -2,22 +2,20 @@ package bc import "io" -// Output is the result of a transfer of value. The value it contains +// OriginalOutput is the result of a transfer of value. The value it contains // may be accessed by a later Spend entry (if that entry can satisfy -// the Output's ControlProgram). Output satisfies the Entry interface. -// -// (Not to be confused with the deprecated type TxOutput.) +// the Output's ControlProgram). OriginalOutput satisfies the Entry interface. -func (Output) typ() string { return "output1" } -func (o *Output) writeForHash(w io.Writer) { +func (OriginalOutput) typ() string { return "originalOutput1" } +func (o *OriginalOutput) writeForHash(w io.Writer) { mustWriteForHash(w, o.Source) mustWriteForHash(w, o.ControlProgram) mustWriteForHash(w, o.StateData) } -// NewOutput creates a new Output. -func NewOutput(source *ValueSource, controlProgram *Program, stateData [][]byte, ordinal uint64) *Output { - return &Output{ +// NewOriginalOutput creates a new OriginalOutput. +func NewOriginalOutput(source *ValueSource, controlProgram *Program, stateData [][]byte, ordinal uint64) *OriginalOutput { + return &OriginalOutput{ Source: source, ControlProgram: controlProgram, Ordinal: ordinal, diff --git a/protocol/bc/tx.go b/protocol/bc/tx.go index ccae7eb6..dfcd14b8 100644 --- a/protocol/bc/tx.go +++ b/protocol/bc/tx.go @@ -32,13 +32,13 @@ var ( ErrMissingEntry = errors.New("missing entry") ) -// Output try to get the output entry by given hash -func (tx *Tx) Output(id Hash) (*Output, error) { +// OriginalOutput try to get the output entry by given hash +func (tx *Tx) OriginalOutput(id Hash) (*OriginalOutput, error) { e, ok := tx.Entries[id] if !ok || e == nil { return nil, errors.Wrapf(ErrMissingEntry, "id %x", id.Bytes()) } - o, ok := e.(*Output) + o, ok := e.(*OriginalOutput) if !ok { return nil, errors.Wrapf(ErrEntryType, "entry %x has unexpected type %T", id.Bytes(), e) } diff --git a/protocol/bc/types/map.go b/protocol/bc/types/map.go index fdc57ec3..60b0b615 100644 --- a/protocol/bc/types/map.go +++ b/protocol/bc/types/map.go @@ -102,7 +102,7 @@ func (mh *mapHelper) mapSpendInput(i int, input *SpendInput) { Position: input.SourcePosition, } - prevout := bc.NewOutput(src, prog, input.StateData, 0) // ordinal doesn't matter for prevouts, only for result outputs + prevout := bc.NewOriginalOutput(src, prog, input.StateData, 0) // ordinal doesn't matter for prevouts, only for result outputs prevoutID := mh.addEntry(prevout) // create entry for spend @@ -162,7 +162,7 @@ func (mh *mapHelper) initMux() { // connect the inputs to the mux for _, spend := range mh.spends { - spentOutput := mh.entryMap[*spend.SpentOutputId].(*bc.Output) + spentOutput := mh.entryMap[*spend.SpentOutputId].(*bc.OriginalOutput) spend.SetDestination(&muxID, spentOutput.Source.Value, spend.Ordinal) } @@ -193,7 +193,7 @@ func (mh *mapHelper) mapOutputs() { resultID = mh.addEntry(r) case out.OutputType() == OriginalOutputType: - o := bc.NewOutput(src, prog, out.StateData, uint64(i)) + o := bc.NewOriginalOutput(src, prog, out.StateData, uint64(i)) resultID = mh.addEntry(o) case out.OutputType() == VoteOutputType: diff --git a/protocol/bc/types/map_test.go b/protocol/bc/types/map_test.go index fc7a679f..398861d1 100644 --- a/protocol/bc/types/map_test.go +++ b/protocol/bc/types/map_test.go @@ -59,7 +59,7 @@ func TestMapSpendTx(t *testing.T) { t.Errorf("tx.InputIDs[%d]'s asset amount is not equal after map'", i) } case *bc.Spend: - spendOut, err := tx.Output(*newInput.SpentOutputId) + spendOut, err := tx.OriginalOutput(*newInput.SpentOutputId) if err != nil { t.Fatal(err) } @@ -76,7 +76,7 @@ func TestMapSpendTx(t *testing.T) { if !ok { t.Errorf("entryMap contains nothing for header.ResultIds[%d] (%x)", i, tx.ResultIds[i].Bytes()) } - newOut, ok := resultEntry.(*bc.Output) + newOut, ok := resultEntry.(*bc.OriginalOutput) if !ok { t.Errorf("header.ResultIds[%d] has type %T, expected *Output", i, resultEntry) } @@ -126,7 +126,7 @@ func TestMapCoinbaseTx(t *testing.T) { if !ok { t.Errorf("entryMap contains nothing for output") } - newOut, ok := outEntry.(*bc.Output) + newOut, ok := outEntry.(*bc.OriginalOutput) if !ok { t.Errorf("header.ResultIds[0] has type %T, expected *Output", outEntry) } diff --git a/protocol/bc/types/merkle_test.go b/protocol/bc/types/merkle_test.go index 82fe26d9..027d3160 100644 --- a/protocol/bc/types/merkle_test.go +++ b/protocol/bc/types/merkle_test.go @@ -346,7 +346,7 @@ func TestMerkleRootRealTx(t *testing.T) { "00", }, ""), } - wantMerkleRoot := "25b984047650029965ba604e4bbd534bca448ddedced5df40e25cd245d4e70f1" + wantMerkleRoot := "a23ae3e435a7bdfb52cb92b58be6e658982fd883283caf9547f9df50d65881df" var txs []*bc.Tx for _, rawTx := range rawTxs { diff --git a/protocol/bc/types/transaction_test.go b/protocol/bc/types/transaction_test.go index 3689c975..31732bd2 100644 --- a/protocol/bc/types/transaction_test.go +++ b/protocol/bc/types/transaction_test.go @@ -106,7 +106,7 @@ func TestTransaction(t *testing.T) { "737461746544617461", // output 0: state data "00", // output 0: witness length }, ""), - hash: testutil.MustDecodeHash("b23862d7969ce9581ee7f94f648fd8a51ca103984afb68a134db9ab5c3af177f"), + hash: testutil.MustDecodeHash("509632e139a418be372cd4b73c8de7b8aa5215c47848bf76ed2488d0a5c0c55e"), }, { tx: NewTx(TxData{ @@ -155,7 +155,7 @@ func TestTransaction(t *testing.T) { "737461746544617461", // output 0: state data "00", // output 1: witness length }, ""), - hash: testutil.MustDecodeHash("27d7fae74355ee9de2014bc51c30de27afa922ac4171eca1f38a05965c899c79"), + hash: testutil.MustDecodeHash("4243fc12f6e8704c5e4318a2addc648d29fd1c03a8fe1246badafa5efd8b5339"), }, } for i, test := range cases { diff --git a/protocol/bc/types/txoutput.go b/protocol/bc/types/txoutput.go index 751b7ef5..901c7cb4 100644 --- a/protocol/bc/types/txoutput.go +++ b/protocol/bc/types/txoutput.go @@ -116,6 +116,6 @@ func ComputeOutputID(sc *SpendCommitment) (h bc.Hash, err error) { Position: sc.SourcePosition, } - o := bc.NewOutput(src, &bc.Program{VmVersion: sc.VMVersion, Code: sc.ControlProgram}, sc.StateData, 0) + o := bc.NewOriginalOutput(src, &bc.Program{VmVersion: sc.VMVersion, Code: sc.ControlProgram}, sc.StateData, 0) return bc.EntryID(o), nil } diff --git a/protocol/bc/types/txoutput_test.go b/protocol/bc/types/txoutput_test.go index 742dcdc6..944754b8 100644 --- a/protocol/bc/types/txoutput_test.go +++ b/protocol/bc/types/txoutput_test.go @@ -119,7 +119,7 @@ func TestComputeOutputID(t *testing.T) { VMVersion: 1, ControlProgram: testutil.MustDecodeHexString("0014cb9f2391bafe2bc1159b2c4c8a0f17ba1b4dd94e"), }, - wantOutputID: "6e8ae55aef79b2267a4762c88825478925890b47fdf00289c107e996fea7a039", + wantOutputID: "b8f8664c4179a7fae694e7cafcb250403b0e12738ed5aae4610d45082a33d44a", }, { sc: &SpendCommitment{ @@ -129,7 +129,7 @@ func TestComputeOutputID(t *testing.T) { VMVersion: 1, ControlProgram: testutil.MustDecodeHexString("001418549d84daf53344d32563830c7cf979dc19d5c0"), }, - wantOutputID: "5260251e46f7bf3a975a96bbacaf2f8e322bcd042e2ceca52eca265542e0a87c", + wantOutputID: "638fd48107ceb576ac7518310df01214ac75a8c667ac659ecfbc397fdf0c5a6f", }, } diff --git a/protocol/state/utxo_view.go b/protocol/state/utxo_view.go index c68ad9a6..00aaf7bd 100644 --- a/protocol/state/utxo_view.go +++ b/protocol/state/utxo_view.go @@ -21,7 +21,7 @@ func NewUtxoViewpoint() *UtxoViewpoint { func (view *UtxoViewpoint) ApplyTransaction(block *bc.Block, tx *bc.Tx) error { for _, prevout := range tx.SpentOutputIDs { - _, err := tx.Output(prevout) + _, err := tx.OriginalOutput(prevout) if err != nil { return err } @@ -40,7 +40,7 @@ func (view *UtxoViewpoint) ApplyTransaction(block *bc.Block, tx *bc.Tx) error { } for _, id := range tx.TxHeader.ResultIds { - _, err := tx.Output(*id) + _, err := tx.OriginalOutput(*id) if err != nil { // error due to it's a retirement, utxo doesn't care this output type so skip it continue @@ -71,7 +71,7 @@ func (view *UtxoViewpoint) CanSpend(hash *bc.Hash) bool { func (view *UtxoViewpoint) DetachTransaction(tx *bc.Tx) error { for _, prevout := range tx.SpentOutputIDs { - _, err := tx.Output(prevout) + _, err := tx.OriginalOutput(prevout) if err != nil { return err } @@ -88,7 +88,7 @@ func (view *UtxoViewpoint) DetachTransaction(tx *bc.Tx) error { } for _, id := range tx.TxHeader.ResultIds { - _, err := tx.Output(*id) + _, err := tx.OriginalOutput(*id) if err != nil { // error due to it's a retirement, utxo doesn't care this output type so skip it continue diff --git a/protocol/state/utxo_view_test.go b/protocol/state/utxo_view_test.go index db3f05c7..a1df3b7e 100644 --- a/protocol/state/utxo_view_test.go +++ b/protocol/state/utxo_view_test.go @@ -11,7 +11,7 @@ import ( ) var defaultEntry = map[bc.Hash]bc.Entry{ - bc.Hash{V0: 0}: &bc.Output{ + bc.Hash{V0: 0}: &bc.OriginalOutput{ Source: &bc.ValueSource{ Value: &bc.AssetAmount{ AssetId: &bc.AssetID{V0: 0}, @@ -21,14 +21,14 @@ var defaultEntry = map[bc.Hash]bc.Entry{ } var gasOnlyTxEntry = map[bc.Hash]bc.Entry{ - bc.Hash{V1: 0}: &bc.Output{ + bc.Hash{V1: 0}: &bc.OriginalOutput{ Source: &bc.ValueSource{ Value: &bc.AssetAmount{ AssetId: consensus.BTMAssetID, }, }, }, - bc.Hash{V1: 1}: &bc.Output{ + bc.Hash{V1: 1}: &bc.OriginalOutput{ Source: &bc.ValueSource{ Value: &bc.AssetAmount{ AssetId: &bc.AssetID{V0: 999}, @@ -131,7 +131,7 @@ func TestApplyBlock(t *testing.T) { { block: &bc.Block{ BlockHeader: &bc.BlockHeader{ - Height: 101, + Height: 101, }, Transactions: []*bc.Tx{ &bc.Tx{ @@ -160,7 +160,7 @@ func TestApplyBlock(t *testing.T) { { block: &bc.Block{ BlockHeader: &bc.BlockHeader{ - Height: 0, + Height: 0, }, Transactions: []*bc.Tx{ &bc.Tx{ @@ -239,7 +239,7 @@ func TestApplyBlock(t *testing.T) { bc.Hash{V1: 1}: storage.NewUtxoEntry(false, 0, true), }, }, - err: false, + err: false, }, { // apply gas only tx, non-btm asset spent output will not be store @@ -265,7 +265,7 @@ func TestApplyBlock(t *testing.T) { bc.Hash{V1: 1}: storage.NewUtxoEntry(true, 0, false), }, }, - err: false, + err: false, }, } diff --git a/protocol/txpool.go b/protocol/txpool.go index 43657fda..42ec97e1 100644 --- a/protocol/txpool.go +++ b/protocol/txpool.go @@ -286,7 +286,7 @@ func (tp *TxPool) addTransaction(txD *TxDesc) error { txD.Added = time.Now() tp.pool[tx.ID] = txD for _, id := range tx.ResultIds { - _, err := tx.Output(*id) + _, err := tx.OriginalOutput(*id) if err != nil { // error due to it's a retirement, utxo doesn't care this output type so skip it continue diff --git a/protocol/validation/block.go b/protocol/validation/block.go index 10a498f4..465709c7 100644 --- a/protocol/validation/block.go +++ b/protocol/validation/block.go @@ -48,7 +48,7 @@ func checkCoinbaseAmount(b *bc.Block, checkpoint *state.Checkpoint) error { } if b.Height%state.BlocksOfEpoch != 1 || b.Height == 1 { - output, err := tx.Output(*tx.TxHeader.ResultIds[0]) + output, err := tx.OriginalOutput(*tx.TxHeader.ResultIds[0]) if err != nil { return err } @@ -75,7 +75,7 @@ func checkoutRewardCoinbase(tx *bc.Tx, checkpoint *state.Checkpoint) error { var startIndex int if resultIdLen == len(checkpoint.Rewards)+1 { - output, err := tx.Output(*tx.TxHeader.ResultIds[0]) + output, err := tx.OriginalOutput(*tx.TxHeader.ResultIds[0]) if err != nil { return err } @@ -90,7 +90,7 @@ func checkoutRewardCoinbase(tx *bc.Tx, checkpoint *state.Checkpoint) error { rewards := checkpoint.Rewards for i := startIndex; i < resultIdLen; i++ { output := tx.TxHeader.ResultIds[i] - out, err := tx.Output(*output) + out, err := tx.OriginalOutput(*output) if err != nil { return err } diff --git a/protocol/validation/tx.go b/protocol/validation/tx.go index 3ab1feea..8759345a 100644 --- a/protocol/validation/tx.go +++ b/protocol/validation/tx.go @@ -201,7 +201,7 @@ func checkValid(vs *validationState, e bc.Entry) (err error) { return err } - case *bc.Output: + case *bc.OriginalOutput: vs2 := *vs vs2.sourcePos = 0 if err = checkValidSrc(&vs2, e.Source); err != nil { @@ -256,7 +256,7 @@ func checkValid(vs *validationState, e bc.Entry) (err error) { if e.SpentOutputId == nil { return errors.Wrap(ErrMissingField, "spend without spent output ID") } - spentOutput, err := vs.tx.Output(*e.SpentOutputId) + spentOutput, err := vs.tx.OriginalOutput(*e.SpentOutputId) if err != nil { return errors.Wrap(err, "getting spend prevout") } @@ -453,7 +453,7 @@ func checkValidDest(vs *validationState, vd *bc.ValueDestination) error { var src *bc.ValueSource switch ref := e.(type) { - case *bc.Output: + case *bc.OriginalOutput: if vd.Position != 0 { return errors.Wrapf(ErrPosition, "invalid position %d for output destination", vd.Position) } diff --git a/protocol/validation/tx_scene_test.go b/protocol/validation/tx_scene_test.go index 64e954df..16aa9892 100644 --- a/protocol/validation/tx_scene_test.go +++ b/protocol/validation/tx_scene_test.go @@ -1,13 +1,13 @@ package validation import ( - "encoding/hex" "testing" "github.com/bytom/bytom/consensus" "github.com/bytom/bytom/protocol/bc" "github.com/bytom/bytom/protocol/bc/types" "github.com/bytom/bytom/protocol/vm" + "github.com/bytom/bytom/testutil" ) func TestValidateTx(t *testing.T) { @@ -25,14 +25,14 @@ func TestValidateTx(t *testing.T) { Inputs: []*types.TxInput{ types.NewSpendInput( [][]byte{ - mustDecodeString("556a2be7ea4e116e6ff9a0df0ababc2541fce9e8a0f209b624e1cb1f55e8f2f1f3ed4097b4b2daa12bab8f7746ef5c7966788e9d89daf08e11c8de78d115460d"), - mustDecodeString("32fa23244a69e5524d190ad62391c2fc654685a740e00e9a316b78c95028363f"), + testutil.MustDecodeHexString("d5380072fcf74cd9625c0ba77e9c6ae4604521889e3dd42fcba770f0e7523b2b2e2c0fe2218f75def7d7375bbc24e8b6c51afc0d7900acac3849b34245b46703"), + testutil.MustDecodeHexString("7642ba797fd89d1f98a8559b4ca74123697dd4dee882955acd0da9010a80d64e"), }, bc.Hash{V0: 2}, - *consensus.BTMAssetID, 1000000000, 0, mustDecodeString("00149dd32abe4756676cc310470457edefce8b3bd7e7"), [][]byte{}), + *consensus.BTMAssetID, 1000000000, 0, testutil.MustDecodeHexString("0014f233267911e94dc74df706fe3b697273e212d545"), [][]byte{}), }, Outputs: []*types.TxOutput{ - types.NewOriginalTxOutput(*consensus.BTMAssetID, 100, mustDecodeString("00149dd32abe4756676cc310470457edefce8b3bd7e7"), [][]byte{}), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 100, testutil.MustDecodeHexString("0014f233267911e94dc74df706fe3b697273e212d545"), [][]byte{}), }, }, err: nil, @@ -45,23 +45,23 @@ func TestValidateTx(t *testing.T) { Inputs: []*types.TxInput{ types.NewSpendInput( [][]byte{ - mustDecodeString("bc68d6cf8e9b58ad1561fe855a2e2072941833ccc73efb2db82181a275133711087975e7f16e5004bf5f4214a99c2326e77c8ee9005112251209f799c50a3e06"), - mustDecodeString("3c4518eb4faa8ab01503057933932f33503e7693e05bb20948efd525be5850df"), + testutil.MustDecodeHexString("725dd970e2654fc75ef9affbd31ca20f973c28a7101d5f35c064ee6a1afe91fb75495ab4e6a83d1b213c4eed87d987bc3d4256782f33b62d418abaeaae7f0a0d"), + testutil.MustDecodeHexString("7642ba797fd89d1f98a8559b4ca74123697dd4dee882955acd0da9010a80d64e"), }, bc.Hash{V0: 14760873410800997144, V1: 1698395500822741684, V2: 5965908492734661392, V3: 9445539829830863994}, - *consensus.BTMAssetID, 11818900000, 0, mustDecodeString("0014a5f3f1941449c6072ade0ec5a66fad1417124f03"), nil), + *consensus.BTMAssetID, 11818900000, 0, testutil.MustDecodeHexString("0014f233267911e94dc74df706fe3b697273e212d545"), nil), types.NewSpendInput( [][]byte{ - mustDecodeString("634d17cf09126ec42547d878414a78703accbc52b98d44d3bd71bb78a035cc1663f5340ecee915290c8c89c552a9d1795bf0dee7832cedafb7be15d0ed57da03"), - mustDecodeString("3c4518eb4faa8ab01503057933932f33503e7693e05bb20948efd525be5850df"), + testutil.MustDecodeHexString("c714d495298d02cdaa285a740eedca6f05df1dfbc8eb5d17498b3e8b8feacd51f9bac6c302dbe8157b3a107ea41c742dae42d1b5a60f46804698eb7cf578d50e"), + testutil.MustDecodeHexString("7642ba797fd89d1f98a8559b4ca74123697dd4dee882955acd0da9010a80d64e"), }, bc.Hash{V0: 13464118406972499748, V1: 5083224803004805715, V2: 16263625389659454272, V3: 9428032044180324575}, - *consensus.BTMAssetID, 99439999900, 2, mustDecodeString("0014a5f3f1941449c6072ade0ec5a66fad1417124f03"), nil), + *consensus.BTMAssetID, 99439999900, 2, testutil.MustDecodeHexString("0014f233267911e94dc74df706fe3b697273e212d545"), nil), }, Outputs: []*types.TxOutput{ - types.NewOriginalTxOutput(*consensus.BTMAssetID, 1818900000, mustDecodeString("00145931e1b7b65897f47845ac08fc136e0c0a4ff166"), nil), - types.NewOriginalTxOutput(*consensus.BTMAssetID, 89439999900, mustDecodeString("0014ca1f877c2787f746a4473adac932171dd18d55d7"), nil), - types.NewOriginalTxOutput(*consensus.BTMAssetID, 19900000000, mustDecodeString("00145ade29df622cc68d0473aa1a20fb89690451c66e"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 1818900000, testutil.MustDecodeHexString("00145931e1b7b65897f47845ac08fc136e0c0a4ff166"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 89439999900, testutil.MustDecodeHexString("0014ca1f877c2787f746a4473adac932171dd18d55d7"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 19900000000, testutil.MustDecodeHexString("00145ade29df622cc68d0473aa1a20fb89690451c66e"), nil), }, }, err: nil, @@ -74,50 +74,28 @@ func TestValidateTx(t *testing.T) { Inputs: []*types.TxInput{ types.NewSpendInput( [][]byte{ - mustDecodeString("4a8bf559f3c334ad23ed0aadab22dd3a4a8260488b1632dee16f75cac5c0ade674f2938776459414ab4d4e43622290507ff750a3fb563a25ee9a72386bfbe207"), - mustDecodeString("ca85ea98011ddd592d1f081ebd2a91ac0f4238784222ed85b9d95aeb654f1cf1"), + testutil.MustDecodeHexString("4a8bf559f3c334ad23ed0aadab22dd3a4a8260488b1632dee16f75cac5c0ade674f2938776459414ab4d4e43622290507ff750a3fb563a25ee9a72386bfbe207"), + testutil.MustDecodeHexString("ca85ea98011ddd592d1f081ebd2a91ac0f4238784222ed85b9d95aeb654f1cf1"), }, bc.Hash{V0: 14760873410800997144, V1: 1698395500822741684, V2: 5965908492734661392, V3: 9445539829830863994}, - *consensus.BTMAssetID, 11818900000, 0, mustDecodeString("0014e6e1f8b11f1cfb7609037003b90f64837afd272c"), nil), + *consensus.BTMAssetID, 11818900000, 0, testutil.MustDecodeHexString("0014e6e1f8b11f1cfb7609037003b90f64837afd272c"), nil), types.NewSpendInput( [][]byte{ - mustDecodeString("b4f6876a97c8e6bd7e038b476fb6fd07cdd6cfcf7d661dfab796b5e2c777b3de166495de4fba2aa154af844ed6a3d51c26742241edb0d5d107fc52dfff0f6305"), - mustDecodeString("e5966eee4092eeefdd805b06f2ad368bb9392edec20998993ebe2a929052c1ce"), + testutil.MustDecodeHexString("b4f6876a97c8e6bd7e038b476fb6fd07cdd6cfcf7d661dfab796b5e2c777b3de166495de4fba2aa154af844ed6a3d51c26742241edb0d5d107fc52dfff0f6305"), + testutil.MustDecodeHexString("e5966eee4092eeefdd805b06f2ad368bb9392edec20998993ebe2a929052c1ce"), }, bc.Hash{V0: 17091584763764411831, V1: 2315724244669489432, V2: 4322938623810388342, V3: 11167378497724951792}, - *consensus.BTMAssetID, 99960000000, 1, mustDecodeString("0014cfbccfac5018ad4b4bfbcb1fab834e3c85037460"), nil), + *consensus.BTMAssetID, 99960000000, 1, testutil.MustDecodeHexString("0014cfbccfac5018ad4b4bfbcb1fab834e3c85037460"), nil), }, Outputs: []*types.TxOutput{ - types.NewOriginalTxOutput(*consensus.BTMAssetID, 1818900000, mustDecodeString("00144b5637cc25b188136f440484f210541fa2a7ce64"), nil), - types.NewOriginalTxOutput(*consensus.BTMAssetID, 89960000000, mustDecodeString("0014c7271a69dba57331b36221118dfeb1b1793933df"), nil), - types.NewOriginalTxOutput(*consensus.BTMAssetID, 20000000000, mustDecodeString("0014447e597c1c326ad1a639f8023d3f87ae22a4e049"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 1818900000, testutil.MustDecodeHexString("00144b5637cc25b188136f440484f210541fa2a7ce64"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 89960000000, testutil.MustDecodeHexString("0014c7271a69dba57331b36221118dfeb1b1793933df"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 20000000000, testutil.MustDecodeHexString("0014447e597c1c326ad1a639f8023d3f87ae22a4e049"), nil), }, }, err: vm.ErrRunLimitExceeded, }, { - desc: "single utxo, multi sign, non asset, btm stanard transaction", - txData: &types.TxData{ - Version: 1, - SerializedSize: 396, - Inputs: []*types.TxInput{ - types.NewSpendInput( - [][]byte{ - mustDecodeString("6aa2dc1535e99a7b24eb215081613bbc9152cb073ebffc4846c819490f0836dec172b4893287cb026d230c0e462f237825fdcca29fde66cf096642a2844c860b"), - mustDecodeString("28125a89064f60333d3bc213a18e13a4d35038bcaafc1ff7349e24607d6b98c755a33c74f44830f86d272da57dac77cca681672dfd12431004b7abaebeabad00"), - mustDecodeString("ae20ed8e23a24df18f7a3dc148b9fa25cf849cdf233516528af683fe8a950ae31cff2015fb5ccf17b225be43161037d9b671cc26344c65e6fee1519ef66379c25f73905252ad"), - }, - bc.Hash{V0: 6970879411704044573, V1: 10086395903308657573, V2: 10107608596190358115, V3: 8645856247221333302}, - *consensus.BTMAssetID, 89220000000, 1, mustDecodeString("00203adcfdf4a4e7e2b27d5b9f6eeafeebb4db229f73db244931c69feb54775d8510"), nil), - }, - Outputs: []*types.TxOutput{ - types.NewOriginalTxOutput(*consensus.BTMAssetID, 79220000000, mustDecodeString("00206205ec178dc1ac6ea05ea01bb0fcda6aa978173026fa75204a101bdad7bd6b48"), nil), - types.NewOriginalTxOutput(*consensus.BTMAssetID, 9900000000, mustDecodeString("0014414eb62abda9a9191f9cba5d7e38d92f3e91e268"), nil), - }, - }, - err: nil, - }, - { desc: "single utxo, retire, non asset, btm stanard transaction", txData: &types.TxData{ Version: 1, @@ -125,14 +103,14 @@ func TestValidateTx(t *testing.T) { Inputs: []*types.TxInput{ types.NewSpendInput( [][]byte{ - mustDecodeString("3501a5dbfc05872d4da038893ecf3d2a776e3a805b3ae3f83bd461064a318ad7aa11d897e52b571a037347a8d4e3ccd0b7cdcda232af3142fa1329ac290f2509"), - mustDecodeString("a0513ea06993680e7e639400ab051bbedeac675ed8f2085d4d6379fb8000bdb4"), + testutil.MustDecodeHexString("62313a8ae7bc039bf02df721bcf6d0581e16d0b23e097f96d3a107c22c6d75fc1e5ec41ceaa4104e38c97204cfc742f49fea95cbd06a9a5a19ea26d0c334c701"), + testutil.MustDecodeHexString("7642ba797fd89d1f98a8559b4ca74123697dd4dee882955acd0da9010a80d64e"), }, bc.Hash{V0: 14760873410800997144, V1: 1698395500822741684, V2: 5965908492734661392, V3: 9445539829830863994}, - *consensus.BTMAssetID, 11818900000, 0, mustDecodeString("0014d3b239cfb5aa0b3302872b92682623ed408d0afc"), nil), + *consensus.BTMAssetID, 11818900000, 0, testutil.MustDecodeHexString("0014f233267911e94dc74df706fe3b697273e212d545"), nil), }, Outputs: []*types.TxOutput{ - types.NewOriginalTxOutput(*consensus.BTMAssetID, 11718900000, mustDecodeString("0014085a02ecdf934a56343aa59a3dec9d9feb86ee43"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 11718900000, testutil.MustDecodeHexString("0014f233267911e94dc74df706fe3b697273e212d545"), nil), types.NewOriginalTxOutput(*consensus.BTMAssetID, 90000000, []byte{byte(vm.OP_FAIL)}, nil), }, }, @@ -146,25 +124,24 @@ func TestValidateTx(t *testing.T) { Inputs: []*types.TxInput{ types.NewSpendInput( [][]byte{ - mustDecodeString("cbd46e05c84c23a1ef7c27dcef189f1d386088a49df1c345de5d988bbe7d557d8406c596d6caea161473f5e3467d3d1883a75a559c71a0be5f2452b8aa3e510e"), - mustDecodeString("7642ba797fd89d1f98a8559b4ca74123697dd4dee882955acd0da9010a80d64e"), + + testutil.MustDecodeHexString("86416e48fe371d4f07afea76aef204d9acb2c1fff6742499d50feda314bc49f478cd28e9d6a4cdba6592da5e5b819cf6c3d40ad6326192ef3e2fcc6f6bfd4509"), + testutil.MustDecodeHexString("7642ba797fd89d1f98a8559b4ca74123697dd4dee882955acd0da9010a80d64e"), }, bc.Hash{V0: 14760873410800997144, V1: 1698395500822741684, V2: 5965908492734661392, V3: 9445539829830863994}, - *consensus.BTMAssetID, 11818900000, 0, mustDecodeString("0014f233267911e94dc74df706fe3b697273e212d545"), [][]byte{}), + *consensus.BTMAssetID, 11818900000, 0, testutil.MustDecodeHexString("0014f233267911e94dc74df706fe3b697273e212d545"), [][]byte{}), types.NewIssuanceInput( - mustDecodeString("fd0aec4229deb281"), + testutil.MustDecodeHexString("fd0aec4229deb281"), 10000000000, - mustDecodeString("ae20ae12def13abe1295b477c24aa8ad5f1a60a60927c355e046bcd078a133b8d94c5151ad"), - [][]byte{ - mustDecodeString("d6b284c40289a9417b53b3351483112ccf8a5f35cdb7812684a6df471a461774b118e546444dd16ddb469b536b96b6185430faff75ffae4661b9853657a2de0f"), - }, - mustDecodeString("7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a207b7d2c0a2020226e616d65223a2022222c0a20202273796d626f6c223a2022220a7d"), + testutil.MustDecodeHexString("51"), + [][]byte{}, + testutil.MustDecodeHexString("7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a207b7d2c0a2020226e616d65223a2022222c0a20202273796d626f6c223a2022220a7d"), ), }, Outputs: []*types.TxOutput{ - types.NewOriginalTxOutput(*consensus.BTMAssetID, 1818900000, mustDecodeString("00147d6b00edfbbc758a5da6130a5fa1a4cfec8422c3"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 1818900000, testutil.MustDecodeHexString("00147d6b00edfbbc758a5da6130a5fa1a4cfec8422c3"), nil), types.NewOriginalTxOutput(*consensus.BTMAssetID, 9900000000, []byte{byte(vm.OP_FAIL)}, nil), - types.NewOriginalTxOutput(bc.AssetID{V0: 18275849036764733644, V1: 7408071477801754980, V2: 2368297496240756305, V3: 216480183129600045}, 10000000000, mustDecodeString("0014447e597c1c326ad1a639f8023d3f87ae22a4e049"), nil), + types.NewOriginalTxOutput(testutil.MustDecodeAsset("2e1e4db789f0a23ccf98038b01ba2949634c940a3f01154b5f73ca7f3ebef7c1"), 10000000000, testutil.MustDecodeHexString("0014447e597c1c326ad1a639f8023d3f87ae22a4e049"), nil), }, }, err: nil, @@ -177,25 +154,25 @@ func TestValidateTx(t *testing.T) { Inputs: []*types.TxInput{ types.NewSpendInput( [][]byte{ - mustDecodeString("23ca3a6f8474b1b9ab8b77fcf3cf3fd9dfa761dff4e5d8551a72307dc065cd19100f3ca9fcca4df2f8842b71dba2fd29b73c1b06b3d8bddc2a71e8cc18842a04"), - mustDecodeString("ca85ea98011ddd592d1f081ebd2a91ac0f4238784222ed85b9d95aeb654f1cf1"), + testutil.MustDecodeHexString("23ca3a6f8474b1b9ab8b77fcf3cf3fd9dfa761dff4e5d8551a72307dc065cd19100f3ca9fcca4df2f8842b71dba2fd29b73c1b06b3d8bddc2a71e8cc18842a04"), + testutil.MustDecodeHexString("ca85ea98011ddd592d1f081ebd2a91ac0f4238784222ed85b9d95aeb654f1cf1"), }, bc.Hash{V0: 14760873410800997144, V1: 1698395500822741684, V2: 5965908492734661392, V3: 9445539829830863994}, - *consensus.BTMAssetID, 11818900000, 0, mustDecodeString("0014e6e1f8b11f1cfb7609037003b90f64837afd272c"), nil), + *consensus.BTMAssetID, 11818900000, 0, testutil.MustDecodeHexString("0014e6e1f8b11f1cfb7609037003b90f64837afd272c"), nil), types.NewIssuanceInput( - mustDecodeString("4b6afc9344c3ce63"), + testutil.MustDecodeHexString("4b6afc9344c3ce63"), 10000000000, - mustDecodeString("ae2054a71277cc162eb3eb21b5bd9fe54402829a53b294deaed91692a2cd8a081f9c5151ad"), + testutil.MustDecodeHexString("ae2054a71277cc162eb3eb21b5bd9fe54402829a53b294deaed91692a2cd8a081f9c5151ad"), [][]byte{ - mustDecodeString("e8f301f7bd3b1e4ca85f1f8acda3a91fb73e717c096b8b82b2c7ed9d25170c0f9fcd9b5e8039094bd1174886f1b5428272eb6c2af03946bf3c2037a4b499c77107b94b96a92088a0d0d3b15559b3a253a4f5f9c7efba233ab0f6896bec23adc6a816c350e08f6b8ac5bc23eb5720173f9190805328af581f34a7fe561358d100"), + testutil.MustDecodeHexString("e8f301f7bd3b1e4ca85f1f8acda3a91fb73e717c096b8b82b2c7ed9d25170c0f9fcd9b5e8039094bd1174886f1b5428272eb6c2af03946bf3c2037a4b499c77107b94b96a92088a0d0d3b15559b3a253a4f5f9c7efba233ab0f6896bec23adc6a816c350e08f6b8ac5bc23eb5720173f9190805328af581f34a7fe561358d100"), }, - mustDecodeString("7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a207b7d2c0a2020226e616d65223a2022222c0a20202273796d626f6c223a2022220a7d"), + testutil.MustDecodeHexString("7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a207b7d2c0a2020226e616d65223a2022222c0a20202273796d626f6c223a2022220a7d"), ), }, Outputs: []*types.TxOutput{ - types.NewOriginalTxOutput(*consensus.BTMAssetID, 1818900000, mustDecodeString("001482b7991d64d001009b673ffe3ca2b35eab14f142"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 1818900000, testutil.MustDecodeHexString("001482b7991d64d001009b673ffe3ca2b35eab14f142"), nil), types.NewOriginalTxOutput(*consensus.BTMAssetID, 10000000000, []byte{byte(vm.OP_FAIL)}, nil), - types.NewOriginalTxOutput(bc.AssetID{V0: 8879089148261671560, V1: 16875272676673176923, V2: 14627348561007036053, V3: 5774520766896450836}, 10000000000, mustDecodeString("0014447e597c1c326ad1a639f8023d3f87ae22a4e049"), nil), + types.NewOriginalTxOutput(bc.AssetID{V0: 8879089148261671560, V1: 16875272676673176923, V2: 14627348561007036053, V3: 5774520766896450836}, 10000000000, testutil.MustDecodeHexString("0014447e597c1c326ad1a639f8023d3f87ae22a4e049"), nil), }, }, err: vm.ErrRunLimitExceeded, @@ -208,15 +185,15 @@ func TestValidateTx(t *testing.T) { Inputs: []*types.TxInput{ types.NewSpendInput( [][]byte{ - mustDecodeString("298fbf48459480914e19a0fc20440b095bd7f38d9f01c56bfc904b4ed4967a7b73f1fc4919f23a7806eeb834a89f8ce696500f4528e8f7bf29c8ee1f38a91e02"), - mustDecodeString("5a260070d967d894a9c4a6e16670c2881ed4c225e12d93b0707156e71fce5bfd"), + testutil.MustDecodeHexString("298fbf48459480914e19a0fc20440b095bd7f38d9f01c56bfc904b4ed4967a7b73f1fc4919f23a7806eeb834a89f8ce696500f4528e8f7bf29c8ee1f38a91e02"), + testutil.MustDecodeHexString("5a260070d967d894a9c4a6e16670c2881ed4c225e12d93b0707156e71fce5bfd"), }, bc.Hash{V0: 3485387979411255237, V1: 15603105575416882039, V2: 5974145557334619041, V3: 16513948410238218452}, - *consensus.BTMAssetID, 21819700000, 0, mustDecodeString("001411ef7695d46e1f9288d996c3daa6ff4d956ac355"), nil), + *consensus.BTMAssetID, 21819700000, 0, testutil.MustDecodeHexString("001411ef7695d46e1f9288d996c3daa6ff4d956ac355"), nil), }, Outputs: []*types.TxOutput{ - types.NewOriginalTxOutput(*consensus.BTMAssetID, 11818900000, mustDecodeString("001415c956112c2b46354690e36051803cc9d5a8f26b"), nil), - types.NewOriginalTxOutput(*consensus.BTMAssetID, 10000000000, mustDecodeString("00149c9dd93184cc34ac5d47c145c5af3df852235aad"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 11818900000, testutil.MustDecodeHexString("001415c956112c2b46354690e36051803cc9d5a8f26b"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 10000000000, testutil.MustDecodeHexString("00149c9dd93184cc34ac5d47c145c5af3df852235aad"), nil), }, }, err: vm.ErrFalseVMResult, @@ -228,29 +205,29 @@ func TestValidateTx(t *testing.T) { SerializedSize: 508, Inputs: []*types.TxInput{ types.NewSpendInput( - [][]byte{mustDecodeString("8fb54963e411982c0855924b22a07ea432df0f78a90558d7a759b93275991da18e101b8bcd2227b07ed5666732826e19d34e715dd432bfac49c5e7a5833b2e0a")}, + [][]byte{testutil.MustDecodeHexString("f0b2326e8bb5ef8d069587a144edf7d249d2bb647ea7cbaed4a2ebb19865f6a9b8e63e911338a0b6cfb2992af25b3da4907682bc985305d737f91e96b9ac7b0b")}, bc.Hash{V0: 13727785470566991667, V1: 17422390991613608658, V2: 10016033157382430074, V3: 8274310611876171875}, bc.AssetID{V0: 986236576456443635, V1: 13806502593573493203, V2: 9657495453304566675, V3: 15226142438973879401}, 1000, 1, - mustDecodeString("207642ba797fd89d1f98a8559b4ca74123697dd4dee882955acd0da9010a80d64e7403ae7cac00c0"), + testutil.MustDecodeHexString("207642ba797fd89d1f98a8559b4ca74123697dd4dee882955acd0da9010a80d64e7403ae7cac00c0"), nil), types.NewSpendInput( [][]byte{ - mustDecodeString("ae8eb568b080d43d05a4f84f92e9f189937b490a34416ec4b111b995af45f9ac4d776af528294f22465c1695949746bc6ca6a605ee5cc7e9c394e316c3fca30c"), - mustDecodeString("7642ba797fd89d1f98a8559b4ca74123697dd4dee882955acd0da9010a80d64e"), + testutil.MustDecodeHexString("bc91faef22f5926c4042545e0b15649fe56c7e0a8d49a68b2460caf41511f1fb39fa82bc3d85f68658486d5b3ebf85351536898ce6e5f626a3bb111cad78dc02"), + testutil.MustDecodeHexString("7642ba797fd89d1f98a8559b4ca74123697dd4dee882955acd0da9010a80d64e"), }, bc.Hash{V0: 5430419158397285610, V1: 15989125147582690097, V2: 3140150800656736345, V3: 4704385074037173738}, - *consensus.BTMAssetID, 9800000000, 2, mustDecodeString("0014f233267911e94dc74df706fe3b697273e212d545"), + *consensus.BTMAssetID, 9800000000, 2, testutil.MustDecodeHexString("0014f233267911e94dc74df706fe3b697273e212d545"), nil), }, Outputs: []*types.TxOutput{ types.NewOriginalTxOutput( bc.AssetID{V0: 986236576456443635, V1: 13806502593573493203, V2: 9657495453304566675, V3: 15226142438973879401}, 1000, - mustDecodeString("001437e1aec83a4e6587ca9609e4e5aa728db7007449"), + testutil.MustDecodeHexString("001437e1aec83a4e6587ca9609e4e5aa728db7007449"), nil), - types.NewOriginalTxOutput(*consensus.BTMAssetID, 9750000000, mustDecodeString("0014ec75fda5c727cb0d41137ab62afbf9070a405744"), nil), + types.NewOriginalTxOutput(*consensus.BTMAssetID, 9750000000, testutil.MustDecodeHexString("0014ec75fda5c727cb0d41137ab62afbf9070a405744"), nil), }, }, err: nil, @@ -258,17 +235,8 @@ func TestValidateTx(t *testing.T) { } for i, c := range cases { - _, err := ValidateTx(types.MapTx(c.txData), mockBlock(), converter) - if rootErr(err) != c.err { + if _, err := ValidateTx(types.MapTx(c.txData), mockBlock(), converter); rootErr(err) != c.err { t.Errorf("case #%d (%s) got error %s, want %s; validationState is:\n", i, c.desc, err, c.err) } } } - -func mustDecodeString(hexString string) []byte { - bytes, err := hex.DecodeString(hexString) - if err != nil { - panic(err) - } - return bytes -} diff --git a/protocol/validation/tx_test.go b/protocol/validation/tx_test.go index 74ef533a..a23789ca 100644 --- a/protocol/validation/tx_test.go +++ b/protocol/validation/tx_test.go @@ -333,7 +333,7 @@ func TestTxValidation(t *testing.T) { Position: uint64(len(tx.ResultIds)), } prog := &bc.Program{txOutput.VMVersion, txOutput.ControlProgram} - output := bc.NewOutput(src, prog, nil, uint64(len(tx.ResultIds))) + output := bc.NewOriginalOutput(src, prog, nil, uint64(len(tx.ResultIds))) outputID := bc.EntryID(output) tx.Entries[outputID] = output @@ -392,10 +392,10 @@ func TestTxValidation(t *testing.T) { desc: "underflowing mux destination amounts", f: func() { mux.WitnessDestinations[0].Value.Amount = math.MaxInt64 - out := tx.Entries[*mux.WitnessDestinations[0].Ref].(*bc.Output) + out := tx.Entries[*mux.WitnessDestinations[0].Ref].(*bc.OriginalOutput) out.Source.Value.Amount = math.MaxInt64 mux.WitnessDestinations[1].Value.Amount = math.MaxInt64 - out = tx.Entries[*mux.WitnessDestinations[1].Ref].(*bc.Output) + out = tx.Entries[*mux.WitnessDestinations[1].Ref].(*bc.OriginalOutput) out.Source.Value.Amount = math.MaxInt64 }, err: ErrOverflow, @@ -412,7 +412,7 @@ func TestTxValidation(t *testing.T) { { desc: "mismatched output source / mux dest position", f: func() { - tx.Entries[*tx.ResultIds[0]].(*bc.Output).Source.Position = 1 + tx.Entries[*tx.ResultIds[0]].(*bc.OriginalOutput).Source.Position = 1 }, err: ErrMismatchedPosition, }, @@ -433,7 +433,7 @@ func TestTxValidation(t *testing.T) { fixture2 := sample(t, fixture) tx2 := types.NewTx(*fixture2.tx).Tx out2ID := tx2.ResultIds[0] - out2 := tx2.Entries[*out2ID].(*bc.Output) + out2 := tx2.Entries[*out2ID].(*bc.OriginalOutput) tx.Entries[*out2ID] = out2 mux.WitnessDestinations[0].Ref = out2ID }, @@ -465,7 +465,7 @@ func TestTxValidation(t *testing.T) { desc: "mismatched mux dest value / output source value", f: func() { outID := tx.ResultIds[0] - out := tx.Entries[*outID].(*bc.Output) + out := tx.Entries[*outID].(*bc.OriginalOutput) mux.WitnessDestinations[0].Value = &bc.AssetAmount{ AssetId: out.Source.Value.AssetId, Amount: out.Source.Value.Amount + 1, @@ -508,7 +508,7 @@ func TestTxValidation(t *testing.T) { desc: "mismatched spent source/witness value", f: func() { spend := txSpend(t, tx, 1) - spentOutput := tx.Entries[*spend.SpentOutputId].(*bc.Output) + spentOutput := tx.Entries[*spend.SpentOutputId].(*bc.OriginalOutput) spentOutput.Source.Value = &bc.AssetAmount{ AssetId: spend.WitnessDestination.Value.AssetId, Amount: spend.WitnessDestination.Value.Amount + 1, @@ -606,7 +606,7 @@ func TestTxValidation(t *testing.T) { desc: "normal retirement output", f: func() { outputID := tx.ResultIds[0] - output := tx.Entries[*outputID].(*bc.Output) + output := tx.Entries[*outputID].(*bc.OriginalOutput) retirement := bc.NewRetirement(output.Source, output.Ordinal) retirementID := bc.EntryID(retirement) tx.Entries[retirementID] = retirement @@ -620,8 +620,8 @@ func TestTxValidation(t *testing.T) { desc: "ordinal doesn't matter for prevouts", f: func() { spend := txSpend(t, tx, 1) - prevout := tx.Entries[*spend.SpentOutputId].(*bc.Output) - newPrevout := bc.NewOutput(prevout.Source, prevout.ControlProgram, prevout.StateData, 10) + prevout := tx.Entries[*spend.SpentOutputId].(*bc.OriginalOutput) + newPrevout := bc.NewOriginalOutput(prevout.Source, prevout.ControlProgram, prevout.StateData, 10) hash := bc.EntryID(newPrevout) spend.SpentOutputId = &hash }, @@ -1199,7 +1199,7 @@ func txSpend(t *testing.T, tx *bc.Tx, index int) *bc.Spend { func getMuxID(tx *bc.Tx) *bc.Hash { out := tx.Entries[*tx.ResultIds[0]] switch result := out.(type) { - case *bc.Output: + case *bc.OriginalOutput: return result.Source.Ref case *bc.Retirement: return result.Source.Ref diff --git a/protocol/validation/vmcontext.go b/protocol/validation/vmcontext.go index cc62afaf..cdaedfa8 100644 --- a/protocol/validation/vmcontext.go +++ b/protocol/validation/vmcontext.go @@ -33,7 +33,7 @@ func NewTxVMContext(vs *validationState, entry bc.Entry, prog *bc.Program, state destPos = &e.WitnessDestination.Position case *bc.Spend: - spentOutput := tx.Entries[*e.SpentOutputId].(*bc.Output) + spentOutput := tx.Entries[*e.SpentOutputId].(*bc.OriginalOutput) a1 := spentOutput.Source.Value.AssetId.Bytes() assetID = &a1 amount = &spentOutput.Source.Value.Amount @@ -120,7 +120,7 @@ func (ec *entryContext) checkOutput(index uint64, amount uint64, assetID []byte, } switch e := e.(type) { - case *bc.Output: + case *bc.OriginalOutput: return check(e.ControlProgram, e.Source.Value, e.StateData), nil case *bc.Retirement: diff --git a/test/tx_test_util.go b/test/tx_test_util.go index f138d3cb..5aebd17c 100644 --- a/test/tx_test_util.go +++ b/test/tx_test_util.go @@ -274,7 +274,7 @@ func txFee(tx *types.Tx) uint64 { // CreateSpendInput create SpendInput which spent the output from tx func CreateSpendInput(tx *types.Tx, outputIndex uint64) (*types.SpendInput, error) { outputID := tx.ResultIds[outputIndex] - output, ok := tx.Entries[*outputID].(*bc.Output) + output, ok := tx.Entries[*outputID].(*bc.OriginalOutput) if !ok { return nil, fmt.Errorf("retirement can't be spent") } diff --git a/test/utxo_view/utxo_view_test_util.go b/test/utxo_view/utxo_view_test_util.go index 86a2ea7e..f408993d 100644 --- a/test/utxo_view/utxo_view_test_util.go +++ b/test/utxo_view/utxo_view_test_util.go @@ -27,12 +27,12 @@ func newTx(t *types.Tx) *tx { } func (t *tx) getSourceID(outIndex int) *bc.Hash { - output := t.Tx.Entries[*t.Tx.OutputID(outIndex)].(*bc.Output) + output := t.Tx.Entries[*t.Tx.OutputID(outIndex)].(*bc.OriginalOutput) return output.Source.Ref } func (t *tx) getAmount(outIndex int) uint64 { - output := t.Tx.Entries[*t.Tx.OutputID(outIndex)].(*bc.Output) + output := t.Tx.Entries[*t.Tx.OutputID(outIndex)].(*bc.OriginalOutput) return output.Source.Value.Amount } diff --git a/wallet/annotated.go b/wallet/annotated.go index 457072d1..68bb0a87 100644 --- a/wallet/annotated.go +++ b/wallet/annotated.go @@ -279,7 +279,7 @@ func (w *Wallet) BuildAnnotatedOutput(tx *types.Tx, idx int) *query.AnnotatedOut case orig.OutputType() == types.OriginalOutputType: out.Type = "control" if e, ok := tx.Entries[*outid]; ok { - if output, ok := e.(*bc.Output); ok { + if output, ok := e.(*bc.OriginalOutput); ok { out.StateData = stateDataStrings(output.StateData) } } diff --git a/wallet/utxo.go b/wallet/utxo.go index 7ff2d1d8..09521911 100644 --- a/wallet/utxo.go +++ b/wallet/utxo.go @@ -69,7 +69,7 @@ func (w *Wallet) detachUtxos(batch dbm.Batch, b *types.Block) { for txIndex := len(b.Transactions) - 1; txIndex >= 0; txIndex-- { tx := b.Transactions[txIndex] for j := range tx.Outputs { - resOut, err := tx.Output(*tx.ResultIds[j]) + resOut, err := tx.OriginalOutput(*tx.ResultIds[j]) if err != nil { continue } @@ -154,7 +154,7 @@ func txInToUtxos(tx *types.Tx) []*account.UTXO { switch inp := e.(type) { case *bc.Spend: - resOut, err := tx.Output(*inp.SpentOutputId) + resOut, err := tx.OriginalOutput(*inp.SpentOutputId) if err != nil { log.WithFields(log.Fields{"module": logModule, "err": err}).Error("txInToUtxos fail on get resOut") continue @@ -206,7 +206,7 @@ func txOutToUtxos(tx *types.Tx, blockHeight uint64) []*account.UTXO { var utxo *account.UTXO switch bcOut := entryOutput.(type) { - case *bc.Output: + case *bc.OriginalOutput: if out.AssetAmount.Amount == uint64(0) { continue } diff --git a/wallet/utxo_test.go b/wallet/utxo_test.go index 980d84bf..27a1dfc3 100644 --- a/wallet/utxo_test.go +++ b/wallet/utxo_test.go @@ -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) } } -- 2.11.0