8 func BenchmarkEntryID(b *testing.B) {
9 m := NewMux([]*ValueSource{{Position: 1}}, &Program{Code: []byte{1}, VmVersion: 1})
13 NewTxHeader(1, 1, 0, nil),
14 NewIntraChainOutput(&ValueSource{}, &Program{Code: []byte{1}, VmVersion: 1}, 0),
15 NewRetirement(&ValueSource{}, 1),
19 for _, e := range entries {
20 name := reflect.TypeOf(e).Elem().Name()
21 b.Run(name, func(b *testing.B) {
22 for i := 0; i < b.N; i++ {
29 func TestEntryID(t *testing.T) {
38 Ref: &Hash{V0: 0, V1: 1, V2: 2, V3: 3},
39 Value: &AssetAmount{&AssetID{V0: 1, V1: 2, V2: 3, V3: 4}, 100},
43 &Program{VmVersion: 1, Code: []byte{1, 2, 3, 4}},
45 expectEntryID: "16c4265a8a90916434c2a904a90132c198c7ebf8512aa1ba4485455b0beff388",
48 entry: NewIntraChainOutput(
50 Ref: &Hash{V0: 4, V1: 5, V2: 6, V3: 7},
51 Value: &AssetAmount{&AssetID{V0: 1, V1: 1, V2: 1, V3: 1}, 10},
54 &Program{VmVersion: 1, Code: []byte{5, 5, 5, 5}},
57 expectEntryID: "c60faad6ae44b15d54a57b5bd021f6cec0e5f7d2c55f53b90d6231ce5c561e9c",
62 Ref: &Hash{V0: 4, V1: 5, V2: 6, V3: 7},
63 Value: &AssetAmount{&AssetID{V0: 1, V1: 1, V2: 1, V3: 1}, 10},
68 expectEntryID: "538c367f7b6e1e9bf205ed0a29def84a1467c477b19812a6934e831c78c4da62",
71 entry: NewSpend(&Hash{V0: 0, V1: 1, V2: 2, V3: 3}, 1),
72 expectEntryID: "2761dbb13967af8944620c134e0f336bbbb26f61eb4ecd154bc034ad6155b9e8",
75 entry: NewTxHeader(1, 100, 1000, []*Hash{&Hash{V0: 4, V1: 5, V2: 6, V3: 7}}),
76 expectEntryID: "ba592aa0841bd4649d9a04309e2e8497ac6f295a847cadd9de6b6f9c2d806663",
80 for _, c := range cases {
81 entryID := EntryID(c.entry)
82 if entryID.String() != c.expectEntryID {
83 t.Errorf("the got extry id:%s is not equals to expect entry id:%s", entryID.String(), c.expectEntryID)