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