OSDN Git Service

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