github.com/Bytom/bytom@v1.1.2-0.20210127130405-ae40204c0b09/test/utxo_view/utxo_view_test_util.go (about)

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