zcashd/src/test/miner_tests.cpp

421 lines
40 KiB
C++
Raw Normal View History

// Copyright (c) 2011-2014 The Bitcoin Core developers
2014-12-12 20:09:33 -08:00
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "arith_uint256.h"
#include "consensus/validation.h"
2012-05-22 14:55:15 -07:00
#include "main.h"
#include "miner.h"
#include "pubkey.h"
#include "uint256.h"
2012-04-17 11:37:47 -07:00
#include "util.h"
2016-04-07 23:38:56 -07:00
#include "crypto/equihash.h"
#include "test/test_bitcoin.h"
#include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(miner_tests, TestingSetup)
2016-04-07 23:38:56 -07:00
#define NUM_EQUIHASH_SOLUTIONS 32
2012-05-22 14:55:15 -07:00
static
struct {
2016-04-07 23:38:56 -07:00
const char *nonce_hex;
uint32_t vSolutions[NUM_EQUIHASH_SOLUTIONS];
2012-05-22 14:55:15 -07:00
} blockinfo[] = {
{"0000000000000000000000000000000000000000000000000000000000000000", {235,65029,45368,98164,12719,41416,54778,126678,36687,50519,38205,46645,41843,65062,44021,125867,5393,71268,72227,90535,6016,51231,50075,121116,7789,67777,72674,77789,12817,113149,35048,74889,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {802,2470,82865,126091,4290,56329,50451,84100,17163,21935,22594,103016,17822,28961,93874,98180,12398,121178,53234,128710,44556,98033,46816,120890,44492,57487,53675,83675,51365,52958,98868,107516,}},
{"0000000000000000000000000000000000000000000000000000000000000004", {1714,115778,24542,123620,9417,114821,64402,119047,15330,80205,93690,111881,52681,80723,89061,120532,1928,68992,96580,105657,10806,58310,24637,72792,20038,83172,22484,116059,40313,122574,100688,117977,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3181,92424,65529,114980,5122,50206,24349,44901,7992,63999,10855,83788,89862,120503,127631,129544,5974,73070,81792,96252,12135,52433,50007,128006,14134,57561,25554,62328,41153,64018,128316,130790,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {462,47204,88431,91563,10036,80940,36928,53580,2272,98312,107969,127762,46492,96887,112619,127503,1826,64537,69811,120925,21517,84329,89711,125021,16765,97320,25821,34645,31456,36167,33934,80770,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4536,70653,20267,109536,41591,46655,52723,112375,25278,95099,123317,125894,62191,79881,83919,88859,20725,128181,73447,81121,47442,69731,61489,76637,39324,39473,69872,76021,47874,130318,76547,127864,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2437,104537,26766,67203,77710,80873,101053,122081,17553,74588,49907,119548,28425,100700,37855,124993,7581,61033,19655,72560,39735,58434,70025,107839,9569,19450,57774,85238,16196,104333,42299,73549,}},
{"0000000000000000000000000000000000000000000000000000000000000005", {577,47641,51961,116531,35858,70798,79577,107257,7990,79081,41682,95638,10275,122892,43365,74503,4672,85859,55990,117330,6955,103966,16310,86763,14582,19945,42038,106864,34782,43359,41837,110663,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3432,16038,81253,115127,21358,96302,33069,105136,9149,52335,64799,87576,75312,80579,83428,98811,3482,121292,9179,90964,67648,93789,114300,121361,7122,90504,13900,71334,56844,105173,67225,124454,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1347,97821,39742,103801,57191,129729,92952,107206,12351,91255,44568,106427,22864,23736,71593,97214,5475,37568,8676,45753,25993,125484,29860,76295,19817,88620,39810,48530,29954,124301,33306,44406,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2507,35457,44295,54297,18653,96198,59686,101509,25980,126793,58231,99111,49684,86077,112594,120310,12247,116080,107040,114215,21894,59079,54018,123948,26703,110914,54690,86685,29459,121801,106525,122150,}},
{"0000000000000000000000000000000000000000000000000000000000000005", {1761,49893,7652,25214,13680,81252,48359,49958,11270,53144,37928,82424,39020,94879,41658,68230,8419,68052,28952,57536,55082,117267,66151,72121,18377,75029,90343,106555,41650,45125,51121,56902,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {989,47806,56699,75701,40682,129114,104752,130210,16515,117767,31366,61385,17324,104728,67998,127493,5333,9637,47996,123300,18988,106064,78337,108164,11924,49880,64385,122580,28824,112970,68565,120344,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1650,7101,87115,106069,16472,107372,30741,47465,4783,129120,72323,123589,16367,27296,82896,98509,3639,101344,35297,111495,16334,129448,82699,122901,5451,82139,81306,129977,62836,68689,79941,124419,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3699,59367,55122,60539,37298,101020,43320,51575,14789,46768,15475,70161,70256,123564,83243,86829,8018,87593,8838,127864,35937,111692,43097,85757,12878,33352,63629,82049,15564,51885,29171,117888,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1926,18553,16930,92149,36872,63597,37846,79385,30278,71190,71709,72100,32861,42077,50302,102436,13975,26469,27368,77965,21160,40355,56436,123398,14099,123948,24458,41396,56007,96778,102823,127270,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {65,12985,74297,130318,43532,128669,66111,113064,31107,73096,44380,59856,33815,92179,52866,96696,14296,38000,48460,59944,21462,79064,92625,104110,15594,90628,43407,112754,52163,130308,60843,76313,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {6498,55549,53149,121199,48427,81377,70468,95775,7361,66238,19543,76591,56018,91376,79663,120074,8705,105601,71278,125138,55490,122021,57038,90434,12828,43541,83816,87598,27234,49618,58775,100555,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1709,5066,75112,123463,19655,45245,108419,114698,3734,73301,80400,116827,26871,110315,53580,107920,11752,41948,22677,46612,69207,121552,76783,122273,19456,46985,28443,83926,62999,120394,75857,110787,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3321,81671,65591,83849,47104,68414,107691,129980,12174,66460,16510,86912,13936,122447,15478,28301,7240,112584,53184,100659,8294,50002,60833,130588,28178,72512,57116,94627,28318,102289,42011,125025,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2363,101121,87260,98687,3091,118155,51013,69127,27960,88512,49881,105635,37899,120361,64809,82405,5561,9477,17763,42811,43584,106282,116637,126133,15943,98126,21312,113465,66460,101382,78048,87916,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1916,124580,15413,37614,26226,54521,31899,83723,36374,65209,47265,69358,40649,77493,71883,119007,7041,59236,40245,76142,17225,65779,59156,87089,22923,88154,120805,125259,33238,82806,34930,122891,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {84,123215,6049,93569,325,21624,60478,72231,11212,130603,80693,115975,22696,80399,79311,97282,4245,44256,21608,77584,32234,130948,67798,72805,30802,108287,51276,86470,79393,98581,88128,93585,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2971,123979,22949,46363,26782,66849,72167,88643,5338,81027,87050,99944,28104,98323,80665,122053,44640,53876,88745,94856,47738,70991,66526,70160,49067,58417,77750,127337,61435,70111,62409,108630,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {10329,105403,16620,62000,27182,97334,27187,33671,18648,20995,63119,108614,29525,129881,33914,56955,13536,38981,95691,100254,18074,90790,26399,89994,25880,117738,31746,57478,39000,44123,50373,115229,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5220,59608,81416,103593,15134,28871,56168,95481,15216,106020,25741,97213,35182,93022,44865,90284,8495,124089,21754,81665,28466,119781,49744,94822,24546,34250,29156,70847,78374,123816,122055,126521,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {8926,123648,46602,47920,12887,120187,82953,102336,16895,86882,32237,60307,25252,105544,48365,62408,15546,118489,78320,111689,47889,103241,61735,104533,16238,95251,24529,63919,22991,82841,69615,112498,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {1185,112912,8038,83793,56010,80820,74681,82138,5287,96364,123236,124658,66772,121661,83509,106959,2177,46664,63197,102691,7524,62742,55488,99954,11582,100839,11830,96077,40614,63543,50922,65877,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {8827,107406,11710,32384,60870,68762,108356,121479,14421,69308,21111,21981,73091,79949,76636,96864,21689,75125,31316,86658,32451,94917,70815,130130,25285,83198,66250,90494,64714,76766,95971,120606,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {75,73504,4617,87550,8946,24502,94714,119113,33552,36437,96391,103493,70887,85236,82040,92009,3348,74345,4512,56799,47389,119413,101926,124507,3622,48139,24734,129469,45659,47040,73311,82231,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {569,115638,7006,96215,31348,60400,70855,87378,36982,118455,50619,112275,43676,60029,85608,114615,2617,93727,89450,97994,30412,87319,36194,126249,11263,40459,56651,79522,57347,112257,93446,101796,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5514,116901,7632,54175,19637,81419,80818,104024,12293,60796,44181,129189,28681,68661,55340,106139,5970,123204,38787,113763,52286,93948,81854,99224,7819,30439,75753,87651,21061,120303,27120,79910,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2929,14952,52013,77193,5866,84108,78990,100113,5003,46928,34174,43180,47580,70494,54498,81846,11531,102934,111315,114618,47090,83962,88282,107740,12181,49917,42430,111800,16606,21946,53813,102615,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {292,49634,41239,76786,11870,81077,26439,69369,7624,54952,35700,88706,49189,126520,90391,108005,18320,27521,22059,85356,50048,109324,89133,103984,21578,85609,52494,60178,56626,106010,64147,105336,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1087,121626,11801,21712,8298,43332,37626,113326,22731,112233,111618,125459,58566,125026,113767,129322,18209,45320,111207,115513,24135,30290,27213,70416,39485,129015,51975,80580,66129,89570,103553,124964,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4217,5781,64929,98941,6701,119962,19391,98876,26063,90469,75024,87992,60818,72264,67564,104578,7361,73899,39161,82656,18668,119774,74782,127335,10348,104599,81801,102996,14976,33275,24729,96519,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1974,128516,54461,80478,12757,129579,40017,73512,20716,84429,26042,40187,38586,99111,47019,128651,13752,113435,65468,92561,23671,78919,91132,91966,43612,81993,69069,73414,70213,82577,80016,95565,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {237,128266,21118,26590,32803,92212,51947,87477,18793,88158,63573,77446,20902,44854,54713,127130,5128,54184,60419,74802,38061,50413,57537,66355,44427,45425,85592,114470,60482,92782,88079,95131,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {958,82537,47989,117948,16445,63166,34010,57066,26418,64921,56343,76003,43686,113702,46599,129942,13661,89687,52704,110124,20038,38976,37611,66194,21344,107870,84795,87851,52506,76418,106087,119840,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {841,60225,36522,104379,24330,61715,46006,73412,2392,46897,16804,54353,2856,90432,118683,128270,15422,66291,18152,72867,63387,90766,85760,89667,32745,79595,41636,93626,81777,102515,89457,116064,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2167,130252,62999,83706,24526,98233,104085,119150,4945,58031,50423,90620,51439,70342,81841,98890,21352,25246,33724,109081,50722,91524,57343,63208,34817,120667,82006,126728,91909,125918,110088,123912,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1004,127996,15152,16740,24990,103217,36312,99081,26375,76653,76185,93032,28126,88569,41268,47423,6912,15981,48471,72375,18931,105689,21677,53206,23225,52456,43303,102436,23963,38486,43184,85084,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2429,4023,60604,106263,70874,126856,77657,121967,4774,45899,59210,69695,17732,87385,127092,130174,18085,103916,51407,122518,31140,58530,67755,119275,26852,85703,44191,114408,68571,86584,90381,130796,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4583,108414,55833,112848,52127,74455,85284,105022,12404,78032,13861,107577,14227,79051,36146,54957,9290,37947,67979,125812,42955,80473,46895,115605,32802,63565,72233,104998,58004,68967,105635,106258,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {573,28332,1430,90096,79787,97426,87819,90439,16609,85309,18543,66105,21879,65369,93594,113277,4121,16033,78683,125268,21060,31410,39826,69787,11482,87493,23483,63252,11872,77753,23754,87946,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {6748,123563,14869,75803,64296,99155,85310,128483,31450,102145,93979,117115,47331,49023,85122,125841,10038,75369,38375,72989,23265,95173,46402,127207,16252,34356,16681,45114,27114,92477,61891,83278,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {145,99747,78911,87955,1262,78567,25854,54233,5419,22610,27116,106074,9590,36348,13825,98861,3632,41763,22663,55896,22872,65857,107031,125979,35788,106267,62482,112928,66129,123179,71971,130333,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {75,4707,40727,53255,12261,34577,44352,120932,9846,115509,30942,116678,38174,103756,67553,102120,4258,39318,29806,34620,12409,129607,40553,67322,8768,118253,27092,128474,23030,73671,64729,96071,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {638,130529,49176,69778,4238,32821,68785,79309,40965,101098,52423,108398,43357,85111,45552,130580,4674,33150,43772,105697,82744,126165,83658,114511,11081,81829,19123,85037,52000,124665,64993,89580,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3169,11770,52257,65970,14689,122459,67844,110996,4560,94913,38409,79178,15126,103447,99419,109011,6107,6202,11814,119170,70351,109884,76863,126051,6823,88324,40784,111491,65631,73569,91945,97450,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {6172,105236,34835,39924,28022,96069,75596,84610,48886,124349,63917,66592,59457,75975,71676,122386,13471,70784,85795,105989,15422,48890,125112,125917,25213,115016,45105,129696,28694,72509,70725,126643,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2404,107799,29985,110589,73596,99849,74365,125657,27030,102769,44027,125976,32634,124601,34095,95719,4491,64663,60300,62096,68732,101166,128422,131063,6651,41825,29190,121979,11228,68034,34181,68339,}},
{"0000000000000000000000000000000000000000000000000000000000000004", {4488,25068,12291,83151,67400,127362,128010,128988,51218,64539,108632,122230,51883,96996,59125,82066,14167,101031,79558,125866,30571,85446,62023,118335,23146,99383,96949,103084,47150,117778,94183,123668,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3850,118156,98023,107697,4080,94206,47635,87653,17707,28485,31699,73303,21040,75537,63202,81217,9986,101101,94345,104882,17119,126304,111724,116028,24992,63384,26366,127666,87730,98783,117532,124397,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {807,1237,15747,89167,36049,122717,65206,74082,5571,10538,37951,38281,59532,103408,72946,84637,1663,66653,55212,124124,25693,66321,50916,101072,18758,54850,21529,109091,25910,106720,102314,103401,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {8163,53077,42352,52231,17034,111546,66695,91496,20977,99389,37648,113583,23206,71671,66032,117251,20788,117400,29074,95948,41114,89730,101899,123605,50612,119014,66190,79065,54308,121241,102616,121079,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1396,118206,49526,102347,8551,88490,79726,109818,5269,33955,47078,113454,8019,113287,12698,122094,2570,84299,4404,33070,4018,33799,58599,67636,9980,37385,110028,117454,39873,55684,96580,116772,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {5709,77248,30016,110530,39174,97092,46469,103068,44684,84935,76604,124664,48454,107589,75225,87219,17554,80894,64577,64621,19194,19437,25081,74161,43780,77625,70098,118156,67252,128550,123437,123608,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1186,87220,116513,128605,97503,117529,97683,106777,8796,34464,18127,57526,22914,61379,46441,47257,3156,101905,47490,129174,19003,77474,66796,97906,9987,54420,38885,112063,10797,59182,57019,96934,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {11078,21174,11083,118363,18814,108087,75847,88436,16479,120874,89094,115470,25115,63557,119517,121792,12540,47785,56421,114352,79749,101543,84463,96178,13647,97015,23122,44338,22815,81037,61730,63108,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3891,40144,48187,119250,17939,129448,74457,126594,4302,44753,10826,36036,32159,46058,35232,51893,13365,49638,53807,103807,52450,67194,67080,128122,22407,111842,44534,55431,79308,96916,111897,125204,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2227,97772,78440,113818,14285,81582,78978,84402,2302,127845,15791,86486,85563,97574,113446,118198,4396,121378,28606,51199,6674,62216,104143,108426,11048,57415,68173,130615,13287,128051,36376,81612,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3809,108653,78780,94395,28336,60849,43795,91528,4132,97462,69778,110522,17059,64170,109401,127260,5316,11799,58175,100411,27615,44745,34737,98804,43610,115452,52571,61016,57286,127791,70401,101550,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {376,89733,20840,66104,9700,59516,20535,120112,8328,15198,34780,67956,33146,78044,35481,51898,1341,28414,79309,118354,8961,119085,38359,57706,17396,25115,65892,128377,52081,58056,68766,128732,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {4164,39944,26293,69539,14600,56011,39032,61242,5072,121349,12664,46999,6792,44235,44164,93519,8853,15440,19476,124362,21640,56334,64877,125882,14929,118094,43733,131017,55959,78067,63977,97677,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {814,59457,20018,119951,27813,79313,101760,109860,28255,82086,100369,107351,37696,77347,66908,80508,5856,35460,17779,108720,49548,54298,82286,121028,49999,121859,95247,101261,63643,93589,69480,88913,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2098,35453,102386,111388,33528,101098,36939,76911,7847,74943,44917,107937,51594,58300,58841,88290,2634,15323,30462,71398,53637,84463,76108,83415,44714,121207,76061,101011,54524,106462,85247,121474,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2567,2679,85121,106385,62856,79662,69374,88670,7776,112318,93214,113381,25509,103450,41762,110061,7491,62760,58982,98363,52109,65237,72475,129054,41613,125607,74677,94971,48446,50882,55285,82473,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {349,108928,63318,122058,13698,121229,91490,126005,18991,28691,23745,85752,24629,130720,67848,101891,11951,74946,68077,84627,44062,77794,90085,98429,20442,25284,81332,87958,42656,77629,78440,124564,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2519,80279,31074,113506,25772,27791,46210,60117,5572,124105,7744,84733,10718,65338,45461,83691,28451,84762,78750,100095,35940,129519,68728,121165,28572,116765,48612,54779,55227,106461,100714,125005,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3830,115315,11475,118724,6004,8007,109781,127240,51919,53775,115762,118814,61383,75982,108110,124397,10448,94856,92054,102827,20692,122679,32784,123550,29905,83937,31110,38952,76236,109730,84886,91788,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {461,123150,26414,32920,14338,64536,70577,113623,26266,67601,43840,57623,97345,122334,98452,130578,25527,130457,44862,113738,57394,100133,110734,116498,74554,116747,97721,129354,90330,95992,102641,130854,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {955,90403,78880,89922,35628,105867,69096,91582,15485,35608,52795,99969,17637,94589,20123,94499,3322,124176,74301,111608,16555,126958,19643,48912,14399,47790,48487,99290,64490,80126,100178,125796,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {8001,44484,32945,94446,11650,60161,72013,95132,21496,78063,24805,88929,48928,129688,78977,93603,10248,96088,107491,119046,29504,32097,55415,119251,19854,29496,49885,71936,54656,73307,98797,106783,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {945,94406,85834,95724,27872,75727,43024,105893,7521,47500,27890,117903,21870,51641,119262,127818,5411,97844,35159,46728,22305,129463,22743,103435,9809,128430,57141,105919,56896,93067,59091,65432,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {3172,117968,10378,104885,34997,105671,74219,128112,10661,39256,60339,108443,26775,72354,29561,116588,3216,60223,36285,66485,69642,104072,82574,116440,10156,119856,29496,104947,45155,78056,81634,85564,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2922,21239,9494,72176,28574,80487,112684,119613,4523,97060,34211,122635,43215,55739,109201,113139,9936,96062,48436,96296,11068,60504,29957,65638,12877,83849,41899,68534,31510,92981,82562,109167,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2176,94373,41323,86759,28156,35653,70204,107286,26982,130849,32837,85870,56813,102420,72154,110323,4429,86377,25886,104871,25371,87085,52902,86511,20298,109440,31570,34663,35939,103763,56585,104048,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1096,8759,12215,124957,46199,83192,64773,124954,3047,126418,24642,129232,7151,89125,27351,124439,16476,109819,61243,74563,49842,87328,105801,113643,44199,127343,47906,130457,66101,106855,105558,130213,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3207,66866,40992,127578,25622,59710,62940,99222,16315,48932,75106,88024,71685,128954,77027,100619,6640,86650,41619,79834,12207,74255,63882,74393,45781,94885,99563,119421,52017,94034,103989,121284,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1232,113910,67946,69629,22551,33034,85340,116748,28858,58855,82549,111848,36568,91450,76696,130634,13168,92120,27293,36210,51986,53630,69134,122274,20167,107985,56661,92688,24227,43721,36328,86415,}},
{"0000000000000000000000000000000000000000000000000000000000000003", {2019,59589,11399,93648,5777,55602,20303,28284,10084,17421,32979,50031,61625,109422,76415,91959,9497,130834,21972,41068,16085,64999,94222,103848,20372,39435,41085,117333,24089,63093,50628,90494,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {12829,37289,64570,120139,28083,48461,68430,118770,29039,120480,72588,84954,70526,95847,75275,123141,25314,64282,100323,123318,80589,84412,99664,122807,33180,114122,65544,121990,54483,94252,110062,113403,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {954,90619,6627,32066,11908,54196,58469,93878,28004,39968,60961,104395,91295,98969,94765,111156,3159,34209,25834,100177,15109,100722,109137,121304,5802,54432,25680,103382,33975,62567,99423,109575,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1590,123636,28874,59244,20144,116293,85131,99471,20881,33525,104727,117842,60864,82946,96159,128478,6754,28450,26218,68019,14983,57214,79595,117977,40307,118258,57719,111114,84404,117796,97669,103776,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {7813,23269,39597,103884,9525,52317,83126,105483,18956,40449,45770,87289,38950,70355,61272,100233,23817,84184,43022,110707,71841,120237,108425,122666,35137,101483,97487,118435,44468,120697,97454,112215,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4095,45546,84055,99103,38098,119438,45617,50276,20378,126087,32270,85793,54787,78715,69514,78048,6472,115221,9811,28274,26373,126235,97749,116063,7683,100406,76115,105350,21598,46927,99741,105747,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1298,29784,12511,70142,30291,89148,94926,129383,11609,29154,24239,30040,63156,66093,77034,119382,16266,116169,108776,125397,42864,121460,81127,121487,29771,109699,33629,90942,39367,78228,69203,113591,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2559,26161,18835,80544,6746,13101,72993,124718,8464,62998,52727,77995,14697,100270,61274,76962,14507,77822,62126,81582,31676,86885,48268,79803,14550,15544,18153,118491,27848,90587,59739,119599,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1752,58637,4385,94771,50186,84884,95884,105571,4364,22862,51696,106491,84774,125970,85392,99917,9614,104991,45824,84715,42513,74053,74061,76415,21234,121225,79217,111600,55268,116437,57805,86171,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2035,11488,37640,120536,107315,130708,124288,128847,5165,117556,85878,115139,41241,71803,82277,114167,15776,52865,73402,93531,17103,62652,63354,67707,18653,120341,50052,106690,18740,67047,20554,113050,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3868,93311,4380,115671,26157,88145,64221,124371,5761,77271,10019,70251,12162,80778,104547,121104,14282,57997,24917,120977,24090,28094,34215,94559,24466,55329,40851,98128,56708,129714,84576,123191,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2095,64168,23433,124055,38952,63409,100178,118314,22548,41731,72682,94412,33242,114829,38085,39081,8938,129735,54992,129443,13905,48978,51131,57808,24487,121773,54516,72485,32305,115053,73607,99505,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1120,8354,20896,117315,28372,67761,71523,87320,2249,81905,53869,94984,8770,39554,29912,36211,14895,37949,32776,73955,19350,68446,106009,110520,22285,53364,32041,46854,36556,104054,118109,130247,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {12857,20421,17034,55428,26883,121875,36969,48399,13193,104733,67883,106147,28434,122634,35910,108168,18775,71995,33835,104229,42417,113357,59524,114449,31200,84173,36292,55040,47889,95797,73680,102962,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {767,83082,105735,107654,51726,71969,57344,101990,28770,124726,55717,111008,39209,84569,56636,56653,38789,116304,89858,120086,66232,112697,106722,109480,39145,117961,54140,97937,58916,83490,67082,84905,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {303,73357,54861,111688,19355,47006,28484,34729,4264,57259,33217,72209,30066,68928,40446,87706,374,41559,12921,130989,41824,92932,45515,101760,5321,115750,68463,103064,13152,106359,14858,105778,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2645,45828,28865,90080,23376,37413,106120,111985,9553,42024,13713,94031,67507,86974,79449,123480,8064,100921,43523,119869,21546,93455,42780,94570,10362,49731,90963,102719,55212,80017,117101,128609,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {10654,71153,58440,61788,22926,46313,54064,120910,11334,23089,27910,48647,26896,62738,108709,129984,11370,88278,62195,82218,45293,83603,77385,106087,14335,117197,47763,125760,17627,111039,49375,70500,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {589,61101,37342,103566,3202,65766,33737,92013,17348,27961,90749,123097,40391,89451,45075,45307,12584,82723,20977,113632,30280,50080,31252,122576,18885,118844,81080,120060,90394,98435,124647,129345,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {181,118447,85648,107104,40290,43477,78829,103753,1307,74490,61753,105194,83872,87044,101678,112649,9779,33374,20056,70895,52547,90270,119906,122479,19513,119333,80703,95400,29110,109480,70053,112667,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {368,66571,40744,122896,66195,72295,74534,93298,681,106347,111253,125766,23808,80386,24083,51939,18147,63146,78435,102242,31088,54335,88536,121717,26748,59204,66717,105013,29959,121172,53801,102693,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1357,114787,41938,121607,1802,36324,48812,51881,7583,116275,60451,68697,24533,72418,108227,122108,20905,111283,37077,108389,27612,81032,85169,128552,31067,71388,44070,74317,52533,61033,117649,126273,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1085,35633,36601,102272,19280,37213,68260,117771,13001,102304,65968,128507,37786,108249,97676,122821,4407,111528,8025,59457,5403,91127,27025,65691,6765,91113,68195,119784,44446,119223,74518,88310,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1807,118549,86671,104048,37371,91853,77469,104109,11697,64546,36936,61534,34379,40511,51945,68408,5189,51001,54767,58842,7516,77192,69896,108819,25801,110419,127320,129015,38707,121935,58747,66958,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {817,130356,42282,59676,14613,64306,110409,126251,12289,14542,59386,66425,29873,86023,60293,71482,2485,128595,56156,123075,15629,116410,51311,120954,6624,59190,45536,118980,17884,83740,56985,118402,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {68,121806,38459,92815,12007,88060,19575,46705,12252,23220,50377,52880,24308,107816,41841,122700,4268,97927,13277,37656,20892,122984,28573,115942,39428,85985,102713,104111,48623,93158,60297,78087,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1256,25498,63470,116788,16130,93538,33774,108395,26827,68051,87333,120117,29503,45491,92175,106189,5501,66629,15527,122146,41032,96899,93826,96367,14703,119202,90770,97831,17139,55792,56468,80924,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {12831,79814,14764,53632,38267,40202,88947,125347,17119,82161,43545,44898,20788,115364,31913,90981,15588,63725,57899,94698,18959,32992,78287,104242,28048,125072,50783,81887,48992,76403,90691,106354,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {136,79405,9951,73500,38189,84119,61223,72693,14284,130553,34217,128439,57252,119270,86356,128323,9867,95752,59642,80350,48643,129963,108352,128704,20281,75106,27217,106172,26001,56700,30319,41573,}},
2012-05-22 14:55:15 -07:00
};
// NOTE: These tests rely on CreateNewBlock doing its own self-validation!
BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
{
CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
CBlockTemplate *pblocktemplate;
CMutableTransaction tx,tx2;
2012-05-22 14:55:15 -07:00
CScript script;
uint256 hash;
LOCK(cs_main);
fCheckpointsEnabled = false;
2012-05-22 14:55:15 -07:00
// We can't make transactions until we have inputs
// Therefore, load 100 blocks :)
std::vector<CTransaction*>txFirst;
for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i)
{
// Simple block creation, nothing special yet:
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
pblock->nVersion = 1;
pblock->nTime = chainActive.Tip()->GetMedianTimePast()+1;
CMutableTransaction txCoinbase(pblock->vtx[0]);
txCoinbase.vin[0].scriptSig = CScript();
2016-04-07 23:38:56 -07:00
txCoinbase.vin[0].scriptSig.push_back((unsigned char) 0);
txCoinbase.vin[0].scriptSig.push_back(chainActive.Height());
txCoinbase.vout[0].scriptPubKey = CScript();
pblock->vtx[0] = CTransaction(txCoinbase);
2012-05-22 14:55:15 -07:00
if (txFirst.size() < 2)
txFirst.push_back(new CTransaction(pblock->vtx[0]));
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
2016-04-07 23:38:56 -07:00
pblock->nNonce = uint256S(blockinfo[i].nonce_hex);
pblock->nSolution = std::vector<uint32_t>(blockinfo[i].vSolutions,
blockinfo[i].vSolutions + NUM_EQUIHASH_SOLUTIONS);
/*
{
arith_uint256 try_nonce(0);
// Hash state
crypto_generichash_blake2b_state eh_state;
EhInitialiseState(96, 5, eh_state);
2016-04-07 23:38:56 -07:00
// I = the block header minus nonce and solution.
CEquihashInput I{*pblock};
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << I;
// H(I||...
crypto_generichash_blake2b_update(&eh_state, (unsigned char*)&ss[0], ss.size());
while (true) {
pblock->nNonce = ArithToUint256(try_nonce);
// H(I||V||...
crypto_generichash_blake2b_state curr_state;
curr_state = eh_state;
crypto_generichash_blake2b_update(&curr_state,
pblock->nNonce.begin(),
pblock->nNonce.size());
// (x_1, x_2, ...) = A(I, V, n, k)
std::set<std::vector<unsigned int>> solns;
EhBasicSolve(96, 5, curr_state, solns);
2016-04-07 23:38:56 -07:00
bool ret;
2016-04-07 23:38:56 -07:00
for (auto soln : solns) {
EhIsValidSolution(96, 5, curr_state, soln, ret);
assert(ret);
2016-04-07 23:38:56 -07:00
pblock->nSolution = soln;
CValidationState state;
if (ProcessNewBlock(state, NULL, pblock, true, NULL) && state.IsValid()) {
goto foundit;
}
//std::cout << state.GetRejectReason() << std::endl;
2016-04-07 23:38:56 -07:00
}
try_nonce += 1;
}
foundit:
std::cout << " {\"" << pblock->nNonce.GetHex() << "\", {";
2016-04-07 23:38:56 -07:00
BOOST_FOREACH(auto num, pblock->nSolution) {
std::cout << num << ",";
}
std::cout << "}}," << std::endl;
}
*/
2013-01-26 15:14:11 -08:00
CValidationState state;
BOOST_CHECK(ProcessNewBlock(state, NULL, pblock, true, NULL));
2016-04-07 23:38:56 -07:00
BOOST_CHECK_MESSAGE(state.IsValid(), state.GetRejectReason());
2012-05-22 14:55:15 -07:00
pblock->hashPrevBlock = pblock->GetHash();
// Need to recreate the template each round because of mining slow start
delete pblocktemplate;
2012-05-22 14:55:15 -07:00
}
// Just to make sure we can still make simple blocks
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
2013-09-18 15:01:36 -07:00
delete pblocktemplate;
2012-05-22 14:55:15 -07:00
// block sigops > limit: 1000 CHECKMULTISIG + 1
tx.vin.resize(1);
// NOTE: OP_NOP is used to force 20 SigOps for the CHECKMULTISIG
tx.vin[0].scriptSig = CScript() << OP_0 << OP_0 << OP_0 << OP_NOP << OP_CHECKMULTISIG << OP_1;
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].prevout.n = 0;
tx.vout.resize(1);
2016-05-11 05:01:24 -07:00
tx.vout[0].nValue = 800000LL;
2012-05-22 14:55:15 -07:00
for (unsigned int i = 0; i < 1001; ++i)
{
2016-05-11 05:01:24 -07:00
tx.vout[0].nValue -= 10;
2012-05-22 14:55:15 -07:00
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
2012-05-22 14:55:15 -07:00
tx.vin[0].prevout.hash = hash;
}
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
2012-05-22 14:55:15 -07:00
mempool.clear();
// block size > limit
tx.vin[0].scriptSig = CScript();
// 18 * (520char + DROP) + OP_1 = 9433 bytes
std::vector<unsigned char> vchData(520);
for (unsigned int i = 0; i < 18; ++i)
tx.vin[0].scriptSig << vchData << OP_DROP;
tx.vin[0].scriptSig << OP_1;
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
2016-05-11 05:01:24 -07:00
tx.vout[0].nValue = 800000LL;
2012-05-22 14:55:15 -07:00
for (unsigned int i = 0; i < 128; ++i)
{
2016-05-11 05:01:24 -07:00
tx.vout[0].nValue -= 1000;
2012-05-22 14:55:15 -07:00
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
2012-05-22 14:55:15 -07:00
tx.vin[0].prevout.hash = hash;
}
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
2012-05-22 14:55:15 -07:00
mempool.clear();
// orphan in mempool
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
2012-05-22 14:55:15 -07:00
mempool.clear();
// child with higher priority than parent
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vin[0].prevout.hash = txFirst[1]->GetHash();
2016-05-11 05:01:24 -07:00
tx.vout[0].nValue = 690000LL;
2012-05-22 14:55:15 -07:00
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
2012-05-22 14:55:15 -07:00
tx.vin[0].prevout.hash = hash;
tx.vin.resize(2);
tx.vin[1].scriptSig = CScript() << OP_1;
tx.vin[1].prevout.hash = txFirst[0]->GetHash();
tx.vin[1].prevout.n = 0;
2016-05-11 05:01:24 -07:00
tx.vout[0].nValue = 790000LL;
2012-05-22 14:55:15 -07:00
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
2012-05-22 14:55:15 -07:00
mempool.clear();
// coinbase in mempool
tx.vin.resize(1);
tx.vin[0].prevout.SetNull();
tx.vin[0].scriptSig = CScript() << OP_0 << OP_1;
tx.vout[0].nValue = 0;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
2012-05-22 14:55:15 -07:00
mempool.clear();
// invalid (pre-p2sh) txn in mempool
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].prevout.n = 0;
tx.vin[0].scriptSig = CScript() << OP_1;
2016-05-11 05:01:24 -07:00
tx.vout[0].nValue = 790000LL;
2012-05-22 14:55:15 -07:00
script = CScript() << OP_0;
tx.vout[0].scriptPubKey = GetScriptForDestination(CScriptID(script));
2012-05-22 14:55:15 -07:00
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
2012-05-22 14:55:15 -07:00
tx.vin[0].prevout.hash = hash;
tx.vin[0].scriptSig = CScript() << (std::vector<unsigned char>)script;
2016-05-11 05:01:24 -07:00
tx.vout[0].nValue -= 10000;
2012-05-22 14:55:15 -07:00
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
2012-05-22 14:55:15 -07:00
mempool.clear();
// double spend txn pair in mempool
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].scriptSig = CScript() << OP_1;
2016-05-11 05:01:24 -07:00
tx.vout[0].nValue = 790000LL;
2012-05-22 14:55:15 -07:00
tx.vout[0].scriptPubKey = CScript() << OP_1;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
2012-05-22 14:55:15 -07:00
tx.vout[0].scriptPubKey = CScript() << OP_2;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
2012-05-22 14:55:15 -07:00
mempool.clear();
// subsidy changing
int nHeight = chainActive.Height();
chainActive.Tip()->nHeight = 209999;
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
chainActive.Tip()->nHeight = 210000;
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
chainActive.Tip()->nHeight = nHeight;
2013-09-18 15:01:36 -07:00
// non-final txs in mempool
SetMockTime(chainActive.Tip()->GetMedianTimePast()+1);
// height locked
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vin[0].nSequence = 0;
2016-05-11 05:01:24 -07:00
tx.vout[0].nValue = 790000LL;
tx.vout[0].scriptPubKey = CScript() << OP_1;
tx.nLockTime = chainActive.Tip()->nHeight+1;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(!CheckFinalTx(tx, LOCKTIME_MEDIAN_TIME_PAST));
// time locked
tx2.vin.resize(1);
tx2.vin[0].prevout.hash = txFirst[1]->GetHash();
tx2.vin[0].prevout.n = 0;
tx2.vin[0].scriptSig = CScript() << OP_1;
tx2.vin[0].nSequence = 0;
tx2.vout.resize(1);
2016-05-11 05:01:24 -07:00
tx2.vout[0].nValue = 790000LL;
tx2.vout[0].scriptPubKey = CScript() << OP_1;
tx2.nLockTime = chainActive.Tip()->GetMedianTimePast()+1;
hash = tx2.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx2, 11, GetTime(), 111.0, 11));
BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
// Neither tx should have make it into the template.
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 1);
delete pblocktemplate;
// However if we advance height and time by one, both will.
chainActive.Tip()->nHeight++;
SetMockTime(chainActive.Tip()->GetMedianTimePast()+2);
// FIXME: we should *actually* create a new block so the following test
// works; CheckFinalTx() isn't fooled by monkey-patching nHeight.
//BOOST_CHECK(CheckFinalTx(tx));
//BOOST_CHECK(CheckFinalTx(tx2));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 2);
delete pblocktemplate;
chainActive.Tip()->nHeight--;
SetMockTime(0);
mempool.clear();
2013-09-18 15:01:36 -07:00
BOOST_FOREACH(CTransaction *tx, txFirst)
delete tx;
fCheckpointsEnabled = true;
2012-05-22 14:55:15 -07:00
}
BOOST_AUTO_TEST_SUITE_END()