From f30b7541256e6a7f6f875994cb08edf3bddab93c Mon Sep 17 00:00:00 2001 From: Paladz Date: Thu, 4 Jul 2019 13:44:32 +0800 Subject: [PATCH] Small edit (#241) * check the accesstoken folder * remove unused testutil/expect.go * remove testutil/parameter.go * small changes * hash without vaule * remove the duplicate value in crosschain input * delete unused file --- accesstoken/accesstoken.go | 11 +- accesstoken/accesstoken_test.go | 25 ++-- account/accounts_test.go | 14 +-- blockchain/txbuilder/txbuilder_test.go | 4 +- common/bit_map.go | 53 -------- protocol/bc/bc.pb.go | 140 ++++++++++----------- protocol/bc/bc.proto | 11 +- protocol/bc/crosschain_input.go | 4 +- protocol/bc/types/block.go | 77 ++++-------- protocol/bc/types/block_header.go | 9 +- protocol/bc/types/block_witness.go | 8 +- protocol/bc/types/block_witness_test.go | 2 +- protocol/bc/types/crosschain_input.go | 18 +-- protocol/bc/types/map.go | 16 +-- protocol/bc/types/output_commitment.go | 10 -- protocol/bc/types/output_commitment_test.go | 3 +- protocol/bc/types/txinput.go | 115 ++++++++--------- protocol/bc/types/txinput_test.go | 34 ++--- protocol/bc/types/txoutput.go | 12 +- protocol/bc/types/txoutput_test.go | 2 +- .../bc/types/{vote_txoutput.go => vote_output.go} | 8 +- protocol/state/vote_result.go | 4 +- protocol/validation/tx.go | 16 ++- protocol/validation/vmcontext.go | 7 +- testutil/expect.go | 27 ---- testutil/parameter.go | 10 -- wallet/utxo_test.go | 16 +-- 27 files changed, 264 insertions(+), 392 deletions(-) delete mode 100644 common/bit_map.go rename protocol/bc/types/{vote_txoutput.go => vote_output.go} (73%) delete mode 100644 testutil/expect.go delete mode 100644 testutil/parameter.go diff --git a/accesstoken/accesstoken.go b/accesstoken/accesstoken.go index a2b9d858..640f4aed 100644 --- a/accesstoken/accesstoken.go +++ b/accesstoken/accesstoken.go @@ -72,7 +72,6 @@ func (cs *CredentialStore) Create(id, typ string) (*Token, error) { hashedSecret := make([]byte, tokenSize) sha3pool.Sum256(hashedSecret, secret) - token := &Token{ ID: id, Token: fmt.Sprintf("%s:%x", id, hashedSecret), @@ -84,8 +83,8 @@ func (cs *CredentialStore) Create(id, typ string) (*Token, error) { if err != nil { return nil, err } - cs.DB.Set(key, value) + cs.DB.Set(key, value) return token, nil } @@ -95,12 +94,12 @@ func (cs *CredentialStore) Check(id string, secret string) error { return errors.WithDetailf(ErrBadID, "invalid id %q", id) } - var value []byte - token := &Token{} - - if value = cs.DB.Get([]byte(id)); value == nil { + value := cs.DB.Get([]byte(id)) + if value == nil { return errors.WithDetailf(ErrNoMatchID, "check id %q nonexisting", id) } + + token := &Token{} if err := json.Unmarshal(value, token); err != nil { return err } diff --git a/accesstoken/accesstoken_test.go b/accesstoken/accesstoken_test.go index 8c0fd1d1..16c470bd 100644 --- a/accesstoken/accesstoken_test.go +++ b/accesstoken/accesstoken_test.go @@ -1,7 +1,6 @@ package accesstoken import ( - "context" "os" "strings" "testing" @@ -27,23 +26,21 @@ func TestCreate(t *testing.T) { } for _, c := range cases { - _, err := cs.Create(c.id, c.typ) - if errors.Root(err) != c.want { + if _, err := cs.Create(c.id, c.typ); errors.Root(err) != c.want { t.Errorf("Create(%s, %s) error = %s want %s", c.id, c.typ, err, c.want) } } } func TestList(t *testing.T) { - ctx := context.Background() testDB := dbm.NewDB("testdb", "leveldb", "temp") defer os.RemoveAll("temp") - cs := NewStore(testDB) + cs := NewStore(testDB) tokenMap := make(map[string]*Token) - tokenMap["ab"] = mustCreateToken(ctx, t, cs, "ab", "test") - tokenMap["bc"] = mustCreateToken(ctx, t, cs, "bc", "test") - tokenMap["cd"] = mustCreateToken(ctx, t, cs, "cd", "test") + tokenMap["ab"] = mustCreateToken(t, cs, "ab", "test") + tokenMap["bc"] = mustCreateToken(t, cs, "bc", "test") + tokenMap["cd"] = mustCreateToken(t, cs, "cd", "test") got, err := cs.List() if err != nil { @@ -53,6 +50,7 @@ func TestList(t *testing.T) { if len(got) != len(tokenMap) { t.Error("List errored: get invalid length") } + for _, v := range got { if v.Token != tokenMap[v.ID].Token { t.Errorf("List error: ID: %s, expected token: %s, DB token: %s", v.ID, *tokenMap[v.ID], v.Token) @@ -62,12 +60,11 @@ func TestList(t *testing.T) { } func TestCheck(t *testing.T) { - ctx := context.Background() testDB := dbm.NewDB("testdb", "leveldb", "temp") defer os.RemoveAll("temp") cs := NewStore(testDB) - token := mustCreateToken(ctx, t, cs, "x", "client") + token := mustCreateToken(t, cs, "x", "client") tokenParts := strings.Split(token.Token, ":") if err := cs.Check(tokenParts[0], tokenParts[1]); err != nil { @@ -80,13 +77,12 @@ func TestCheck(t *testing.T) { } func TestDelete(t *testing.T) { - ctx := context.Background() testDB := dbm.NewDB("testdb", "leveldb", "temp") defer os.RemoveAll("temp") cs := NewStore(testDB) const id = "Y" - mustCreateToken(ctx, t, cs, id, "client") + mustCreateToken(t, cs, id, "client") err := cs.Delete(id) if err != nil { @@ -104,13 +100,12 @@ func TestDeleteWithInvalidId(t *testing.T) { defer os.RemoveAll("temp") cs := NewStore(testDB) - err := cs.Delete("@") - if errors.Root(err) != ErrBadID { + if err := cs.Delete("@"); errors.Root(err) != ErrBadID { t.Errorf("Deletion with invalid id success, while it should not") } } -func mustCreateToken(ctx context.Context, t *testing.T, cs *CredentialStore, id, typ string) *Token { +func mustCreateToken(t *testing.T, cs *CredentialStore, id, typ string) *Token { token, err := cs.Create(id, typ) if err != nil { t.Fatal(err) diff --git a/account/accounts_test.go b/account/accounts_test.go index cd572198..d2722bb5 100644 --- a/account/accounts_test.go +++ b/account/accounts_test.go @@ -61,7 +61,7 @@ func TestCreateAccount(t *testing.T) { m := mockAccountManager(t) account, err := m.Create([]chainkd.XPub{testutil.TestXPub}, 1, "test-alias", signers.BIP0044) if err != nil { - testutil.FatalErr(t, err) + t.Fatal(err) } found, err := m.FindByID(account.ID) @@ -121,12 +121,12 @@ func TestDeleteAccount(t *testing.T) { account1, err := m.Create([]chainkd.XPub{testutil.TestXPub}, 1, "test-alias1", signers.BIP0044) if err != nil { - testutil.FatalErr(t, err) + t.Fatal(err) } account2, err := m.Create([]chainkd.XPub{testutil.TestXPub}, 1, "test-alias2", signers.BIP0044) if err != nil { - testutil.FatalErr(t, err) + t.Fatal(err) } found, err := m.FindByID(account1.ID) @@ -135,7 +135,7 @@ func TestDeleteAccount(t *testing.T) { } if err = m.DeleteAccount(account2.ID); err != nil { - testutil.FatalErr(t, err) + t.Fatal(err) } found, err = m.FindByID(account2.ID) @@ -150,7 +150,7 @@ func TestFindByID(t *testing.T) { found, err := m.FindByID(account.ID) if err != nil { - testutil.FatalErr(t, err) + t.Fatal(err) } if !testutil.DeepEqual(account, found) { @@ -164,7 +164,7 @@ func TestFindByAlias(t *testing.T) { found, err := m.FindByAlias("some-alias") if err != nil { - testutil.FatalErr(t, err) + t.Fatal(err) } if !testutil.DeepEqual(account, found) { @@ -228,7 +228,7 @@ func mockAccountManager(t *testing.T) *Manager { func (m *Manager) createTestAccount(t testing.TB, alias string, tags map[string]interface{}) *Account { account, err := m.Create([]chainkd.XPub{testutil.TestXPub}, 1, alias, signers.BIP0044) if err != nil { - testutil.FatalErr(t, err) + t.Fatal(err) } return account diff --git a/blockchain/txbuilder/txbuilder_test.go b/blockchain/txbuilder/txbuilder_test.go index 8cd14327..5176a9a9 100644 --- a/blockchain/txbuilder/txbuilder_test.go +++ b/blockchain/txbuilder/txbuilder_test.go @@ -59,7 +59,7 @@ func TestBuildIntra(t *testing.T) { expiryTime := time.Now().Add(time.Minute) got, err := Build(ctx, nil, actions, expiryTime, 0) if err != nil { - testutil.FatalErr(t, err) + t.Fatal(err) } want := &Template{ @@ -115,7 +115,7 @@ func TestBuildCrossOut(t *testing.T) { expiryTime := time.Now().Add(time.Minute) got, err := Build(ctx, nil, actions, expiryTime, 0) if err != nil { - testutil.FatalErr(t, err) + t.Fatal(err) } want := &Template{ diff --git a/common/bit_map.go b/common/bit_map.go deleted file mode 100644 index 6dabaebd..00000000 --- a/common/bit_map.go +++ /dev/null @@ -1,53 +0,0 @@ -package common - -import ( - "errors" -) - -const bitLen = 32 - -var ( - errIndexOutOfBounds = errors.New("index out of bounds error") -) - -type BitMap struct { - size uint32 - arr []int32 -} - -func NewBitMap(size uint32) *BitMap { - obj := &BitMap{size: size} - num := (size + bitLen - 1) / bitLen - arr := make([]int32, num) - obj.arr = arr - return obj -} - -func (b *BitMap) Set(index uint32) error { - if index >= b.size { - return errIndexOutOfBounds - } - - arrIndex, bitIndex := index / bitLen, index % bitLen - b.arr[arrIndex] |= (1 << bitIndex) - return nil -} - -func (b *BitMap) Clean(index uint32) error { - if index >= b.size { - return errIndexOutOfBounds - } - - arrIndex, bitIndex := index / bitLen, index % bitLen - b.arr[arrIndex] &= (^(1 << bitIndex)) - return nil -} - -func (b *BitMap) Test(index uint32) (bool, error) { - if index >= b.size { - return false, errIndexOutOfBounds - } - - arrIndex, bitIndex := index / bitLen, index % bitLen - return b.arr[arrIndex] & (1 << bitIndex) != 0, nil -} diff --git a/protocol/bc/bc.pb.go b/protocol/bc/bc.pb.go index d31e7310..b65b3b7f 100644 --- a/protocol/bc/bc.pb.go +++ b/protocol/bc/bc.pb.go @@ -693,12 +693,11 @@ func (m *Spend) GetOrdinal() uint64 { type CrossChainInput struct { MainchainOutputId *Hash `protobuf:"bytes,1,opt,name=mainchain_output_id,json=mainchainOutputId" json:"mainchain_output_id,omitempty"` - Value *AssetAmount `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` - WitnessDestination *ValueDestination `protobuf:"bytes,3,opt,name=witness_destination,json=witnessDestination" json:"witness_destination,omitempty"` - ControlProgram *Program `protobuf:"bytes,4,opt,name=control_program,json=controlProgram" json:"control_program,omitempty"` - AssetDefinition *AssetDefinition `protobuf:"bytes,5,opt,name=asset_definition,json=assetDefinition" json:"asset_definition,omitempty"` - WitnessArguments [][]byte `protobuf:"bytes,6,rep,name=witness_arguments,json=witnessArguments,proto3" json:"witness_arguments,omitempty"` - Ordinal uint64 `protobuf:"varint,7,opt,name=ordinal" json:"ordinal,omitempty"` + WitnessDestination *ValueDestination `protobuf:"bytes,2,opt,name=witness_destination,json=witnessDestination" json:"witness_destination,omitempty"` + ControlProgram *Program `protobuf:"bytes,3,opt,name=control_program,json=controlProgram" json:"control_program,omitempty"` + AssetDefinition *AssetDefinition `protobuf:"bytes,4,opt,name=asset_definition,json=assetDefinition" json:"asset_definition,omitempty"` + WitnessArguments [][]byte `protobuf:"bytes,5,rep,name=witness_arguments,json=witnessArguments,proto3" json:"witness_arguments,omitempty"` + Ordinal uint64 `protobuf:"varint,6,opt,name=ordinal" json:"ordinal,omitempty"` } func (m *CrossChainInput) Reset() { *m = CrossChainInput{} } @@ -713,13 +712,6 @@ func (m *CrossChainInput) GetMainchainOutputId() *Hash { return nil } -func (m *CrossChainInput) GetValue() *AssetAmount { - if m != nil { - return m.Value - } - return nil -} - func (m *CrossChainInput) GetWitnessDestination() *ValueDestination { if m != nil { return m.WitnessDestination @@ -781,65 +773,65 @@ func init() { func init() { proto.RegisterFile("bc.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 960 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4d, 0x6f, 0x1b, 0x37, - 0x13, 0x86, 0x56, 0x6b, 0x49, 0x1e, 0x39, 0x96, 0x44, 0x27, 0xef, 0xbb, 0x08, 0x52, 0xd4, 0x58, - 0x20, 0x75, 0x8a, 0x02, 0x86, 0x3f, 0xd2, 0x8f, 0x43, 0x51, 0xd4, 0xb5, 0x9b, 0x46, 0x87, 0x20, - 0x05, 0x6d, 0xe8, 0xba, 0xa0, 0x76, 0x29, 0x89, 0xa8, 0xb4, 0x54, 0x49, 0xae, 0xea, 0xf8, 0x2f, - 0xf4, 0xdc, 0x43, 0x7f, 0x51, 0x0f, 0x45, 0xff, 0x4e, 0xaf, 0x2d, 0x38, 0xcb, 0x95, 0x56, 0x1f, - 0xb6, 0x13, 0x14, 0x45, 0xdb, 0xdb, 0xce, 0x70, 0xf8, 0xc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5, 0x3c, 0x3f, 0xc0, 0x80, 0xbc, 0x94, 0x6e, 0x72, 0x5b, 0x73, 0x79, 0xef, - 0xd8, 0x5c, 0x1b, 0x9b, 0xbb, 0xba, 0xb9, 0xb9, 0xcb, 0x15, 0xfa, 0xcb, 0x4a, 0xbf, 0x06, 0xa0, - 0xdc, 0x08, 0xc5, 0x6d, 0xe0, 0xdb, 0x0b, 0x5d, 0x02, 0xf4, 0x96, 0x01, 0x7f, 0xa9, 0xc0, 0xd6, - 0xe5, 0x94, 0xa7, 0xc9, 0x7f, 0x5e, 0x9a, 0xdf, 0x3d, 0x68, 0x2d, 0x46, 0x22, 0x3f, 0xee, 0xcf, - 0x60, 0x6f, 0xc2, 0x44, 0x1a, 0x5b, 0xcf, 0x1d, 0x75, 0x75, 0xe6, 0x41, 0xf3, 0xda, 0xde, 0xf2, - 0x9d, 0x70, 0x8b, 0x04, 0xd5, 0x77, 0x94, 0x60, 0xc3, 0x20, 0xf8, 0xf7, 0x0f, 0xc2, 0x17, 0xd0, - 0xce, 0x9f, 0x84, 0xc9, 0xfc, 0x4d, 0xe7, 0xfe, 0xf8, 0x7b, 0x73, 0xba, 0x8b, 0xe7, 0x1e, 0x6d, - 0xb1, 0x95, 0xf7, 0xdf, 0x46, 0xe1, 0x6b, 0xf7, 0x0b, 0x5f, 0x5f, 0x12, 0xbe, 0x5f, 0xc3, 0x47, - 0xf8, 0xe9, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x1b, 0x9e, 0x47, 0x90, 0x0b, 0x00, 0x00, + // 951 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x5f, 0x6f, 0x23, 0x35, + 0x10, 0x57, 0x36, 0xdb, 0x24, 0x9d, 0xf4, 0x9a, 0xc4, 0xbd, 0x83, 0xd5, 0xe9, 0x10, 0xd5, 0x4a, + 0x47, 0x0f, 0x21, 0x55, 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0x59, 0x69, 0x0b, 0x00, 0x00, } diff --git a/protocol/bc/bc.proto b/protocol/bc/bc.proto index d3085c08..59190d4c 100644 --- a/protocol/bc/bc.proto +++ b/protocol/bc/bc.proto @@ -127,10 +127,9 @@ message Spend { message CrossChainInput { Hash mainchain_output_id = 1; - AssetAmount value = 2; - ValueDestination witness_destination = 3; - Program control_program = 4; - AssetDefinition asset_definition = 5; - repeated bytes witness_arguments = 6; - uint64 ordinal = 7; + ValueDestination witness_destination = 2; + Program control_program = 3; + AssetDefinition asset_definition = 4; + repeated bytes witness_arguments = 5; + uint64 ordinal = 6; } diff --git a/protocol/bc/crosschain_input.go b/protocol/bc/crosschain_input.go index 123ce253..e9014c27 100644 --- a/protocol/bc/crosschain_input.go +++ b/protocol/bc/crosschain_input.go @@ -9,7 +9,6 @@ func (CrossChainInput) typ() string { return "crosschaininput1" } func (cci *CrossChainInput) writeForHash(w io.Writer) { mustWriteForHash(w, cci.MainchainOutputId) - mustWriteForHash(w, cci.Value) mustWriteForHash(w, cci.AssetDefinition) } @@ -23,10 +22,9 @@ func (cci *CrossChainInput) SetDestination(id *Hash, val *AssetAmount, pos uint6 } // NewCrossChainInput creates a new CrossChainInput. -func NewCrossChainInput(mainchainOutputID *Hash, value *AssetAmount, prog *Program, ordinal uint64, assetDef *AssetDefinition) *CrossChainInput { +func NewCrossChainInput(mainchainOutputID *Hash, prog *Program, ordinal uint64, assetDef *AssetDefinition) *CrossChainInput { return &CrossChainInput{ MainchainOutputId: mainchainOutputID, - Value: value, Ordinal: ordinal, ControlProgram: prog, AssetDefinition: assetDef, diff --git a/protocol/bc/types/block.go b/protocol/bc/types/block.go index 84c9d261..67198c42 100644 --- a/protocol/bc/types/block.go +++ b/protocol/bc/types/block.go @@ -25,13 +25,15 @@ type Block struct { Transactions []*Tx } -// MarshalText fulfills the json.Marshaler interface. This guarantees that -// blocks will get deserialized correctly when being parsed from HTTP requests. -func (b *Block) MarshalText() ([]byte, error) { +func (b *Block) marshalText(serflags uint8) ([]byte, error) { buf := bufpool.Get() defer bufpool.Put(buf) - if _, err := b.WriteTo(buf); err != nil { + ew := errors.NewWriter(buf) + if err := b.writeTo(ew, serflags); err != nil { + return nil, err + } + if err := ew.Err(); err != nil { return nil, err } @@ -40,6 +42,22 @@ func (b *Block) MarshalText() ([]byte, error) { return enc, nil } +// MarshalText fulfills the json.Marshaler interface. This guarantees that +// blocks will get deserialized correctly when being parsed from HTTP requests. +func (b *Block) MarshalText() ([]byte, error) { + return b.marshalText(SerBlockFull) +} + +// MarshalTextForBlockHeader fulfills the json.Marshaler interface. +func (b *Block) MarshalTextForBlockHeader() ([]byte, error) { + return b.marshalText(SerBlockHeader) +} + +// MarshalTextForTransactions fulfills the json.Marshaler interface. +func (b *Block) MarshalTextForTransactions() ([]byte, error) { + return b.marshalText(SerBlockTransactions) +} + // UnmarshalText fulfills the encoding.TextUnmarshaler interface. func (b *Block) UnmarshalText(text []byte) error { decoded := make([]byte, hex.DecodedLen(len(text))) @@ -58,42 +76,6 @@ func (b *Block) UnmarshalText(text []byte) error { return nil } -// MarshalTextForBlockHeader fulfills the json.Marshaler interface. -func (b *Block) MarshalTextForBlockHeader() ([]byte, error) { - buf := bufpool.Get() - defer bufpool.Put(buf) - - ew := errors.NewWriter(buf) - if err := b.writeTo(ew, SerBlockHeader); err != nil { - return nil, err - } - if err := ew.Err(); err != nil { - return nil, err - } - - enc := make([]byte, hex.EncodedLen(buf.Len())) - hex.Encode(enc, buf.Bytes()) - return enc, nil -} - -// MarshalTextForTransactions fulfills the json.Marshaler interface. -func (b *Block) MarshalTextForTransactions() ([]byte, error) { - buf := bufpool.Get() - defer bufpool.Put(buf) - - ew := errors.NewWriter(buf) - if err := b.writeTo(ew, SerBlockTransactions); err != nil { - return nil, err - } - if err := ew.Err(); err != nil { - return nil, err - } - - enc := make([]byte, hex.EncodedLen(buf.Len())) - hex.Encode(enc, buf.Bytes()) - return enc, nil -} - func (b *Block) readFrom(r *blockchain.Reader) error { serflag, err := b.BlockHeader.readFrom(r) if err != nil { @@ -120,7 +102,6 @@ func (b *Block) readFrom(r *blockchain.Reader) error { return nil } -// WriteTo will write block to input io.Writer func (b *Block) WriteTo(w io.Writer) (int64, error) { ew := errors.NewWriter(w) if err := b.writeTo(ew, SerBlockFull); err != nil { @@ -130,16 +111,12 @@ func (b *Block) WriteTo(w io.Writer) (int64, error) { } func (b *Block) writeTo(w io.Writer, serflags uint8) error { - if serflags != SerBlockTransactions { - if err := b.BlockHeader.writeTo(w, serflags); err != nil { - return err - } + if err := b.BlockHeader.writeTo(w, serflags); err != nil { + return err + } - if serflags == SerBlockHeader { - return nil - } - } else { - w.Write([]byte{serflags}) + if serflags == SerBlockHeader { + return nil } if _, err := blockchain.WriteVarint31(w, uint64(len(b.Transactions))); err != nil { diff --git a/protocol/bc/types/block_header.go b/protocol/bc/types/block_header.go index 392b3ec1..848f3f7b 100644 --- a/protocol/bc/types/block_header.go +++ b/protocol/bc/types/block_header.go @@ -69,7 +69,10 @@ func (bh *BlockHeader) UnmarshalText(text []byte) error { func (bh *BlockHeader) readFrom(r *blockchain.Reader) (serflag uint8, err error) { var serflags [1]byte - io.ReadFull(r, serflags[:]) + if _, err := io.ReadFull(r, serflags[:]); err != nil { + return 0, err + } + serflag = serflags[0] switch serflag { case SerBlockHeader, SerBlockFull: @@ -112,6 +115,10 @@ func (bh *BlockHeader) WriteTo(w io.Writer) (int64, error) { func (bh *BlockHeader) writeTo(w io.Writer, serflags uint8) (err error) { w.Write([]byte{serflags}) + if serflags == SerBlockTransactions { + return nil + } + if _, err = blockchain.WriteVarint63(w, bh.Version); err != nil { return err } diff --git a/protocol/bc/types/block_witness.go b/protocol/bc/types/block_witness.go index 52f3e0e4..cf270d9b 100644 --- a/protocol/bc/types/block_witness.go +++ b/protocol/bc/types/block_witness.go @@ -11,13 +11,13 @@ type BlockWitness struct { Witness [][]byte } -func (bw *BlockWitness) writeTo(w io.Writer) error { - _, err := blockchain.WriteVarstrList(w, bw.Witness) +func (bw *BlockWitness) readFrom(r *blockchain.Reader) (err error) { + bw.Witness, err = blockchain.ReadVarstrList(r) return err } -func (bw *BlockWitness) readFrom(r *blockchain.Reader) (err error) { - bw.Witness, err = blockchain.ReadVarstrList(r) +func (bw *BlockWitness) writeTo(w io.Writer) error { + _, err := blockchain.WriteVarstrList(w, bw.Witness) return err } diff --git a/protocol/bc/types/block_witness_test.go b/protocol/bc/types/block_witness_test.go index 9dc53b94..11f74c3d 100644 --- a/protocol/bc/types/block_witness_test.go +++ b/protocol/bc/types/block_witness_test.go @@ -82,7 +82,7 @@ func TestBlockWitnessSet(t *testing.T) { bw: BlockWitness{Witness: [][]byte{[]byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04}}}, index: uint64(4), data: []byte{0x04, 0x04, 0x04, 0x04}, - want: BlockWitness{Witness: [][]byte{[]byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04}, []byte{}, []byte{}, []byte{0x04, 0x04, 0x04, 0x04}}}, + want: BlockWitness{Witness: [][]byte{[]byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04}, nil, nil, []byte{0x04, 0x04, 0x04, 0x04}}}, }, } diff --git a/protocol/bc/types/crosschain_input.go b/protocol/bc/types/crosschain_input.go index e29673d5..ee8fb9bc 100644 --- a/protocol/bc/types/crosschain_input.go +++ b/protocol/bc/types/crosschain_input.go @@ -10,15 +10,15 @@ type CrossChainInput struct { Arguments [][]byte // Witness SpendCommitment - VMVersion uint64 - AssetDefinition []byte - IssuanceProgram []byte + AssetDefinition []byte + IssuanceVMVersion uint64 + IssuanceProgram []byte } // NewCrossChainInput create a new CrossChainInput struct. // The source is created/issued by trusted federation and hence there is no need // to refer to it. -func NewCrossChainInput(arguments [][]byte, sourceID bc.Hash, assetID bc.AssetID, amount, sourcePos, vmVersion uint64, assetDefinition, issuanceProgram []byte) *TxInput { +func NewCrossChainInput(arguments [][]byte, sourceID bc.Hash, assetID bc.AssetID, amount, sourcePos, IssuanceVMVersion uint64, assetDefinition, issuanceProgram []byte) *TxInput { sc := SpendCommitment{ AssetAmount: bc.AssetAmount{ AssetId: &assetID, @@ -31,11 +31,11 @@ func NewCrossChainInput(arguments [][]byte, sourceID bc.Hash, assetID bc.AssetID return &TxInput{ AssetVersion: 1, TypedInput: &CrossChainInput{ - SpendCommitment: sc, - Arguments: arguments, - VMVersion: vmVersion, - AssetDefinition: assetDefinition, - IssuanceProgram: issuanceProgram, + SpendCommitment: sc, + Arguments: arguments, + AssetDefinition: assetDefinition, + IssuanceVMVersion: IssuanceVMVersion, + IssuanceProgram: issuanceProgram, }, } } diff --git a/protocol/bc/types/map.go b/protocol/bc/types/map.go index 0fe229dc..27f687e0 100644 --- a/protocol/bc/types/map.go +++ b/protocol/bc/types/map.go @@ -55,10 +55,9 @@ func MapTx(oldTx *TxData) *bc.Tx { continue } - if ord >= uint64(len(oldTx.Inputs)) { - continue + if ord < uint64(len(oldTx.Inputs)) { + tx.InputIDs[ord] = id } - tx.InputIDs[ord] = id } for id := range spentOutputIDs { @@ -149,18 +148,18 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash } prevout := bc.NewIntraChainOutput(src, prog, 0) // ordinal doesn't matter - outputID := bc.EntryID(prevout) + mainchainOutputID := addEntry(prevout) assetDefHash := bc.NewHash(sha3.Sum256(inp.AssetDefinition)) assetDef := &bc.AssetDefinition{ Data: &assetDefHash, IssuanceProgram: &bc.Program{ - VmVersion: inp.VMVersion, + VmVersion: inp.IssuanceVMVersion, Code: inp.IssuanceProgram, }, } - crossIn := bc.NewCrossChainInput(&outputID, &inp.AssetAmount, prog, uint64(i), assetDef) + crossIn := bc.NewCrossChainInput(&mainchainOutputID, prog, uint64(i), assetDef) crossIn.WitnessArguments = inp.Arguments crossInID := addEntry(crossIn) muxSources[i] = &bc.ValueSource{ @@ -186,7 +185,8 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash } for _, crossIn := range crossIns { - crossIn.SetDestination(&muxID, crossIn.Value, crossIn.Ordinal) + mainchainOutput := entryMap[*crossIn.MainchainOutputId].(*bc.IntraChainOutput) + crossIn.SetDestination(&muxID, mainchainOutput.Source.Value, crossIn.Ordinal) } if coinbase != nil { @@ -224,7 +224,7 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash case out.OutputType() == VoteOutputType: // non-retirement vote tx - voteOut, _ := out.TypedOutput.(*VoteTxOutput) + voteOut, _ := out.TypedOutput.(*VoteOutput) prog := &bc.Program{out.VMVersion(), out.ControlProgram()} o := bc.NewVoteOutput(src, prog, uint64(i), voteOut.Vote) resultID = addEntry(o) diff --git a/protocol/bc/types/output_commitment.go b/protocol/bc/types/output_commitment.go index e72cf545..aede38f2 100644 --- a/protocol/bc/types/output_commitment.go +++ b/protocol/bc/types/output_commitment.go @@ -4,7 +4,6 @@ import ( "fmt" "io" - "github.com/vapor/crypto/sha3pool" "github.com/vapor/encoding/blockchain" "github.com/vapor/errors" "github.com/vapor/protocol/bc" @@ -61,12 +60,3 @@ func (oc *OutputCommitment) readFrom(r *blockchain.Reader, assetVersion uint64) return nil }) } - -// Hash convert suffix && assetVersion to bc.Hash -func (oc *OutputCommitment) Hash(suffix []byte, assetVersion uint64) (outputhash bc.Hash) { - h := sha3pool.Get256() - defer sha3pool.Put256(h) - oc.writeExtensibleString(h, suffix, assetVersion) - outputhash.ReadFrom(h) - return outputhash -} diff --git a/protocol/bc/types/output_commitment_test.go b/protocol/bc/types/output_commitment_test.go index c5ef8da1..52aabda3 100644 --- a/protocol/bc/types/output_commitment_test.go +++ b/protocol/bc/types/output_commitment_test.go @@ -47,8 +47,7 @@ func TestReadWriteOutputCommitment(t *testing.T) { } oc := &OutputCommitment{} - _, err := oc.readFrom(blockchain.NewReader(buffer.Bytes()), 1) - if err != nil { + if _, err := oc.readFrom(blockchain.NewReader(buffer.Bytes()), 1); err != nil { t.Fatal(err) } diff --git a/protocol/bc/types/txinput.go b/protocol/bc/types/txinput.go index 888c9420..88b3bcea 100644 --- a/protocol/bc/types/txinput.go +++ b/protocol/bc/types/txinput.go @@ -32,8 +32,6 @@ type ( } ) -var errBadAssetID = errors.New("asset ID does not match other issuance parameters") - // AssetAmount return the asset id and amount of the txinput. func (t *TxInput) AssetAmount() bc.AssetAmount { switch inp := t.TypedInput.(type) { @@ -138,7 +136,7 @@ func (t *TxInput) SpentOutputID() (o bc.Hash, err error) { o, err = ComputeOutputID(&inp.SpendCommitment, VetoInputType, inp.Vote) } - return o, err + return o, fmt.Errorf("output don't have spend output ID") } func (t *TxInput) readFrom(r *blockchain.Reader) (err error) { @@ -177,11 +175,26 @@ func (t *TxInput) readFrom(r *blockchain.Reader) (err error) { return err } + if ci.IssuanceVMVersion, err = blockchain.ReadVarint63(r); err != nil { + return err + } + + if ci.AssetDefinition, err = blockchain.ReadVarstr31(r); err != nil { + return err + } + + if ci.IssuanceProgram, err = blockchain.ReadVarstr31(r); err != nil { + return err + } + case VetoInputType: ui := new(VetoInput) t.TypedInput = ui if ui.VetoCommitmentSuffix, err = ui.SpendCommitment.readFrom(r, 1); err != nil { + return err + } + if ui.Vote, err = blockchain.ReadVarstr31(r); err != nil { return err } @@ -199,45 +212,21 @@ func (t *TxInput) readFrom(r *blockchain.Reader) (err error) { return nil } + var err error switch inp := t.TypedInput.(type) { case *SpendInput: - if inp.Arguments, err = blockchain.ReadVarstrList(r); err != nil { - return err - } + inp.Arguments, err = blockchain.ReadVarstrList(r) case *CrossChainInput: - if inp.Arguments, err = blockchain.ReadVarstrList(r); err != nil { - return err - } - - if inp.VMVersion, err = blockchain.ReadVarint63(r); err != nil { - return err - } - - if inp.AssetDefinition, err = blockchain.ReadVarstr31(r); err != nil { - return err - } - - if inp.IssuanceProgram, err = blockchain.ReadVarstr31(r); err != nil { - return err - } + inp.Arguments, err = blockchain.ReadVarstrList(r) case *VetoInput: - if inp.Arguments, err = blockchain.ReadVarstrList(r); err != nil { - return err - } - if inp.Vote, err = blockchain.ReadVarstr31(r); err != nil { - return err - } - + inp.Arguments, err = blockchain.ReadVarstrList(r) } - return nil - }) - if err != nil { - return err - } - return nil + return err + }) + return err } func (t *TxInput) writeTo(w io.Writer) error { @@ -266,19 +255,36 @@ func (t *TxInput) writeInputCommitment(w io.Writer) (err error) { if _, err = w.Write([]byte{SpendInputType}); err != nil { return err } + return inp.SpendCommitment.writeExtensibleString(w, inp.SpendCommitmentSuffix, t.AssetVersion) case *CrossChainInput: if _, err = w.Write([]byte{CrossChainInputType}); err != nil { return err } - return inp.SpendCommitment.writeExtensibleString(w, inp.SpendCommitmentSuffix, t.AssetVersion) + + if err := inp.SpendCommitment.writeExtensibleString(w, inp.SpendCommitmentSuffix, t.AssetVersion); err != nil { + return err + } + + if _, err := blockchain.WriteVarint63(w, inp.IssuanceVMVersion); err != nil { + return err + } + + if _, err := blockchain.WriteVarstr31(w, inp.AssetDefinition); err != nil { + return err + } + + if _, err := blockchain.WriteVarstr31(w, inp.IssuanceProgram); err != nil { + return err + } case *CoinbaseInput: - if _, err = w.Write([]byte{CoinbaseInputType}); err != nil { + if _, err := w.Write([]byte{CoinbaseInputType}); err != nil { return err } - if _, err = blockchain.WriteVarstr31(w, inp.Arbitrary); err != nil { + + if _, err := blockchain.WriteVarstr31(w, inp.Arbitrary); err != nil { return errors.Wrap(err, "writing coinbase arbitrary") } @@ -286,7 +292,13 @@ func (t *TxInput) writeInputCommitment(w io.Writer) (err error) { if _, err = w.Write([]byte{VetoInputType}); err != nil { return err } - return inp.SpendCommitment.writeExtensibleString(w, inp.VetoCommitmentSuffix, t.AssetVersion) + + if err := inp.SpendCommitment.writeExtensibleString(w, inp.VetoCommitmentSuffix, t.AssetVersion); err != nil { + return err + } + + _, err := blockchain.WriteVarstr31(w, inp.Vote) + return err } return nil } @@ -296,33 +308,16 @@ func (t *TxInput) writeInputWitness(w io.Writer) error { return nil } + var err error switch inp := t.TypedInput.(type) { case *SpendInput: - _, err := blockchain.WriteVarstrList(w, inp.Arguments) - return err + _, err = blockchain.WriteVarstrList(w, inp.Arguments) case *CrossChainInput: - if _, err := blockchain.WriteVarstrList(w, inp.Arguments); err != nil { - return err - } + _, err = blockchain.WriteVarstrList(w, inp.Arguments) - if _, err := blockchain.WriteVarint63(w, inp.VMVersion); err != nil { - return err - } - - if _, err := blockchain.WriteVarstr31(w, inp.AssetDefinition); err != nil { - return err - } - - _, err := blockchain.WriteVarstr31(w, inp.IssuanceProgram) - - return err case *VetoInput: - if _, err := blockchain.WriteVarstrList(w, inp.Arguments); err != nil { - return err - } - _, err := blockchain.WriteVarstr31(w, inp.Vote) - return err + _, err = blockchain.WriteVarstrList(w, inp.Arguments) } - return nil + return err } diff --git a/protocol/bc/types/txinput_test.go b/protocol/bc/types/txinput_test.go index c590ce6d..4b45ab4b 100644 --- a/protocol/bc/types/txinput_test.go +++ b/protocol/bc/types/txinput_test.go @@ -76,7 +76,7 @@ func TestSerializationCrossIn(t *testing.T) { wantHex := strings.Join([]string{ "01", // asset version - "48", // input commitment length + "62", // input commitment length "00", // cross-chain input type flag "46", // cross-chain input commitment length "fad5195a0c8e3b590b86a3c0a95e7529565888508aecca96e9aeda633002f409", // source id @@ -85,17 +85,17 @@ func TestSerializationCrossIn(t *testing.T) { "03", // source position "01", // vm version "00", // spend program length - "31", // witness length - "02", // argument array length - "0a", // first argument length - "617267756d656e747331", // first argument data - "0a", // second argument length - "617267756d656e747332", // second argument data "01", // VmVersion "08", // asset definition length "7768617465766572", // asset definition data "0f", // IssuanceProgram length "49737375616e636550726f6772616d", // IssuanceProgram + "17", // witness length + "02", // argument array length + "0a", // first argument length + "617267756d656e747331", // first argument data + "0a", // second argument length + "617267756d656e747332", // second argument data }, "") // Test convert struct to hex @@ -134,10 +134,10 @@ func TestSerializationVeto(t *testing.T) { vetoInput := NewVetoInput(arguments, testutil.MustDecodeHash("fad5195a0c8e3b590b86a3c0a95e7529565888508aecca96e9aeda633002f409"), testutil.MustDecodeAsset("fe9791d71b67ee62515e08723c061b5ccb952a80d804417c8aeedf7f633c524a"), 254354, 3, []byte("spendProgram"), []byte("af594006a40837d9f028daabb6d589df0b9138daefad5683e5233c2646279217294a8d532e60863bcf196625a35fb8ceeffa3c09610eb92dcfb655a947f13269")) wantHex := strings.Join([]string{ - "01", // asset version - "54", // input commitment length - "03", // veto type flag - "52", // veto commitment length + "01", // asset version + "d601", // input commitment length + "03", // veto type flag + "52", // veto commitment length "fad5195a0c8e3b590b86a3c0a95e7529565888508aecca96e9aeda633002f409", // source id "fe9791d71b67ee62515e08723c061b5ccb952a80d804417c8aeedf7f633c524a", // assetID "92c30f", // amount @@ -145,14 +145,14 @@ func TestSerializationVeto(t *testing.T) { "01", // vm version "0c", // veto program length "7370656e6450726f6772616d", // veto program - "9901", // witness length - "02", // argument array length - "0a", // first argument length - "617267756d656e747331", // first argument data - "0a", // second argument length - "617267756d656e747332", // second argument data "8001", //xpub length "6166353934303036613430383337643966303238646161626236643538396466306239313338646165666164353638336535323333633236343632373932313732393461386435333265363038363362636631393636323561333566623863656566666133633039363130656239326463666236353561393437663133323639", //voter xpub + "17", // witness length + "02", // argument array length + "0a", // first argument length + "617267756d656e747331", // first argument data + "0a", // second argument length + "617267756d656e747332", // second argument data }, "") // Test convert struct to hex diff --git a/protocol/bc/types/txoutput.go b/protocol/bc/types/txoutput.go index 15f07e12..7380bf11 100644 --- a/protocol/bc/types/txoutput.go +++ b/protocol/bc/types/txoutput.go @@ -40,7 +40,7 @@ func (to *TxOutput) OutputCommitment() OutputCommitment { case *CrossChainOutput: return outp.OutputCommitment - case *VoteTxOutput: + case *VoteOutput: return outp.OutputCommitment default: @@ -57,7 +57,7 @@ func (to *TxOutput) AssetAmount() bc.AssetAmount { case *CrossChainOutput: return outp.AssetAmount - case *VoteTxOutput: + case *VoteOutput: return outp.AssetAmount default: @@ -74,7 +74,7 @@ func (to *TxOutput) ControlProgram() []byte { case *CrossChainOutput: return outp.ControlProgram - case *VoteTxOutput: + case *VoteOutput: return outp.ControlProgram default: @@ -91,7 +91,7 @@ func (to *TxOutput) VMVersion() uint64 { case *CrossChainOutput: return outp.VMVersion - case *VoteTxOutput: + case *VoteOutput: return outp.VMVersion default: @@ -130,7 +130,7 @@ func (to *TxOutput) readFrom(r *blockchain.Reader) (err error) { } case VoteOutputType: - out := new(VoteTxOutput) + out := new(VoteOutput) to.TypedOutput = out if out.Vote, err = blockchain.ReadVarstr31(r); err != nil { return errors.Wrap(err, "reading vote output vote") @@ -190,7 +190,7 @@ func (to *TxOutput) writeOutputCommitment(w io.Writer) error { } return outp.OutputCommitment.writeExtensibleString(w, outp.CommitmentSuffix, to.AssetVersion) - case *VoteTxOutput: + case *VoteOutput: if _, err := w.Write([]byte{VoteOutputType}); err != nil { return err } diff --git a/protocol/bc/types/txoutput_test.go b/protocol/bc/types/txoutput_test.go index 0ae1f62f..58eaa85f 100644 --- a/protocol/bc/types/txoutput_test.go +++ b/protocol/bc/types/txoutput_test.go @@ -99,7 +99,7 @@ func TestSerializationCrossChainTxOutput(t *testing.T) { } } -func TestSerializationVoteTxOutput(t *testing.T) { +func TestSerializationVoteOutput(t *testing.T) { assetID := testutil.MustDecodeAsset("81756fdab39a17163b0ce582ee4ee256fb4d1e156c692b997d608a42ecb38d47") voteTxOutput := NewVoteOutput(assetID, 1000, []byte("TestSerializationTxOutput"), []byte("af594006a40837d9f028daabb6d589df0b9138daefad5683e5233c2646279217294a8d532e60863bcf196625a35fb8ceeffa3c09610eb92dcfb655a947f13269")) diff --git a/protocol/bc/types/vote_txoutput.go b/protocol/bc/types/vote_output.go similarity index 73% rename from protocol/bc/types/vote_txoutput.go rename to protocol/bc/types/vote_output.go index f0ebe944..aeeac986 100644 --- a/protocol/bc/types/vote_txoutput.go +++ b/protocol/bc/types/vote_output.go @@ -4,8 +4,8 @@ import ( "github.com/vapor/protocol/bc" ) -// VoteTxOutput satisfies the TypedOutput interface and represents a vote transaction. -type VoteTxOutput struct { +// VoteOutput satisfies the TypedOutput interface and represents a vote transaction. +type VoteOutput struct { OutputCommitment // Unconsumed suffixes of the commitment and witness extensible strings. CommitmentSuffix []byte @@ -16,7 +16,7 @@ type VoteTxOutput struct { func NewVoteOutput(assetID bc.AssetID, amount uint64, controlProgram []byte, vote []byte) *TxOutput { return &TxOutput{ AssetVersion: 1, - TypedOutput: &VoteTxOutput{ + TypedOutput: &VoteOutput{ OutputCommitment: OutputCommitment{ AssetAmount: bc.AssetAmount{ AssetId: &assetID, @@ -30,4 +30,4 @@ func NewVoteOutput(assetID bc.AssetID, amount uint64, controlProgram []byte, vot } } -func (it *VoteTxOutput) OutputType() uint8 { return VoteOutputType } +func (it *VoteOutput) OutputType() uint8 { return VoteOutputType } diff --git a/protocol/state/vote_result.go b/protocol/state/vote_result.go index 6a434c8d..7ea2a82a 100644 --- a/protocol/state/vote_result.go +++ b/protocol/state/vote_result.go @@ -75,7 +75,7 @@ func (v *VoteResult) ApplyBlock(block *types.Block) error { } for _, output := range tx.Outputs { - voteOutput, ok := output.TypedOutput.(*types.VoteTxOutput) + voteOutput, ok := output.TypedOutput.(*types.VoteOutput) if !ok { continue } @@ -148,7 +148,7 @@ func (v *VoteResult) DetachBlock(block *types.Block) error { } for _, output := range tx.Outputs { - voteOutput, ok := output.TypedOutput.(*types.VoteTxOutput) + voteOutput, ok := output.TypedOutput.(*types.VoteOutput) if !ok { continue } diff --git a/protocol/validation/tx.go b/protocol/validation/tx.go index bf925b3a..6d248e54 100644 --- a/protocol/validation/tx.go +++ b/protocol/validation/tx.go @@ -251,9 +251,17 @@ func checkValid(vs *validationState, e bc.Entry) (err error) { } case *bc.CrossChainInput: - // check assetID + if e.MainchainOutputId == nil { + return errors.Wrap(ErrMissingField, "crosschain input without mainchain output ID") + } + + mainchainOutput, err := vs.tx.IntraChainOutput(*e.MainchainOutputId) + if err != nil { + return errors.Wrap(err, "getting mainchain output") + } + assetID := e.AssetDefinition.ComputeAssetID() - if *e.Value.AssetId != *consensus.BTMAssetID && *e.Value.AssetId != assetID { + if *mainchainOutput.Source.Value.AssetId != *consensus.BTMAssetID && *mainchainOutput.Source.Value.AssetId != assetID { return errors.New("incorrect asset_id while checking CrossChainInput") } @@ -262,8 +270,8 @@ func checkValid(vs *validationState, e bc.Entry) (err error) { VmVersion: e.ControlProgram.VmVersion, Code: code, } - _, err := vm.Verify(NewTxVMContext(vs, e, prog, e.WitnessArguments), consensus.DefaultGasCredit) - if err != nil { + + if _, err := vm.Verify(NewTxVMContext(vs, e, prog, e.WitnessArguments), consensus.DefaultGasCredit); err != nil { return errors.Wrap(err, "checking cross-chain input control program") } diff --git a/protocol/validation/vmcontext.go b/protocol/validation/vmcontext.go index 9815b2e3..df676937 100644 --- a/protocol/validation/vmcontext.go +++ b/protocol/validation/vmcontext.go @@ -26,10 +26,13 @@ func NewTxVMContext(vs *validationState, entry bc.Entry, prog *bc.Program, args switch e := entry.(type) { case *bc.CrossChainInput: - a1 := e.Value.AssetId.Bytes() + mainchainOutput := tx.Entries[*e.MainchainOutputId].(*bc.IntraChainOutput) + a1 := mainchainOutput.Source.Value.AssetId.Bytes() assetID = &a1 - amount = &e.Value.Amount + amount = &mainchainOutput.Source.Value.Amount destPos = &e.WitnessDestination.Position + s := e.MainchainOutputId.Bytes() + spentOutputID = &s case *bc.Spend: spentOutput := tx.Entries[*e.SpentOutputId].(*bc.IntraChainOutput) diff --git a/testutil/expect.go b/testutil/expect.go deleted file mode 100644 index 9d0ac38f..00000000 --- a/testutil/expect.go +++ /dev/null @@ -1,27 +0,0 @@ -package testutil - -import ( - "fmt" - "os" - "path/filepath" - "strings" - "testing" - - "github.com/vapor/errors" -) - -var wd, _ = os.Getwd() - -func FatalErr(t testing.TB, err error) { - args := []interface{}{err} - for _, frame := range errors.Stack(err) { - file := frame.File - if rel, err := filepath.Rel(wd, file); err == nil && !strings.HasPrefix(rel, "../") { - file = rel - } - funcname := frame.Func[strings.IndexByte(frame.Func, '.')+1:] - s := fmt.Sprintf("\n%s:%d: %s", file, frame.Line, funcname) - args = append(args, s) - } - t.Fatal(args...) -} diff --git a/testutil/parameter.go b/testutil/parameter.go deleted file mode 100644 index 73e93d3f..00000000 --- a/testutil/parameter.go +++ /dev/null @@ -1,10 +0,0 @@ -package testutil - -import ( - "github.com/vapor/protocol/bc" -) - -var ( - MaxHash = &bc.Hash{V0: 1<<64 - 1, V1: 1<<64 - 1, V2: 1<<64 - 1, V3: 1<<64 - 1} - MinHash = &bc.Hash{} -) diff --git a/wallet/utxo_test.go b/wallet/utxo_test.go index 86450baf..67780ff9 100644 --- a/wallet/utxo_test.go +++ b/wallet/utxo_test.go @@ -684,35 +684,35 @@ func TestTxOutToUtxos(t *testing.T) { blockHeight: 0, wantUtxos: []*account.UTXO{ &account.UTXO{ - OutputID: bc.Hash{V0: 5429526025956869574, V1: 12188959875155232503, V2: 14722092106507294798, V3: 27876074648890075}, + OutputID: bc.Hash{15099088327605875240, 9219883424533839002, 14610773420520931246, 14899393216621986426}, AssetID: bc.AssetID{V0: 1}, Amount: 2, ControlProgram: []byte{0x51}, - SourceID: bc.Hash{V0: 10187915247323429348, V1: 4770401581694266753, V2: 4182269187154655368, V3: 9030883832705174512}, + SourceID: bc.Hash{16280523637332892554, 3627898494554775182, 16212395834831293013, 3511838375364469081}, SourcePos: 0, }, &account.UTXO{ - OutputID: bc.Hash{V0: 18100481287404207387, V1: 3365694797435565990, V2: 8136211093499423216, V3: 12028531817690438568}, + OutputID: bc.Hash{3610727630628260133, 13088239834060115701, 14968571476177322101, 7529789620153710893}, AssetID: bc.AssetID{V0: 1}, Amount: 3, ControlProgram: []byte{0x52}, - SourceID: bc.Hash{V0: 10187915247323429348, V1: 4770401581694266753, V2: 4182269187154655368, V3: 9030883832705174512}, + SourceID: bc.Hash{16280523637332892554, 3627898494554775182, 16212395834831293013, 3511838375364469081}, SourcePos: 1, }, &account.UTXO{ - OutputID: bc.Hash{V0: 15745816911932387102, V1: 5035893487696724781, V2: 10084725527786878517, V3: 11270352747873435606}, + OutputID: bc.Hash{2034718018519539988, 16893043149780417913, 11926903829554245570, 3446441680088007327}, AssetID: *consensus.BTMAssetID, Amount: 2, ControlProgram: []byte{0x53}, - SourceID: bc.Hash{V0: 10187915247323429348, V1: 4770401581694266753, V2: 4182269187154655368, V3: 9030883832705174512}, + SourceID: bc.Hash{16280523637332892554, 3627898494554775182, 16212395834831293013, 3511838375364469081}, SourcePos: 2, }, &account.UTXO{ - OutputID: bc.Hash{V0: 10165799535720725897, V1: 9618876671942765420, V2: 17982649347111502590, V3: 15837286550437859084}, + OutputID: bc.Hash{7296157888262317106, 5789265653020263821, 1170213393196090227, 7665081318694049454}, AssetID: *consensus.BTMAssetID, Amount: 5, ControlProgram: []byte{0x54}, - SourceID: bc.Hash{V0: 10187915247323429348, V1: 4770401581694266753, V2: 4182269187154655368, V3: 9030883832705174512}, + SourceID: bc.Hash{16280523637332892554, 3627898494554775182, 16212395834831293013, 3511838375364469081}, SourcePos: 3, }, }, -- 2.11.0