OSDN Git Service

rename (#465)
[bytom/vapor.git] / test / utxo_view / utxo_view_test_util.go
1 package utxo_view
2
3 import (
4         "encoding/hex"
5
6         "github.com/bytom/vapor/consensus"
7         "github.com/bytom/vapor/protocol/bc"
8         "github.com/bytom/vapor/protocol/bc/types"
9         "github.com/bytom/vapor/testutil"
10 )
11
12 const utxoPreFix = "UT:"
13
14 func calcUtxoKey(hash *bc.Hash) []byte {
15         return []byte(utxoPreFix + hash.String())
16 }
17
18 type tx struct {
19         Tx *types.Tx
20 }
21
22 func newTx(t *types.Tx) *tx {
23         return &tx{
24                 Tx: t,
25         }
26 }
27
28 func (t *tx) getSourceID(outIndex int) *bc.Hash {
29         output := t.Tx.Entries[*t.Tx.OutputID(outIndex)].(*bc.IntraChainOutput)
30         return output.Source.Ref
31 }
32
33 func (t *tx) getAmount(outIndex int) uint64 {
34         output := t.Tx.Entries[*t.Tx.OutputID(outIndex)].(*bc.IntraChainOutput)
35         return output.Source.Value.Amount
36 }
37
38 func (t *tx) getSpentOutputID(index int) bc.Hash {
39         input, err := t.Tx.Spend(t.Tx.InputIDs[index])
40         if err != nil {
41                 panic(err)
42         }
43
44         return *input.SpentOutputId
45 }
46
47 func (t *tx) OutputHash(outIndex int) *bc.Hash {
48         return t.Tx.ResultIds[outIndex]
49 }
50
51 func mustDecodeHex(str string) []byte {
52         data, err := hex.DecodeString(str)
53         if err != nil {
54                 panic(err)
55         }
56         return data
57 }
58
59 func coinBaseTx(amount uint64, arbitrary string) *types.Tx {
60         return types.NewTx(types.TxData{
61                 Inputs: []*types.TxInput{
62                         types.NewCoinbaseInput([]byte(arbitrary)),
63                 },
64                 Outputs: []*types.TxOutput{
65                         types.NewIntraChainOutput(*consensus.BTMAssetID, amount, mustDecodeHex("00144431c4278632c6e35dd2870faa1a4b8e0a275cbc")),
66                 },
67         })
68 }
69
70 var mockTransaction = []*tx{}
71 var mockBlocks = []*block{}
72
73 func toHash(hash string) bc.Hash {
74         sourceID := bc.Hash{}
75         sourceID.UnmarshalText([]byte(hash))
76         return sourceID
77 }
78
79 func toAssetID(assetID string) bc.AssetID {
80         asset := bc.AssetID{}
81         if err := asset.UnmarshalText([]byte(assetID)); err != nil {
82                 panic(err)
83         }
84         return asset
85 }
86
87 type block struct {
88         types.Block
89 }
90
91 func init() {
92         // 0
93         mockTransaction = []*tx{}
94         t := &tx{
95                 Tx: types.NewTx(types.TxData{
96                         Inputs: []*types.TxInput{
97                                 types.NewSpendInput(nil, toHash("ca9b179e549406aa583869e124e39817414d4500a8ce5476e95b6018d182b966"), *consensus.BTMAssetID, 41250000000, 0, []byte("00144431c4278632c6e35dd2870faa1a4b8e0a275cbc")),
98                         },
99                         Outputs: []*types.TxOutput{
100                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("00148c704747e94387fa0b8712b053ed2132d84820ac")),
101                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 41150000000, []byte("00144431c4278632c6e35dd2870faa1a4b8e0a275cbc")),
102                         },
103                 }),
104         }
105         mockTransaction = append(mockTransaction, t)
106
107         // 1
108         t = &tx{
109                 Tx: types.NewTx(types.TxData{
110                         Inputs: []*types.TxInput{
111                                 types.NewSpendInput(nil, *mockTransaction[0].getSourceID(1), *consensus.BTMAssetID, 41150000000, 1, []byte("00144431c4278632c6e35dd2870faa1a4b8e0a275cbc")),
112                         },
113                         Outputs: []*types.TxOutput{
114                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("00148c704747e94387fa0b8712b053ed2132d84820ac")),
115                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 41050000000, []byte("00144431c4278632c6e35dd2870faa1a4b8e0a275cbc")),
116                         },
117                 }),
118         }
119         mockTransaction = append(mockTransaction, t)
120
121         // 2
122         t = &tx{
123                 Tx: types.NewTx(types.TxData{
124                         Inputs: []*types.TxInput{
125                                 types.NewSpendInput(nil, *mockTransaction[1].getSourceID(1), *consensus.BTMAssetID, 41050000000, 1, []byte("00144431c4278632c6e35dd2870faa1a4b8e0a275cbc")),
126                         },
127                         Outputs: []*types.TxOutput{
128                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("00148c704747e94387fa0b8712b053ed2132d84820ac")),
129                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 40950000000, []byte("00144431c4278632c6e35dd2870faa1a4b8e0a275cbc")),
130                         },
131                 }),
132         }
133         mockTransaction = append(mockTransaction, t)
134
135         // 3: 00140b0c5059514c751a80c4e1c94f8ecfe16d80671b -> 0014b103d8f2dc10e7bbbe2557ff8b9876524dec0a7e
136         assetID := toAssetID("5c3b60753fe1f8321298d64ab3881b200fa1d7e56f1b2a2df587233c532c5eb6")
137         t = &tx{
138                 Tx: types.NewTx(types.TxData{
139                         Inputs: []*types.TxInput{
140                                 types.NewSpendInput(nil, toHash("453936067da4be89a99bbd78aa8c7eb88cbe92ae0941e1013a58b8d6af65d344"), *consensus.BTMAssetID, 41250000000, 0, []byte("00140b0c5059514c751a80c4e1c94f8ecfe16d80671b")),
141                                 types.NewSpendInput(nil, toHash("50d1c966b3a58f9092a696136a75ceb801ea7da2470784d80ebf3f17a76b8a98"), assetID, 800000000000, 0, []byte("00140b0c5059514c751a80c4e1c94f8ecfe16d80671b")),
142                         },
143                         Outputs: []*types.TxOutput{
144                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 41150000000, []byte("0014b103d8f2dc10e7bbbe2557ff8b9876524dec0a7e")),
145                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("00140b0c5059514c751a80c4e1c94f8ecfe16d80671b")),
146                                 types.NewIntraChainOutput(assetID, 700000000000, []byte("0014b103d8f2dc10e7bbbe2557ff8b9876524dec0a7e")),
147                                 types.NewIntraChainOutput(assetID, 100000000000, []byte("00140b0c5059514c751a80c4e1c94f8ecfe16d80671b")),
148                         },
149                 }),
150         }
151         mockTransaction = append(mockTransaction, t)
152
153         // 4
154         t = &tx{
155                 Tx: types.NewTx(types.TxData{
156                         Inputs: []*types.TxInput{
157                                 types.NewSpendInput(nil, toHash("ca9b179e549406aa583869e124e39817514d4500a8ce5476e95b6018d182b966"), *consensus.BTMAssetID, 41250000000, 0, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
158                                 types.NewSpendInput(nil, toHash("d9a9b64e4f842060a40b15325d9aae61987776f7748e7e6a2887a474e84294ef"), assetID, 600000000000, 0, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
159                         },
160                         Outputs: []*types.TxOutput{
161                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce")),
162                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 41150000000, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
163                                 types.NewIntraChainOutput(assetID, 600000000000, []byte("0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce")),
164                                 types.NewIntraChainOutput(assetID, 400000000000, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
165                         },
166                 }),
167         }
168         mockTransaction = append(mockTransaction, t)
169
170         // 5: 0014b103d8f2dc10e7bbbe2557ff8b9876524dec0a7e -> 00142b248deeffe82f9cd94fab43849468e0dfe97806
171         t = &tx{
172                 Tx: types.NewTx(types.TxData{
173                         Inputs: []*types.TxInput{
174                                 types.NewSpendInput(nil, toHash("ca9b179e549406aa583869e124e39817514d4500a8ce5476e95b6018d182b966"), *consensus.BTMAssetID, 41150000000, 1, []byte("0014b103d8f2dc10e7bbbe2557ff8b9876524dec0a7e")),
175                                 types.NewSpendInput(nil, toHash("466e6a9261d7b51f227d6c05b7cd3cc36487cc6f0cfb79c58794021e68d4c877"), assetID, 300000000000, 0, []byte("0014b103d8f2dc10e7bbbe2557ff8b9876524dec0a7e")),
176                         },
177                         Outputs: []*types.TxOutput{
178                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 41050000000, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
179                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("0014b103d8f2dc10e7bbbe2557ff8b9876524dec0a7e")),
180                                 types.NewIntraChainOutput(assetID, 200000000000, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
181                                 types.NewIntraChainOutput(assetID, 100000000000, []byte("0014b103d8f2dc10e7bbbe2557ff8b9876524dec0a7e")),
182                         },
183                 }),
184         }
185         mockTransaction = append(mockTransaction, t)
186
187         //6: 00142b248deeffe82f9cd94fab43849468e0dfe97806 -> 0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce
188         t = &tx{
189                 Tx: types.NewTx(types.TxData{
190                         Inputs: []*types.TxInput{
191                                 types.NewSpendInput(nil, toHash("ca9b179e549406aa583869e124e39817514d4500a8ce5476e95b6018d182b966"), *consensus.BTMAssetID, 41050000000, 2, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
192                                 types.NewSpendInput(nil, toHash("e5757774fb46287ebda3479e19c8643d2fcdb5de3b1ac84d4020c1971bb3f531"), assetID, 100000000000, 0, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
193                         },
194                         Outputs: []*types.TxOutput{
195                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 40950000000, []byte("0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce")),
196                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
197                                 types.NewIntraChainOutput(assetID, 50000000000, []byte("0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce")),
198                                 types.NewIntraChainOutput(assetID, 50000000000, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
199                         },
200                 }),
201         }
202         mockTransaction = append(mockTransaction, t)
203
204         // 7: 0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce -> 0014e3bb841fb722d1840a959d86e12a174c54a3a6e8
205         t = &tx{
206                 Tx: types.NewTx(types.TxData{
207                         Inputs: []*types.TxInput{
208                                 types.NewSpendInput(nil, toHash("ca9b179e549406aa583869e124e39817514d4500a8ce5476e95b6018d182b966"), *consensus.BTMAssetID, 40950000000, 3, []byte("0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce")),
209                         },
210                         Outputs: []*types.TxOutput{
211                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 40850000000, []byte("0014e3bb841fb722d1840a959d86e12a174c54a3a6e8")),
212                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce")),
213                         },
214                 }),
215         }
216         mockTransaction = append(mockTransaction, t)
217
218         // 8: 0014e3bb841fb722d1840a959d86e12a174c54a3a6e8 -> 001449601d4cfb6e7a1b990778497b3c364f66bc17d2
219         t = &tx{
220                 Tx: types.NewTx(types.TxData{
221                         Inputs: []*types.TxInput{
222                                 types.NewSpendInput(nil, toHash("ca9b179e549406aa583869e124e39817514d4500a8ce5476e95b6018d182b966"), *consensus.BTMAssetID, 40850000000, 4, []byte("0014e3bb841fb722d1840a959d86e12a174c54a3a6e8")),
223                         },
224                         Outputs: []*types.TxOutput{
225                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 40750000000, []byte("001449601d4cfb6e7a1b990778497b3c364f66bc17d2")),
226                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("0014e3bb841fb722d1840a959d86e12a174c54a3a6e8")),
227                         },
228                 }),
229         }
230         mockTransaction = append(mockTransaction, t)
231
232         // 9: 001449601d4cfb6e7a1b990778497b3c364f66bc17d2 -> 0014bd3d70b1bcd62ece61c06a2fe097a4732e5f006b
233         t = &tx{
234                 Tx: types.NewTx(types.TxData{
235                         Inputs: []*types.TxInput{
236                                 types.NewSpendInput(nil, toHash("ca9b179e549406aa583869e124e39817514d4500a8ce5476e95b6018d182b966"), *consensus.BTMAssetID, 40750000000, 5, []byte("001449601d4cfb6e7a1b990778497b3c364f66bc17d2")),
237                         },
238                         Outputs: []*types.TxOutput{
239                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 40650000000, []byte("0014bd3d70b1bcd62ece61c06a2fe097a4732e5f006b")),
240                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("001449601d4cfb6e7a1b990778497b3c364f66bc17d2")),
241                         },
242                 }),
243         }
244         mockTransaction = append(mockTransaction, t)
245
246         // 10: 0014bd3d70b1bcd62ece61c06a2fe097a4732e5f006b -> 0014e809cb6f328db1e624821dec508cbe08fe1ed08d
247         t = &tx{
248                 Tx: types.NewTx(types.TxData{
249                         Inputs: []*types.TxInput{
250                                 types.NewSpendInput(nil, toHash("ca9b179e549406aa583869e124e39817514d4500a8ce5476e95b6018d182b966"), *consensus.BTMAssetID, 40650000000, 6, []byte("0014bd3d70b1bcd62ece61c06a2fe097a4732e5f006b")),
251                         },
252                         Outputs: []*types.TxOutput{
253                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 40550000000, []byte("0014e809cb6f328db1e624821dec508cbe08fe1ed08d")),
254                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("0014bd3d70b1bcd62ece61c06a2fe097a4732e5f006b")),
255                         },
256                 }),
257         }
258         mockTransaction = append(mockTransaction, t)
259
260         // Chain trading
261         // 11: 0014b103d8f2dc10e7bbbe2557ff8b9876524dec0a7e -> 00142b248deeffe82f9cd94fab43849468e0dfe97806
262         t = &tx{
263                 Tx: types.NewTx(types.TxData{
264                         Inputs: []*types.TxInput{
265                                 types.NewSpendInput(nil, *mockTransaction[3].getSourceID(0), *consensus.BTMAssetID, 41150000000, 0, []byte("0014b103d8f2dc10e7bbbe2557ff8b9876524dec0a7e")),
266                         },
267                         Outputs: []*types.TxOutput{
268                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 41050000000, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
269                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("0014b103d8f2dc10e7bbbe2557ff8b9876524dec0a7e")),
270                         },
271                 }),
272         }
273         mockTransaction = append(mockTransaction, t)
274
275         //12: 00142b248deeffe82f9cd94fab43849468e0dfe97806 -> 0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce
276         t = &tx{
277                 Tx: types.NewTx(types.TxData{
278                         Inputs: []*types.TxInput{
279                                 types.NewSpendInput(nil, *mockTransaction[11].getSourceID(0), *consensus.BTMAssetID, 41050000000, 0, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
280                         },
281                         Outputs: []*types.TxOutput{
282                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 40950000000, []byte("0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce")),
283                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("00142b248deeffe82f9cd94fab43849468e0dfe97806")),
284                         },
285                 }),
286         }
287         mockTransaction = append(mockTransaction, t)
288
289         // 13: 0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce -> 0014e3bb841fb722d1840a959d86e12a174c54a3a6e8
290         t = &tx{
291                 Tx: types.NewTx(types.TxData{
292                         Inputs: []*types.TxInput{
293                                 types.NewSpendInput(nil, *mockTransaction[12].getSourceID(0), *consensus.BTMAssetID, 40950000000, 0, []byte("0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce")),
294                         },
295                         Outputs: []*types.TxOutput{
296                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 40850000000, []byte("0014e3bb841fb722d1840a959d86e12a174c54a3a6e8")),
297                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("0014492d5b0f09f83bd9bff6a44514dcc9b11c091dce")),
298                         },
299                 }),
300         }
301         mockTransaction = append(mockTransaction, t)
302
303         // 14: 0014e3bb841fb722d1840a959d86e12a174c54a3a6e8 -> 001449601d4cfb6e7a1b990778497b3c364f66bc17d2
304         t = &tx{
305                 Tx: types.NewTx(types.TxData{
306                         Inputs: []*types.TxInput{
307                                 types.NewSpendInput(nil, *mockTransaction[13].getSourceID(0), *consensus.BTMAssetID, 40850000000, 0, []byte("0014e3bb841fb722d1840a959d86e12a174c54a3a6e8")),
308                         },
309                         Outputs: []*types.TxOutput{
310                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 40750000000, []byte("001449601d4cfb6e7a1b990778497b3c364f66bc17d2")),
311                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("0014e3bb841fb722d1840a959d86e12a174c54a3a6e8")),
312                         },
313                 }),
314         }
315         mockTransaction = append(mockTransaction, t)
316
317         // 15: 001449601d4cfb6e7a1b990778497b3c364f66bc17d2 -> 0014bd3d70b1bcd62ece61c06a2fe097a4732e5f006b
318         t = &tx{
319                 Tx: types.NewTx(types.TxData{
320                         Inputs: []*types.TxInput{
321                                 types.NewSpendInput(nil, *mockTransaction[14].getSourceID(0), *consensus.BTMAssetID, 40750000000, 0, []byte("001449601d4cfb6e7a1b990778497b3c364f66bc17d2")),
322                         },
323                         Outputs: []*types.TxOutput{
324                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 40650000000, []byte("0014bd3d70b1bcd62ece61c06a2fe097a4732e5f006b")),
325                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("001449601d4cfb6e7a1b990778497b3c364f66bc17d2")),
326                         },
327                 }),
328         }
329         mockTransaction = append(mockTransaction, t)
330
331         // 16: 0014bd3d70b1bcd62ece61c06a2fe097a4732e5f006b -> 0014e809cb6f328db1e624821dec508cbe08fe1ed08d
332         t = &tx{
333                 Tx: types.NewTx(types.TxData{
334                         Inputs: []*types.TxInput{
335                                 types.NewSpendInput(nil, *mockTransaction[15].getSourceID(0), *consensus.BTMAssetID, 40650000000, 0, []byte("0014bd3d70b1bcd62ece61c06a2fe097a4732e5f006b")),
336                         },
337                         Outputs: []*types.TxOutput{
338                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 40550000000, []byte("0014e809cb6f328db1e624821dec508cbe08fe1ed08d")),
339                                 types.NewIntraChainOutput(*consensus.BTMAssetID, 100000000, []byte("0014bd3d70b1bcd62ece61c06a2fe097a4732e5f006b")),
340                         },
341                 }),
342         }
343         mockTransaction = append(mockTransaction, t)
344
345         mockBlocks = []*block{
346                 // coinbase tx
347                 &block{Block: types.Block{
348                         BlockHeader: types.BlockHeader{
349                                 Height:            100,
350                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
351                                 Timestamp:         1522908275000,
352                         },
353                         Transactions: []*types.Tx{
354                                 coinBaseTx(41250000000, "arbitrary block0"),
355                         },
356                 }},
357
358                 // Chain trading 3
359                 &block{Block: types.Block{
360                         BlockHeader: types.BlockHeader{
361                                 Height:            101,
362                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
363                                 Timestamp:         1522908275000,
364                         },
365                         Transactions: []*types.Tx{
366                                 coinBaseTx(41250000000, "arbitrary block1"),
367                                 mockTransaction[0].Tx,
368                                 mockTransaction[1].Tx,
369                                 mockTransaction[2].Tx,
370                         },
371                 }},
372
373                 // detach block 1, attach block 2
374                 &block{Block: types.Block{
375                         BlockHeader: types.BlockHeader{
376                                 Height:            102,
377                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
378                                 Timestamp:         1522908275000,
379                         },
380                         Transactions: []*types.Tx{
381                                 coinBaseTx(41250000000, "arbitrary block2"),
382                                 mockTransaction[0].Tx,
383                         },
384                 }},
385
386                 &block{Block: types.Block{
387                         BlockHeader: types.BlockHeader{
388                                 Height:            102,
389                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
390                                 Timestamp:         1522908275000,
391                         },
392                         Transactions: []*types.Tx{
393                                 coinBaseTx(41250000000, "arbitrary block3"),
394                                 mockTransaction[0].Tx,
395                         },
396                 }},
397
398                 &block{Block: types.Block{
399                         BlockHeader: types.BlockHeader{
400                                 Height:            103,
401                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
402                                 Timestamp:         1522908275000,
403                         },
404                         Transactions: []*types.Tx{
405                                 coinBaseTx(41250000000, "arbitrary block4"),
406                                 mockTransaction[1].Tx,
407                         },
408                 }},
409
410                 // detach block 5, attach block 2
411                 &block{Block: types.Block{
412                         BlockHeader: types.BlockHeader{
413                                 Height:            104,
414                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
415                                 Timestamp:         1522908275000,
416                         },
417                         Transactions: []*types.Tx{
418                                 coinBaseTx(41250000000, "arbitrary block5"),
419                                 mockTransaction[2].Tx,
420                         },
421                 }},
422                 &block{Block: types.Block{
423                         BlockHeader: types.BlockHeader{
424                                 Height:            105,
425                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
426                                 Timestamp:         1522908275000,
427                         },
428                         Transactions: []*types.Tx{
429                                 coinBaseTx(41250000000, "arbitrary block6"),
430                                 mockTransaction[3].Tx,
431                                 mockTransaction[4].Tx,
432                         },
433                 }},
434                 &block{Block: types.Block{
435                         BlockHeader: types.BlockHeader{
436                                 Height:            106,
437                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
438                                 Timestamp:         1522908275000,
439                         },
440                         Transactions: []*types.Tx{
441                                 coinBaseTx(41250000000, "arbitrary block7"),
442                                 mockTransaction[5].Tx,
443                         },
444                 }},
445                 &block{Block: types.Block{
446                         BlockHeader: types.BlockHeader{
447                                 Height:            107,
448                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
449                                 Timestamp:         1522908275000,
450                         },
451                         Transactions: []*types.Tx{
452                                 coinBaseTx(41250000000, "arbitrary block8"),
453                                 mockTransaction[6].Tx,
454                                 mockTransaction[7].Tx,
455                                 mockTransaction[8].Tx,
456                         },
457                 }},
458                 &block{Block: types.Block{
459                         BlockHeader: types.BlockHeader{
460                                 Height:            108,
461                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
462                                 Timestamp:         1522908275000,
463                         },
464                         Transactions: []*types.Tx{
465                                 coinBaseTx(41250000000, "arbitrary block9"),
466                                 mockTransaction[9].Tx,
467                         },
468                 }},
469
470                 // detach block 5, attach block 2. Chain trading
471                 &block{Block: types.Block{
472                         BlockHeader: types.BlockHeader{
473                                 Height:            105,
474                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
475                                 Timestamp:         1522908275000,
476                         },
477                         Transactions: []*types.Tx{
478                                 coinBaseTx(41250000000, "arbitrary block10"),
479                                 mockTransaction[2].Tx,
480                                 mockTransaction[3].Tx,
481                                 mockTransaction[4].Tx,
482                                 mockTransaction[5].Tx,
483                                 mockTransaction[6].Tx,
484                         },
485                 }},
486
487                 &block{Block: types.Block{
488                         BlockHeader: types.BlockHeader{
489                                 Height:            105,
490                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
491                                 Timestamp:         1522908275000,
492                         },
493                         Transactions: []*types.Tx{
494                                 coinBaseTx(41250000000, "arbitrary block11"),
495                                 mockTransaction[7].Tx,
496                                 mockTransaction[8].Tx,
497                                 mockTransaction[9].Tx,
498                         },
499                 }},
500
501                 // detach block 2, attach block 1. Chain trading
502                 &block{Block: types.Block{
503                         BlockHeader: types.BlockHeader{
504                                 Height:            106,
505                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
506                                 Timestamp:         1522908275000,
507                         },
508                         Transactions: []*types.Tx{
509                                 coinBaseTx(41250000000, "arbitrary block12"),
510                                 mockTransaction[11].Tx,
511                                 mockTransaction[12].Tx,
512                                 mockTransaction[13].Tx,
513                                 mockTransaction[14].Tx,
514                         },
515                 }},
516                 &block{Block: types.Block{
517                         BlockHeader: types.BlockHeader{
518                                 Height:            107,
519                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
520                                 Timestamp:         1522908275000,
521                         },
522                         Transactions: []*types.Tx{
523                                 coinBaseTx(41250000000, "arbitrary block13"),
524                                 mockTransaction[15].Tx,
525                                 mockTransaction[16].Tx,
526                         },
527                 }},
528
529                 &block{Block: types.Block{
530                         BlockHeader: types.BlockHeader{
531                                 Height:            106,
532                                 PreviousBlockHash: testutil.MustDecodeHash("0ab29c0bd7bff3b3b7eb98802f8d5f8833884c86c0fb21559a65cc58dda99667"),
533                                 Timestamp:         1522908275000,
534                         },
535                         Transactions: []*types.Tx{
536                                 coinBaseTx(41250000000, "arbitrary block14"),
537                         },
538                 }},
539         }
540
541 }