OSDN Git Service

7d87648b6e4b72fb0aae4a4dc8ecfd808ef43284
[bytom/bytom.git] / protocol / txpool_test.go
1 package protocol
2
3 import (
4         "testing"
5         "time"
6
7         "github.com/davecgh/go-spew/spew"
8
9         "github.com/bytom/consensus"
10         "github.com/bytom/database/storage"
11         "github.com/bytom/event"
12         "github.com/bytom/protocol/bc"
13         "github.com/bytom/protocol/bc/types"
14         "github.com/bytom/protocol/state"
15         "github.com/bytom/testutil"
16 )
17
18 var testTxs = []*types.Tx{
19         //tx0
20         types.NewTx(types.TxData{
21                 SerializedSize: 100,
22                 Inputs: []*types.TxInput{
23                         types.NewSpendInput(nil, bc.NewHash([32]byte{0x01}), *consensus.BTMAssetID, 1, 1, []byte{0x51}),
24                 },
25                 Outputs: []*types.TxOutput{
26                         types.NewTxOutput(*consensus.BTMAssetID, 1, []byte{0x6a}),
27                 },
28         }),
29         //tx1
30         types.NewTx(types.TxData{
31                 SerializedSize: 100,
32                 Inputs: []*types.TxInput{
33                         types.NewSpendInput(nil, bc.NewHash([32]byte{0x01}), *consensus.BTMAssetID, 1, 1, []byte{0x51}),
34                 },
35                 Outputs: []*types.TxOutput{
36                         types.NewTxOutput(*consensus.BTMAssetID, 1, []byte{0x6b}),
37                 },
38         }),
39         //tx2
40         types.NewTx(types.TxData{
41                 SerializedSize: 150,
42                 TimeRange:      0,
43                 Inputs: []*types.TxInput{
44                         types.NewSpendInput(nil, bc.NewHash([32]byte{0x01}), *consensus.BTMAssetID, 1, 1, []byte{0x51}),
45                         types.NewSpendInput(nil, bc.NewHash([32]byte{0x02}), bc.NewAssetID([32]byte{0xa1}), 4, 1, []byte{0x51}),
46                 },
47                 Outputs: []*types.TxOutput{
48                         types.NewTxOutput(*consensus.BTMAssetID, 1, []byte{0x6b}),
49                         types.NewTxOutput(bc.NewAssetID([32]byte{0xa1}), 4, []byte{0x61}),
50                 },
51         }),
52         //tx3
53         types.NewTx(types.TxData{
54                 SerializedSize: 100,
55                 Inputs: []*types.TxInput{
56                         types.NewSpendInput(nil, testutil.MustDecodeHash("dbea684b5c5153ed7729669a53d6c59574f26015a3e1eb2a0e8a1c645425a764"), bc.NewAssetID([32]byte{0xa1}), 4, 1, []byte{0x61}),
57                 },
58                 Outputs: []*types.TxOutput{
59                         types.NewTxOutput(bc.NewAssetID([32]byte{0xa1}), 3, []byte{0x62}),
60                         types.NewTxOutput(bc.NewAssetID([32]byte{0xa1}), 1, []byte{0x63}),
61                 },
62         }),
63         //tx4
64         types.NewTx(types.TxData{
65                 SerializedSize: 100,
66                 Inputs: []*types.TxInput{
67                         types.NewSpendInput(nil, testutil.MustDecodeHash("d84d0be0fd08e7341f2d127749bb0d0844d4560f53bd54861cee9981fd922cad"), bc.NewAssetID([32]byte{0xa1}), 3, 0, []byte{0x62}),
68                 },
69                 Outputs: []*types.TxOutput{
70                         types.NewTxOutput(bc.NewAssetID([32]byte{0xa1}), 2, []byte{0x64}),
71                         types.NewTxOutput(bc.NewAssetID([32]byte{0xa1}), 1, []byte{0x65}),
72                 },
73         }),
74 }
75
76 type mockStore struct{}
77
78 func (s *mockStore) BlockExist(hash *bc.Hash) bool                                { return false }
79 func (s *mockStore) GetBlock(*bc.Hash) (*types.Block, error)                      { return nil, nil }
80 func (s *mockStore) GetStoreStatus() *BlockStoreState                             { return nil }
81 func (s *mockStore) GetTransactionStatus(*bc.Hash) (*bc.TransactionStatus, error) { return nil, nil }
82 func (s *mockStore) GetTransactionsUtxo(*state.UtxoViewpoint, []*bc.Tx) error     { return nil }
83 func (s *mockStore) GetUtxo(*bc.Hash) (*storage.UtxoEntry, error)                 { return nil, nil }
84 func (s *mockStore) LoadBlockIndex(uint64) (*state.BlockIndex, error)             { return nil, nil }
85 func (s *mockStore) SaveBlock(*types.Block, *bc.TransactionStatus) error          { return nil }
86 func (s *mockStore) SaveChainStatus(*state.BlockNode, *state.UtxoViewpoint) error { return nil }
87
88 func TestAddOrphan(t *testing.T) {
89         cases := []struct {
90                 before         *TxPool
91                 after          *TxPool
92                 addOrphan      *TxDesc
93                 requireParents []*bc.Hash
94         }{
95                 {
96                         before: &TxPool{
97                                 orphans:       map[bc.Hash]*orphanTx{},
98                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{},
99                         },
100                         after: &TxPool{
101                                 orphans: map[bc.Hash]*orphanTx{
102                                         testTxs[0].ID: {
103                                                 TxDesc: &TxDesc{
104                                                         Tx: testTxs[0],
105                                                 },
106                                         },
107                                 },
108                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{
109                                         testTxs[0].SpentOutputIDs[0]: {
110                                                 testTxs[0].ID: {
111                                                         TxDesc: &TxDesc{
112                                                                 Tx: testTxs[0],
113                                                         },
114                                                 },
115                                         },
116                                 },
117                         },
118                         addOrphan:      &TxDesc{Tx: testTxs[0]},
119                         requireParents: []*bc.Hash{&testTxs[0].SpentOutputIDs[0]},
120                 },
121                 {
122                         before: &TxPool{
123                                 orphans: map[bc.Hash]*orphanTx{
124                                         testTxs[0].ID: {
125                                                 TxDesc: &TxDesc{
126                                                         Tx: testTxs[0],
127                                                 },
128                                         },
129                                 },
130                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{
131                                         testTxs[0].SpentOutputIDs[0]: {
132                                                 testTxs[0].ID: {
133                                                         TxDesc: &TxDesc{
134                                                                 Tx: testTxs[0],
135                                                         },
136                                                 },
137                                         },
138                                 },
139                         },
140                         after: &TxPool{
141                                 orphans: map[bc.Hash]*orphanTx{
142                                         testTxs[0].ID: {
143                                                 TxDesc: &TxDesc{
144                                                         Tx: testTxs[0],
145                                                 },
146                                         },
147                                         testTxs[1].ID: {
148                                                 TxDesc: &TxDesc{
149                                                         Tx: testTxs[1],
150                                                 },
151                                         },
152                                 },
153                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{
154                                         testTxs[0].SpentOutputIDs[0]: {
155                                                 testTxs[0].ID: {
156                                                         TxDesc: &TxDesc{
157                                                                 Tx: testTxs[0],
158                                                         },
159                                                 },
160                                                 testTxs[1].ID: {
161                                                         TxDesc: &TxDesc{
162                                                                 Tx: testTxs[1],
163                                                         },
164                                                 },
165                                         },
166                                 },
167                         },
168                         addOrphan:      &TxDesc{Tx: testTxs[1]},
169                         requireParents: []*bc.Hash{&testTxs[1].SpentOutputIDs[0]},
170                 },
171                 {
172                         before: &TxPool{
173                                 orphans:       map[bc.Hash]*orphanTx{},
174                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{},
175                         },
176                         after: &TxPool{
177                                 orphans: map[bc.Hash]*orphanTx{
178                                         testTxs[2].ID: {
179                                                 TxDesc: &TxDesc{
180                                                         Tx: testTxs[2],
181                                                 },
182                                         },
183                                 },
184                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{
185                                         testTxs[2].SpentOutputIDs[1]: {
186                                                 testTxs[2].ID: {
187                                                         TxDesc: &TxDesc{
188                                                                 Tx: testTxs[2],
189                                                         },
190                                                 },
191                                         },
192                                 },
193                         },
194                         addOrphan:      &TxDesc{Tx: testTxs[2]},
195                         requireParents: []*bc.Hash{&testTxs[2].SpentOutputIDs[1]},
196                 },
197         }
198
199         for i, c := range cases {
200                 c.before.addOrphan(c.addOrphan, c.requireParents)
201                 for _, orphan := range c.before.orphans {
202                         orphan.expiration = time.Time{}
203                 }
204                 for _, orphans := range c.before.orphansByPrev {
205                         for _, orphan := range orphans {
206                                 orphan.expiration = time.Time{}
207                         }
208                 }
209                 if !testutil.DeepEqual(c.before, c.after) {
210                         t.Errorf("case %d: got %v want %v", i, c.before, c.after)
211                 }
212         }
213 }
214
215 func TestAddTransaction(t *testing.T) {
216         dispatcher := event.NewDispatcher()
217         cases := []struct {
218                 before *TxPool
219                 after  *TxPool
220                 addTx  *TxDesc
221         }{
222                 {
223                         before: &TxPool{
224                                 pool:            map[bc.Hash]*TxDesc{},
225                                 utxo:            map[bc.Hash]*types.Tx{},
226                                 eventDispatcher: dispatcher,
227                         },
228                         after: &TxPool{
229                                 pool: map[bc.Hash]*TxDesc{
230                                         testTxs[2].ID: {
231                                                 Tx:         testTxs[2],
232                                                 StatusFail: false,
233                                         },
234                                 },
235                                 utxo: map[bc.Hash]*types.Tx{
236                                         *testTxs[2].ResultIds[0]: testTxs[2],
237                                         *testTxs[2].ResultIds[1]: testTxs[2],
238                                 },
239                         },
240                         addTx: &TxDesc{
241                                 Tx:         testTxs[2],
242                                 StatusFail: false,
243                         },
244                 },
245                 {
246                         before: &TxPool{
247                                 pool:            map[bc.Hash]*TxDesc{},
248                                 utxo:            map[bc.Hash]*types.Tx{},
249                                 eventDispatcher: dispatcher,
250                         },
251                         after: &TxPool{
252                                 pool: map[bc.Hash]*TxDesc{
253                                         testTxs[2].ID: {
254                                                 Tx:         testTxs[2],
255                                                 StatusFail: true,
256                                         },
257                                 },
258                                 utxo: map[bc.Hash]*types.Tx{
259                                         *testTxs[2].ResultIds[0]: testTxs[2],
260                                 },
261                         },
262                         addTx: &TxDesc{
263                                 Tx:         testTxs[2],
264                                 StatusFail: true,
265                         },
266                 },
267         }
268
269         for i, c := range cases {
270                 c.before.addTransaction(c.addTx)
271                 for _, txD := range c.before.pool {
272                         txD.Added = time.Time{}
273                 }
274                 if !testutil.DeepEqual(c.before.pool, c.after.pool) {
275                         t.Errorf("case %d: got %v want %v", i, c.before.pool, c.after.pool)
276                 }
277                 if !testutil.DeepEqual(c.before.utxo, c.after.utxo) {
278                         t.Errorf("case %d: got %v want %v", i, c.before.utxo, c.after.utxo)
279                 }
280         }
281 }
282
283 func TestExpireOrphan(t *testing.T) {
284         before := &TxPool{
285                 orphans: map[bc.Hash]*orphanTx{
286                         testTxs[0].ID: {
287                                 expiration: time.Unix(1533489701, 0),
288                                 TxDesc: &TxDesc{
289                                         Tx: testTxs[0],
290                                 },
291                         },
292                         testTxs[1].ID: {
293                                 expiration: time.Unix(1633489701, 0),
294                                 TxDesc: &TxDesc{
295                                         Tx: testTxs[1],
296                                 },
297                         },
298                 },
299                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{
300                         testTxs[0].SpentOutputIDs[0]: {
301                                 testTxs[0].ID: {
302                                         expiration: time.Unix(1533489701, 0),
303                                         TxDesc: &TxDesc{
304                                                 Tx: testTxs[0],
305                                         },
306                                 },
307                                 testTxs[1].ID: {
308                                         expiration: time.Unix(1633489701, 0),
309                                         TxDesc: &TxDesc{
310                                                 Tx: testTxs[1],
311                                         },
312                                 },
313                         },
314                 },
315         }
316
317         want := &TxPool{
318                 orphans: map[bc.Hash]*orphanTx{
319                         testTxs[1].ID: {
320                                 expiration: time.Unix(1633489701, 0),
321                                 TxDesc: &TxDesc{
322                                         Tx: testTxs[1],
323                                 },
324                         },
325                 },
326                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{
327                         testTxs[0].SpentOutputIDs[0]: {
328                                 testTxs[1].ID: {
329                                         expiration: time.Unix(1633489701, 0),
330                                         TxDesc: &TxDesc{
331                                                 Tx: testTxs[1],
332                                         },
333                                 },
334                         },
335                 },
336         }
337
338         before.ExpireOrphan(time.Unix(1633479701, 0))
339         if !testutil.DeepEqual(before, want) {
340                 t.Errorf("got %v want %v", before, want)
341         }
342 }
343
344 func TestProcessOrphans(t *testing.T) {
345         dispatcher := event.NewDispatcher()
346         cases := []struct {
347                 before    *TxPool
348                 after     *TxPool
349                 processTx *TxDesc
350         }{
351                 {
352                         before: &TxPool{
353                                 pool:            map[bc.Hash]*TxDesc{},
354                                 utxo:            map[bc.Hash]*types.Tx{},
355                                 eventDispatcher: dispatcher,
356                                 orphans: map[bc.Hash]*orphanTx{
357                                         testTxs[3].ID: {
358                                                 TxDesc: &TxDesc{
359                                                         Tx: testTxs[3],
360                                                 },
361                                         },
362                                 },
363                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{
364                                         testTxs[3].SpentOutputIDs[0]: {
365                                                 testTxs[3].ID: {
366                                                         TxDesc: &TxDesc{
367                                                                 Tx: testTxs[3],
368                                                         },
369                                                 },
370                                         },
371                                 },
372                         },
373                         after: &TxPool{
374                                 pool: map[bc.Hash]*TxDesc{
375                                         testTxs[3].ID: {
376                                                 Tx:         testTxs[3],
377                                                 StatusFail: false,
378                                         },
379                                 },
380                                 utxo: map[bc.Hash]*types.Tx{
381                                         *testTxs[3].ResultIds[0]: testTxs[3],
382                                         *testTxs[3].ResultIds[1]: testTxs[3],
383                                 },
384                                 eventDispatcher: dispatcher,
385                                 orphans:         map[bc.Hash]*orphanTx{},
386                                 orphansByPrev:   map[bc.Hash]map[bc.Hash]*orphanTx{},
387                         },
388                         processTx: &TxDesc{Tx: testTxs[2]},
389                 },
390                 {
391                         before: &TxPool{
392                                 pool:            map[bc.Hash]*TxDesc{},
393                                 utxo:            map[bc.Hash]*types.Tx{},
394                                 eventDispatcher: dispatcher,
395                                 orphans: map[bc.Hash]*orphanTx{
396                                         testTxs[3].ID: {
397                                                 TxDesc: &TxDesc{
398                                                         Tx: testTxs[3],
399                                                 },
400                                         },
401                                         testTxs[4].ID: {
402                                                 TxDesc: &TxDesc{
403                                                         Tx: testTxs[4],
404                                                 },
405                                         },
406                                 },
407                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{
408                                         testTxs[3].SpentOutputIDs[0]: {
409                                                 testTxs[3].ID: {
410                                                         TxDesc: &TxDesc{
411                                                                 Tx: testTxs[3],
412                                                         },
413                                                 },
414                                         },
415                                         testTxs[4].SpentOutputIDs[0]: {
416                                                 testTxs[4].ID: {
417                                                         TxDesc: &TxDesc{
418                                                                 Tx: testTxs[4],
419                                                         },
420                                                 },
421                                         },
422                                 },
423                         },
424                         after: &TxPool{
425                                 pool: map[bc.Hash]*TxDesc{
426                                         testTxs[3].ID: {
427                                                 Tx:         testTxs[3],
428                                                 StatusFail: false,
429                                         },
430                                         testTxs[4].ID: {
431                                                 Tx:         testTxs[4],
432                                                 StatusFail: false,
433                                         },
434                                 },
435                                 utxo: map[bc.Hash]*types.Tx{
436                                         *testTxs[3].ResultIds[0]: testTxs[3],
437                                         *testTxs[3].ResultIds[1]: testTxs[3],
438                                         *testTxs[4].ResultIds[0]: testTxs[4],
439                                         *testTxs[4].ResultIds[1]: testTxs[4],
440                                 },
441                                 eventDispatcher: dispatcher,
442                                 orphans:         map[bc.Hash]*orphanTx{},
443                                 orphansByPrev:   map[bc.Hash]map[bc.Hash]*orphanTx{},
444                         },
445                         processTx: &TxDesc{Tx: testTxs[2]},
446                 },
447         }
448
449         for i, c := range cases {
450                 c.before.store = &mockStore{}
451                 c.before.addTransaction(c.processTx)
452                 c.before.processOrphans(c.processTx)
453                 c.before.RemoveTransaction(&c.processTx.Tx.ID)
454                 c.before.store = nil
455                 c.before.lastUpdated = 0
456                 for _, txD := range c.before.pool {
457                         txD.Added = time.Time{}
458                 }
459
460                 if !testutil.DeepEqual(c.before, c.after) {
461                         t.Errorf("case %d: got %v want %v", i, c.before, c.after)
462                 }
463         }
464 }
465
466 func TestRemoveOrphan(t *testing.T) {
467         cases := []struct {
468                 before       *TxPool
469                 after        *TxPool
470                 removeHashes []*bc.Hash
471         }{
472                 {
473                         before: &TxPool{
474                                 orphans: map[bc.Hash]*orphanTx{
475                                         testTxs[0].ID: {
476                                                 expiration: time.Unix(1533489701, 0),
477                                                 TxDesc: &TxDesc{
478                                                         Tx: testTxs[0],
479                                                 },
480                                         },
481                                 },
482                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{
483                                         testTxs[0].SpentOutputIDs[0]: {
484                                                 testTxs[0].ID: {
485                                                         expiration: time.Unix(1533489701, 0),
486                                                         TxDesc: &TxDesc{
487                                                                 Tx: testTxs[0],
488                                                         },
489                                                 },
490                                         },
491                                 },
492                         },
493                         after: &TxPool{
494                                 orphans:       map[bc.Hash]*orphanTx{},
495                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{},
496                         },
497                         removeHashes: []*bc.Hash{
498                                 &testTxs[0].ID,
499                         },
500                 },
501                 {
502                         before: &TxPool{
503                                 orphans: map[bc.Hash]*orphanTx{
504                                         testTxs[0].ID: {
505                                                 expiration: time.Unix(1533489701, 0),
506                                                 TxDesc: &TxDesc{
507                                                         Tx: testTxs[0],
508                                                 },
509                                         },
510                                         testTxs[1].ID: {
511                                                 expiration: time.Unix(1533489701, 0),
512                                                 TxDesc: &TxDesc{
513                                                         Tx: testTxs[1],
514                                                 },
515                                         },
516                                 },
517                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{
518                                         testTxs[0].SpentOutputIDs[0]: {
519                                                 testTxs[0].ID: {
520                                                         expiration: time.Unix(1533489701, 0),
521                                                         TxDesc: &TxDesc{
522                                                                 Tx: testTxs[0],
523                                                         },
524                                                 },
525                                                 testTxs[1].ID: {
526                                                         expiration: time.Unix(1533489701, 0),
527                                                         TxDesc: &TxDesc{
528                                                                 Tx: testTxs[1],
529                                                         },
530                                                 },
531                                         },
532                                 },
533                         },
534                         after: &TxPool{
535                                 orphans: map[bc.Hash]*orphanTx{
536                                         testTxs[0].ID: {
537                                                 expiration: time.Unix(1533489701, 0),
538                                                 TxDesc: &TxDesc{
539                                                         Tx: testTxs[0],
540                                                 },
541                                         },
542                                 },
543                                 orphansByPrev: map[bc.Hash]map[bc.Hash]*orphanTx{
544                                         testTxs[0].SpentOutputIDs[0]: {
545                                                 testTxs[0].ID: {
546                                                         expiration: time.Unix(1533489701, 0),
547                                                         TxDesc: &TxDesc{
548                                                                 Tx: testTxs[0],
549                                                         },
550                                                 },
551                                         },
552                                 },
553                         },
554                         removeHashes: []*bc.Hash{
555                                 &testTxs[1].ID,
556                         },
557                 },
558         }
559
560         for i, c := range cases {
561                 for _, hash := range c.removeHashes {
562                         c.before.removeOrphan(hash)
563                 }
564                 if !testutil.DeepEqual(c.before, c.after) {
565                         t.Errorf("case %d: got %v want %v", i, c.before, c.after)
566                 }
567         }
568 }
569
570 type mockStore1 struct{}
571
572 func (s *mockStore1) BlockExist(hash *bc.Hash) bool                                { return false }
573 func (s *mockStore1) GetBlock(*bc.Hash) (*types.Block, error)                      { return nil, nil }
574 func (s *mockStore1) GetStoreStatus() *BlockStoreState                             { return nil }
575 func (s *mockStore1) GetTransactionStatus(*bc.Hash) (*bc.TransactionStatus, error) { return nil, nil }
576 func (s *mockStore1) GetTransactionsUtxo(utxoView *state.UtxoViewpoint, tx []*bc.Tx) error {
577         for _, hash := range testTxs[2].SpentOutputIDs {
578                 utxoView.Entries[hash] = &storage.UtxoEntry{IsCoinBase: false, Spent: false}
579         }
580         return nil
581 }
582 func (s *mockStore1) GetUtxo(*bc.Hash) (*storage.UtxoEntry, error)                 { return nil, nil }
583 func (s *mockStore1) LoadBlockIndex(uint64) (*state.BlockIndex, error)             { return nil, nil }
584 func (s *mockStore1) SaveBlock(*types.Block, *bc.TransactionStatus) error          { return nil }
585 func (s *mockStore1) SaveChainStatus(*state.BlockNode, *state.UtxoViewpoint) error { return nil }
586
587 func TestProcessTransaction(t *testing.T) {
588         txPool := &TxPool{
589                 pool:            make(map[bc.Hash]*TxDesc),
590                 utxo:            make(map[bc.Hash]*types.Tx),
591                 orphans:         make(map[bc.Hash]*orphanTx),
592                 orphansByPrev:   make(map[bc.Hash]map[bc.Hash]*orphanTx),
593                 store:           &mockStore1{},
594                 eventDispatcher: event.NewDispatcher(),
595         }
596         cases := []struct {
597                 want  *TxPool
598                 addTx *TxDesc
599         }{
600                 //Dust tx
601                 {
602                         want: &TxPool{},
603                         addTx: &TxDesc{
604                                 Tx:         testTxs[3],
605                                 StatusFail: false,
606                         },
607                 },
608                 //normal tx
609                 {
610                         want: &TxPool{
611                                 pool: map[bc.Hash]*TxDesc{
612                                         testTxs[2].ID: {
613                                                 Tx:         testTxs[2],
614                                                 StatusFail: false,
615                                                 Weight:     150,
616                                         },
617                                 },
618                                 utxo: map[bc.Hash]*types.Tx{
619                                         *testTxs[2].ResultIds[0]: testTxs[2],
620                                         *testTxs[2].ResultIds[1]: testTxs[2],
621                                 },
622                         },
623                         addTx: &TxDesc{
624                                 Tx:         testTxs[2],
625                                 StatusFail: false,
626                         },
627                 },
628         }
629
630         for i, c := range cases {
631                 txPool.ProcessTransaction(c.addTx.Tx, c.addTx.StatusFail, 0, 0)
632                 for _, txD := range txPool.pool {
633                         txD.Added = time.Time{}
634                 }
635                 for _, txD := range txPool.orphans {
636                         txD.Added = time.Time{}
637                         txD.expiration = time.Time{}
638                 }
639
640                 if !testutil.DeepEqual(txPool.pool, c.want.pool) {
641                         t.Errorf("case %d: test ProcessTransaction pool mismatch got %s want %s", i, spew.Sdump(txPool.pool), spew.Sdump(c.want.pool))
642                 }
643                 if !testutil.DeepEqual(txPool.utxo, c.want.utxo) {
644                         t.Errorf("case %d: test ProcessTransaction utxo mismatch got %s want %s", i, spew.Sdump(txPool.utxo), spew.Sdump(c.want.utxo))
645                 }
646                 if !testutil.DeepEqual(txPool.orphans, c.want.orphans) {
647                         t.Errorf("case %d: test ProcessTransaction orphans mismatch got %s want %s", i, spew.Sdump(txPool.orphans), spew.Sdump(c.want.orphans))
648                 }
649                 if !testutil.DeepEqual(txPool.orphansByPrev, c.want.orphansByPrev) {
650                         t.Errorf("case %d: test ProcessTransaction orphansByPrev mismatch got %s want %s", i, spew.Sdump(txPool.orphansByPrev), spew.Sdump(c.want.orphansByPrev))
651                 }
652         }
653 }