OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / testutil / hex.go
1 package testutil
2
3 import (
4         "bytes"
5         "io"
6         "testing"
7
8         "github.com/vapor/protocol/bc"
9 )
10
11 func MustDecodeHash(s string) (h bc.Hash) {
12         if err := h.UnmarshalText([]byte(s)); err != nil {
13                 panic(err)
14         }
15         return h
16 }
17
18 func MustDecodeAsset(s string) (h bc.AssetID) {
19         if err := h.UnmarshalText([]byte(s)); err != nil {
20                 panic(err)
21         }
22         return h
23 }
24
25 func Serialize(t *testing.T, wt io.WriterTo) []byte {
26         var b bytes.Buffer
27         if _, err := wt.WriteTo(&b); err != nil {
28                 t.Fatal(err)
29         }
30         return b.Bytes()
31 }