zcashd/src/test/miner_tests.cpp

418 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", {1401,77664,8779,67549,54187,127420,88890,128544,19444,43310,30156,76231,20957,45840,73064,88363,34483,92468,46413,83992,83393,92203,102774,116628,42017,69111,87818,91169,53615,63071,80521,114086}},
{"0000000000000000000000000000000000000000000000000000000000000000", {223,96141,50229,112621,17242,51644,33169,111286,3253,116579,41383,110620,12222,106913,55915,83207,17924,85931,99463,125536,29159,68343,71069,100713,25954,99583,38157,39818,37694,117193,76786,101842}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2893,60501,25732,38827,17842,68649,36188,90482,13465,40911,74233,130951,14934,55770,36516,68708,20484,75370,36426,90606,41970,108748,88026,125053,39560,43381,66786,101949,71941,105158,92403,109153}},
{"0000000000000000000000000000000000000000000000000000000000000001", {7072,110171,42973,68476,27096,36274,64817,92953,31843,86648,47843,70533,75625,117075,79224,85246,15677,68763,22124,66602,53031,59749,100518,130436,39447,60685,60321,62724,49168,63472,60411,81889}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2119,69343,2571,127513,47892,49823,111149,128489,31780,91247,63034,119916,62203,125714,74081,127950,7026,13061,23164,48547,16551,49158,80436,103905,36586,91219,80999,88847,50856,105957,67548,123312}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2517,62562,39268,77986,16518,51229,29477,100348,4012,103496,119321,127118,11875,124222,28967,102902,35754,117206,51613,90060,38508,89666,60511,129902,48301,61983,53539,73313,50379,59038,65064,120935}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1499,89885,75906,121427,28820,83778,118762,125872,2637,70940,100558,124490,53805,65597,54804,103433,1932,63169,8927,43427,20059,91140,39779,120909,41440,109780,48533,110359,49710,53152,59757,81599}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5124,84067,106291,119300,74864,99808,77304,90761,6537,111390,116714,127666,31060,101835,73576,112304,10908,60763,33199,98448,42143,117359,68636,84471,48504,76877,85655,91459,86608,108232,99786,109515}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2765,65371,115871,122413,5434,71411,16142,64973,27529,32243,75798,119132,59650,106831,99715,110521,6017,83035,112951,122924,27348,59497,92649,115583,19271,50901,67238,100396,44171,53969,110300,127107}},
{"0000000000000000000000000000000000000000000000000000000000000000", {634,87194,87124,96773,4632,98415,38617,43135,986,10635,32120,111600,38285,109477,38461,52020,3150,110686,38810,48516,42525,124757,90732,117110,11979,39159,51698,58046,17384,17609,17601,41453}},
{"0000000000000000000000000000000000000000000000000000000000000001", {9328,125327,38169,124592,22188,127776,24951,42500,10293,50581,24591,46085,27972,89402,39336,125642,15116,112752,108129,129808,34140,100307,66170,99709,27559,47474,71913,110647,37124,87943,59883,101205}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3618,33338,12373,77851,32279,61438,59508,97355,21552,69920,56789,118369,62756,93218,96779,122037,10485,72076,39348,50546,16615,86126,84229,94863,27128,32691,45242,54823,41436,129235,42390,96932}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1729,126691,51026,80884,14431,44072,50039,57073,24701,84245,27008,52582,59216,64525,61958,68930,9973,67783,62280,130342,44833,119915,105958,125859,13761,61012,59665,114986,33729,85008,92742,112942}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3235,86876,113168,124258,36679,85600,39362,65950,5862,45224,12988,78857,9937,129126,19377,116220,5040,124148,100442,111064,44835,93520,61266,100734,11457,21484,104059,129771,26225,105322,38728,117684}},
{"0000000000000000000000000000000000000000000000000000000000000000", {10629,128514,111999,117819,40812,107931,96580,128180,17365,76172,69547,129877,24024,96792,47533,82521,12644,126899,26376,103645,31988,113146,86914,90839,27390,74308,27588,128971,50989,114146,82845,105257}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4142,61580,8178,71455,12263,110643,46700,125749,26738,66738,126752,128510,30073,49404,111549,115538,11385,18169,46223,110792,78589,83336,88168,89911,14686,110363,105453,113844,16773,81262,33683,57680}},
{"0000000000000000000000000000000000000000000000000000000000000001", {727,36296,18218,78864,10723,73302,28644,54933,4934,17520,26619,86996,63769,91819,69901,110329,6828,90963,44783,60735,63540,86252,86110,121268,9590,78347,62729,109254,32510,121838,78518,97406}},
{"0000000000000000000000000000000000000000000000000000000000000000", {922,118725,42819,117938,43755,122658,52985,110233,19976,102664,54499,77750,28832,69271,63487,93236,1327,112043,5303,120350,5749,22763,56666,96619,30317,53269,48473,122112,65762,81202,114104,119841}},
{"0000000000000000000000000000000000000000000000000000000000000000", {618,88921,70573,104716,21908,85519,84868,89712,9799,101037,40695,99429,23921,68811,25213,104252,10255,72803,27884,69046,63989,95930,65826,110899,23769,128172,64142,95472,38381,130283,49871,77599}},
{"0000000000000000000000000000000000000000000000000000000000000000", {963,4006,52667,83318,57485,64950,94139,100394,34615,103257,72976,125132,53810,56211,74866,98410,5723,107494,7813,127240,27432,126386,38724,41301,10783,112863,60668,100409,34076,94857,79857,80348}},
{"0000000000000000000000000000000000000000000000000000000000000000", {469,125221,29935,114750,21289,48447,95596,113194,2041,82707,12415,72546,28839,115830,51334,57963,1496,94387,60035,113626,23748,67457,57358,127558,20642,42097,78025,116342,68768,90731,107309,125367}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1482,100298,108160,124893,5675,77065,79270,127496,5474,77573,68966,104750,57922,65547,117695,118613,6278,112300,6804,13726,14846,117765,19893,100329,10248,71522,59300,69873,32120,124048,37106,84812}},
{"0000000000000000000000000000000000000000000000000000000000000001", {539,118426,34611,94255,22559,110757,49211,69204,3515,64395,9153,95646,21532,68441,36107,91490,4883,109053,41423,75638,49573,57423,69361,108529,23104,60176,27934,54837,33150,41299,36599,67534}},
{"0000000000000000000000000000000000000000000000000000000000000002", {4213,59905,63753,88543,31023,49832,38133,77733,11023,38868,71043,107593,51898,82716,59569,105760,7519,65823,102779,113894,8409,68364,63267,112183,14580,107096,41937,129207,16937,116251,37197,123841}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1047,4308,112063,119754,4747,36825,29758,115967,11051,103035,44484,95465,42044,47466,65386,122990,6129,26481,43998,126670,10990,111219,45643,105153,50901,97909,73727,130758,93429,115834,103540,105606}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2236,83627,4728,91517,26962,68757,53411,87339,29352,69254,82596,101795,59977,76044,64752,120323,9900,126678,88930,129395,13544,40392,22655,79664,11503,48033,47550,81468,16679,25316,46082,108887}},
{"0000000000000000000000000000000000000000000000000000000000000001", {4269,99605,19029,80277,47680,92178,52768,88274,26860,89779,57794,112987,52459,105702,92523,103112,10543,128113,33100,71059,62477,98648,69323,92462,16386,27072,38179,51259,17217,94540,58332,77411}},
{"0000000000000000000000000000000000000000000000000000000000000001", {322,18689,2296,60113,44430,90366,55973,74417,1159,128875,52325,73911,14559,87927,80925,111138,12110,81040,74522,108324,50190,127045,75624,93236,26519,76150,61887,117783,53684,84361,73598,124623}},
{"0000000000000000000000000000000000000000000000000000000000000001", {924,11762,11746,39628,17394,117062,34438,45467,31675,112615,95416,114622,51728,60820,68267,75658,15553,49215,49330,99886,38834,98922,54746,98485,22594,22623,69067,95058,35229,113174,48267,91585}},
{"0000000000000000000000000000000000000000000000000000000000000000", {8436,33074,53929,115803,13159,15284,21243,40358,9844,30176,16559,122962,54466,99751,65241,120043,8635,67023,8896,17511,8985,51040,14197,126725,13938,108094,92981,115055,34363,108312,41861,51048}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1266,25725,36361,79899,47778,58469,57227,92903,1333,44782,9181,26208,19751,24466,61905,92988,4866,55692,49176,123300,32487,106501,60985,75933,20430,22063,67825,94697,45894,102624,59118,101024}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1639,6028,85105,113363,10725,64535,120367,128191,23245,31334,86823,128026,34245,120798,47910,94651,17692,86293,46774,123907,61235,104492,86423,92533,28131,61720,61096,117585,60325,78007,105613,109896}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1046,49732,10297,19813,21586,101099,70206,80456,4469,10362,37312,40259,26764,28163,44026,55274,3745,69290,17523,107604,18536,60996,90790,103392,24734,41242,74440,100454,94353,111991,115303,116341}},
{"0000000000000000000000000000000000000000000000000000000000000000", {7880,12677,63923,103634,26895,101233,33305,43830,25596,51011,54243,108178,36627,53468,70945,99551,9194,61370,85046,103706,9432,76475,24895,77227,13546,26083,39981,59265,20336,62718,26154,64151}},
{"0000000000000000000000000000000000000000000000000000000000000001", {5728,7707,21985,120812,51249,96909,75566,99294,47014,93928,58150,122614,48080,90742,73151,120436,17103,113845,22495,28884,60879,94344,66822,121215,42577,62362,63741,108964,88576,90054,91429,92651}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2830,120472,6411,97892,48039,109813,64096,104086,14248,47506,58610,72625,30699,126789,117151,125831,10783,81130,88353,90808,31422,68798,52018,70733,23736,50951,35904,51100,69988,91783,74218,106927}},
{"0000000000000000000000000000000000000000000000000000000000000002", {772,4758,15216,61604,6446,23185,56297,124977,45067,113761,67547,83349,85019,115499,92138,121106,3282,109998,32435,61067,10900,81045,38098,92742,5579,15278,55790,116875,44532,103202,58066,104209}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3344,29651,5442,121360,17146,31308,97140,114652,9630,112262,46914,86172,24730,57098,38370,82670,16091,42879,63798,125038,54750,81951,71783,122421,28650,62940,44330,124470,31789,42550,32291,90087}},
{"0000000000000000000000000000000000000000000000000000000000000002", {4194,48011,12930,105744,47377,66084,105566,117350,27229,37923,65873,88630,71807,89476,117479,130162,8193,41448,18507,130011,15343,95520,76592,128208,18204,83814,34009,72946,35804,63028,96806,100953}},
{"0000000000000000000000000000000000000000000000000000000000000001", {96,65359,28711,56418,23247,38575,65035,128998,4938,77284,13511,56020,34366,66971,89813,128180,889,37109,25330,36508,2865,18598,103826,108961,10617,51458,79535,88625,38091,83173,40983,66824}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3121,117596,62313,91542,62479,113269,87070,103984,4445,120333,45905,113747,31016,79625,56117,94192,22386,43248,95292,116049,64206,126106,83302,90233,36336,125556,46450,54431,63603,89220,66876,116958}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1512,41624,7215,76131,36588,96199,47532,81741,12311,29235,71756,118012,76555,108758,109596,113964,5902,114097,25790,69270,10331,89503,27570,60183,10451,67442,45994,86255,18384,63764,65692,103348}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1315,98752,8368,123430,2363,63618,111470,115574,21151,84772,89714,96603,28644,83826,42134,63237,8339,81434,93913,116936,40342,89470,80176,91424,25025,27200,45064,90347,82806,125259,93719,125158}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1554,106936,13401,16947,13041,27638,69800,129628,10441,21712,24558,117102,10991,38998,47515,122868,18516,116811,102733,114300,64243,127423,75446,101533,19806,31566,83687,107745,25013,61911,65479,106493}},
{"0000000000000000000000000000000000000000000000000000000000000000", {938,70460,47319,51372,51904,67987,80916,125885,18984,126410,26739,35038,33086,55544,53210,55171,1612,53427,28196,35308,30024,42708,65471,127518,53957,110616,60695,127478,67203,105022,83293,125976}},
{"0000000000000000000000000000000000000000000000000000000000000001", {6,22935,20227,126244,20080,54580,65195,101500,11977,81378,41315,89197,12233,75739,21495,35475,13774,73077,15870,120222,34879,35961,39988,90387,34696,116271,63510,107268,41169,92611,78796,111897}},
{"0000000000000000000000000000000000000000000000000000000000000000", {530,22725,46181,110183,5803,20758,63010,106472,2136,104581,95234,130792,38383,49068,45303,80882,20462,34088,47569,60234,35083,81104,42593,114466,28830,95105,99496,111040,30507,107076,88694,116395}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2829,90206,17314,126311,33789,110535,54516,83485,10627,12632,77433,94917,41390,89468,51269,130409,17155,61723,70010,79415,37407,41360,53555,107082,17720,78064,25472,130087,48651,119142,117035,122726}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2314,46604,54197,105620,6842,15980,80474,108177,9894,80104,51403,85045,19414,125571,22747,113233,39032,116848,60700,69642,69619,119169,83732,115257,48835,119020,66534,74811,49231,61692,53653,124453}},
{"0000000000000000000000000000000000000000000000000000000000000000", {770,50713,21492,25585,5221,76497,54249,55192,4460,130825,44118,89690,20506,106694,93824,106609,1309,80221,8200,75453,81526,125274,88739,97902,11461,56795,55677,110813,27317,72368,60312,102832}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3270,6720,59704,92412,21737,100860,106145,130122,9202,124936,74976,90044,79707,110817,102395,124907,30374,79605,99370,100749,39984,70645,50999,75605,32945,57730,40749,94573,37098,57492,59737,68475}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2973,44010,12606,126529,23445,115277,96429,111545,16386,72503,26946,114426,23436,105566,98452,106535,18135,93592,75881,95443,55923,114602,56112,96562,52600,114154,72556,87170,75286,89823,105401,122430}},
{"0000000000000000000000000000000000000000000000000000000000000000", {138,9238,9253,74630,19650,66922,90319,92875,13457,21980,65747,89362,24612,113887,89281,113582,19184,100727,46600,124429,28593,89865,50539,111231,31817,39613,44092,84273,37263,65890,39555,119591}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3819,100293,57106,63633,27584,39171,93785,127362,9354,39151,110541,117884,39681,130469,47240,119149,10994,104394,117965,126865,24904,40527,57122,95002,13687,48162,65146,128056,30525,87220,62310,127525}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1800,82062,30722,108546,19718,85497,50118,50249,54183,72357,82082,88903,54377,125908,94744,130396,19688,64178,69195,72068,65822,88725,94118,94763,40888,58091,113654,122113,55535,75268,69100,97488}},
{"0000000000000000000000000000000000000000000000000000000000000002", {8523,128516,43668,77964,62715,85212,88226,130462,34743,108788,49138,59176,57437,88675,80315,123790,12113,44690,30925,123031,44360,79210,76403,85526,17753,97586,51866,64871,27667,104380,44054,63082}},
{"0000000000000000000000000000000000000000000000000000000000000001", {852,77169,44928,60907,78660,120059,106896,128375,6389,122341,24273,75578,12273,122030,41575,119728,11353,109222,61187,102370,12506,104876,82123,130152,38468,47254,42182,82660,57421,127973,92898,119174}},
{"0000000000000000000000000000000000000000000000000000000000000002", {10914,101333,35793,58327,84318,103093,91996,113221,11411,48590,16593,105836,47843,106640,100448,120026,11914,24116,57630,80225,69588,82453,97456,113880,12283,41073,50333,62097,13626,56933,62670,81997}},
{"0000000000000000000000000000000000000000000000000000000000000002", {297,77875,108139,124745,8120,78625,17123,112099,20366,91179,60549,79751,49182,65724,105118,128038,1855,80228,3943,15045,5324,68384,33976,129465,5633,41022,45854,75767,13423,122294,76125,104961}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1810,33477,8149,27588,41386,111188,66015,94116,4836,72868,25999,52967,54430,81833,73147,114411,21164,113423,75049,101320,30540,46724,113294,119772,29166,127857,58785,124453,91891,94016,103126,130565}},
{"0000000000000000000000000000000000000000000000000000000000000001", {17947,88182,37645,95684,21017,47568,26558,64136,43725,115505,82195,122033,48151,98661,115974,122373,30570,115322,68478,114416,61833,86956,92486,93082,34309,46995,48331,54787,56691,62349,61874,72168}},
{"0000000000000000000000000000000000000000000000000000000000000003", {3016,23813,27139,122431,41261,88373,45901,79804,9019,99386,22306,120037,18428,69388,30215,48140,27150,113280,77615,90169,43670,125905,102728,125783,37071,113518,60902,68527,50817,77416,51201,115284}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2132,52560,24972,90735,13918,128309,49142,77905,3039,81345,20841,128869,18905,57333,56439,127829,5423,14282,120358,128788,25126,113677,29220,46667,10360,13816,84234,126984,48359,103655,65613,101924}},
{"0000000000000000000000000000000000000000000000000000000000000000", {150,114949,38423,76376,67209,125659,84149,87996,21005,41415,52189,79387,57410,97200,109254,109736,17974,65369,66507,117277,25314,125368,40769,112883,20968,106026,63478,81142,45758,121247,127470,129191}},
{"0000000000000000000000000000000000000000000000000000000000000000", {301,41932,56365,112719,44754,103053,48018,81854,583,41662,102324,128115,50032,127207,106214,118068,794,129205,20075,21553,35307,68307,47980,62377,30931,113184,35293,93806,42739,128823,85042,85794}},
{"0000000000000000000000000000000000000000000000000000000000000004", {3869,115391,11548,38729,28960,88888,69831,85332,29843,127168,59151,118145,70507,106865,80998,127304,14169,58297,45944,76819,66857,80779,77831,129166,24908,41196,26324,122605,46046,61363,68161,79543}},
{"0000000000000000000000000000000000000000000000000000000000000001", {718,86477,58221,85888,10349,100931,116890,127383,10823,24921,30142,50795,19222,103112,90791,120701,23559,67737,96692,118079,32662,42021,71444,122709,24300,43612,119560,124049,41132,106941,55330,93869}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1358,52492,2862,39550,35501,96337,43056,79383,57687,60471,77475,119487,75794,111886,76270,109707,8678,26872,30012,121195,9358,91985,10018,97965,20282,39082,48963,94740,24810,42877,38984,105313}},
{"0000000000000000000000000000000000000000000000000000000000000000", {72,49502,38316,100164,13843,59501,15231,37084,28645,105214,47445,57878,31002,108179,52981,128023,12419,104529,58576,73689,37681,45819,58505,92284,13711,115540,20123,67989,69353,102261,113176,124404}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2089,34462,109901,124607,2877,119478,72134,80563,6880,37939,28499,31226,20612,53033,32786,47620,13466,72462,37797,98060,16631,89403,80383,89068,17399,36042,24371,122623,29578,53876,52287,107700}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1584,122460,9658,45743,42507,60755,109065,109286,13925,76004,79957,124948,37599,102986,92572,130284,19465,36215,84675,128630,27805,29228,74919,95120,31832,84453,93494,107094,33120,42330,77880,123038}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1484,101529,9606,40140,14472,73797,33694,113628,2869,91693,34129,112923,51227,89490,88462,128709,11260,104942,58149,120303,84214,114720,86491,128296,30021,72120,34025,43123,65435,89039,109558,117961}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3281,101730,62291,123844,9101,15670,54038,123017,23598,68925,64733,111652,23967,45673,26565,110901,6107,12216,18059,58305,44251,68041,88452,119600,8356,28625,42446,123312,30577,47559,50420,88894}},
{"0000000000000000000000000000000000000000000000000000000000000000", {6086,129627,111307,114668,16040,83737,49248,104284,23653,84849,92063,103834,53412,75152,76915,112808,7452,72871,71043,117819,46897,86622,88375,99042,9117,21777,68161,76342,13774,27465,28787,36675}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1904,105640,62928,105436,15813,58397,44169,102435,4466,56847,11795,42494,28571,47266,62100,75573,9432,15211,52996,106380,27640,118491,85540,123671,12582,61908,53186,109858,38134,116236,44982,72749}},
{"0000000000000000000000000000000000000000000000000000000000000001", {475,129568,20582,25646,41301,74098,53464,110053,4056,5690,95335,103368,9823,13298,93454,115686,9010,54155,47514,69671,25977,53559,73996,104589,23215,102833,63984,74494,23914,121817,75519,97382}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5582,130435,70381,101088,12803,57220,24969,127104,27195,56072,38198,118696,59330,123307,68264,68457,15666,106661,23879,129010,32626,118788,95362,116614,38289,121089,39180,75306,43317,120222,46122,101202}},
{"0000000000000000000000000000000000000000000000000000000000000002", {2077,24500,52101,129234,32442,110573,65608,90782,5163,125621,68363,113175,32990,82574,114257,128043,22965,104870,25705,74583,58178,112762,68818,72152,24870,37944,91639,103909,53552,80421,99011,114520}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3874,47617,38599,59875,7590,94227,95005,130756,10685,44619,58437,86983,17927,58173,34146,87332,17179,26475,73535,78770,73820,82397,112735,121703,31866,98708,69589,102454,46596,80890,105990,114118}},
{"0000000000000000000000000000000000000000000000000000000000000004", {309,58828,71209,113710,76621,84939,85702,117613,15623,40442,20133,75964,48017,102517,79243,118886,24611,56001,49763,104651,44050,57855,50615,80203,26158,42586,106524,123456,56850,72341,72172,92819}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4398,33146,22020,35989,6755,113183,80325,125518,12477,93302,61225,114168,59371,122728,90864,105013,18431,67029,57797,92272,18803,32813,45552,47857,39598,71394,71513,97281,79636,105057,82946,97551}},
{"0000000000000000000000000000000000000000000000000000000000000000", {784,91101,94055,116523,30543,51378,78455,117183,13214,115448,82600,109861,55424,74739,70176,113504,14553,18512,31061,40439,28013,91472,88848,89479,39576,76555,68856,98662,79036,99729,97458,107304}},
{"0000000000000000000000000000000000000000000000000000000000000000", {8208,111682,112780,123042,70333,81471,110486,120714,10160,14305,37676,111797,20759,115432,57388,77154,8917,89376,8923,91168,21660,57598,104133,125360,9274,29068,39324,114459,11712,96945,15601,21048}},
{"0000000000000000000000000000000000000000000000000000000000000001", {489,98999,68420,85729,17920,71273,88272,120263,34447,115295,83761,91669,75425,78212,86146,90593,4790,21206,5787,130021,9425,92461,43352,89158,8812,66687,19943,55619,9530,26944,61429,77737}},
{"0000000000000000000000000000000000000000000000000000000000000000", {243,85585,43211,71127,37090,92605,78277,101994,29885,113733,67767,93736,45400,76361,54871,74363,6328,78470,75445,119081,67361,67872,109357,126050,32116,95295,64757,81311,32385,129194,44441,124867}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5944,127067,64086,90739,50783,59907,117329,124737,11441,38017,100013,122393,35278,56199,55872,88447,7254,53175,23685,25774,32286,113584,38046,43818,12033,30851,42075,72208,20704,101753,74304,107017}},
{"0000000000000000000000000000000000000000000000000000000000000002", {770,50145,11977,120853,14261,78948,100569,120108,21875,28285,108522,126037,58358,118294,76761,123973,18743,77066,96472,106472,32119,115692,58201,63790,28511,111477,31952,107016,43607,43849,97055,108046}},
{"0000000000000000000000000000000000000000000000000000000000000000", {10738,93487,40999,75106,26257,121936,28029,111129,47712,76209,85029,104114,61485,107246,61845,102341,21225,65626,67350,89851,57134,67077,78164,100867,40331,83487,69759,86634,73069,98298,79533,122310}},
{"0000000000000000000000000000000000000000000000000000000000000000", {12329,75236,100083,125936,29686,51420,41657,119484,26079,58372,48530,124179,41377,51220,66111,113187,28040,129333,45672,46386,35493,119370,76430,83833,50493,130481,57526,110732,70713,73329,106683,118573}},
{"0000000000000000000000000000000000000000000000000000000000000006", {863,48347,47811,111777,30547,41135,49484,111073,8233,92891,44990,100864,37068,52882,79563,116816,21053,108493,56234,129704,32817,123373,88448,111977,31663,107835,55000,85215,39463,125097,75478,129682}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2624,124467,26684,50669,11204,108080,15233,106999,62334,90370,73820,106402,80610,107881,92645,127933,15543,52309,27888,113612,73224,89800,75117,86646,52837,76037,63749,112948,101360,120517,127856,131058}},
{"0000000000000000000000000000000000000000000000000000000000000000", {451,107672,8949,18718,17147,91499,58167,61712,8640,51777,79750,100067,10005,36798,19233,92115,6262,114210,20361,92289,72769,80272,72796,123703,7453,49312,45449,66124,100915,113758,112504,124461}},
{"0000000000000000000000000000000000000000000000000000000000000000", {738,81797,33556,68757,54672,109503,56098,127746,50307,81542,63050,90820,56901,69975,70933,104979,1047,123453,44566,117185,13326,23334,20908,102884,53092,107891,61835,76387,58614,116174,88458,110855}},
{"0000000000000000000000000000000000000000000000000000000000000001", {745,75851,6276,73320,11990,64748,43200,67392,39196,124739,91058,100521,43527,113883,44976,130668,7218,35894,97240,118184,46795,94357,73784,75266,11268,54659,69032,100328,35669,124419,36821,69718}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3250,10278,32835,108120,18838,46360,40923,123105,9068,119788,50046,124496,16604,57571,20148,43116,9818,41224,49312,127849,15123,25007,29744,55175,19260,109616,70021,118715,52098,110926,102594,104659}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2683,67576,27205,109409,22061,76378,42803,128212,63367,73487,92625,94542,75422,131028,86344,89879,5438,127819,37692,76107,17438,73745,54403,120333,32195,115178,46265,89445,38475,62614,71378,99705}},
{"0000000000000000000000000000000000000000000000000000000000000000", {6136,125615,16909,39395,34957,35105,82870,89612,23318,71315,33953,70042,96197,110193,110133,114861,14988,75439,26628,110648,26911,129891,104579,124370,26420,35587,33453,95840,31762,94820,32620,83410}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2440,53218,39799,109449,12614,110580,15053,122194,41991,105117,47545,60425,61134,74190,88136,95703,21728,59782,64251,101513,40894,74585,96934,99800,34334,93877,83812,129678,48551,122116,65187,72270}},
{"0000000000000000000000000000000000000000000000000000000000000001", {6629,29736,21934,63635,34924,49651,91790,115354,18785,130575,68939,85953,67413,69414,84932,85017,7081,20767,68635,119498,26639,48763,37717,120533,7943,126680,67724,116053,41230,128406,74666,106567}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2532,65374,36024,121823,52340,122507,64653,71985,3069,15192,53922,117201,4494,116477,94071,122008,11254,26280,18067,93813,28039,129867,42433,71981,23774,58761,33678,129561,41602,129611,59361,109021}},
{"0000000000000000000000000000000000000000000000000000000000000000", {14014,35796,87590,125531,30955,108163,46082,51210,27235,38604,75693,101362,56997,100929,84140,130559,17828,44849,25098,81329,29802,77164,82629,99243,18768,58134,124810,128627,25280,89934,42563,60581}},
{"0000000000000000000000000000000000000000000000000000000000000000", {7754,89566,56359,110788,9780,102277,12466,85630,9391,39419,91792,102547,73018,88176,84647,105449,13683,87897,26514,58130,38395,117181,45412,116178,29693,91069,97997,127886,50000,50371,53115,95065}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1811,33544,7412,128225,47835,82152,67676,75251,4409,65926,10912,81567,16386,99367,55681,72453,27310,86743,27449,96830,54361,62357,84781,124068,30485,85623,61336,76293,68910,112850,80485,84969}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4658,62687,65104,105065,77301,116748,80658,110543,8362,8954,64297,105438,27373,58280,44448,70014,8836,105182,45505,72944,10648,39117,98149,100026,32968,93103,45006,68736,50894,85261,54457,71848}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3625,24741,31301,121516,16496,89982,39250,46152,11548,94322,47502,68676,14249,26945,57286,77302,10180,18395,98368,109006,38855,50960,66754,120896,13245,32177,20369,40635,31333,106939,69283,124322}},
{"0000000000000000000000000000000000000000000000000000000000000001", {12586,120205,60253,109639,76111,123199,88870,113612,35010,42912,39377,53207,77623,99534,93085,114331,32016,74771,33991,91026,32088,71389,42626,58085,41794,101895,56894,93874,75126,101628,108599,110522}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2119,60522,98750,118388,4961,35358,35484,56011,15178,123261,20051,103277,42486,47336,43875,44086,8140,116571,31742,79479,9642,107161,18173,82251,21412,115502,67191,109434,34601,43070,53913,88507}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5637,69158,76153,102706,31824,38642,32826,91449,9684,66977,36269,104105,22044,39029,59211,62844,6376,67740,26190,75028,37767,98166,55541,81351,36411,44446,80909,82693,49062,67652,76184,96737}},
{"0000000000000000000000000000000000000000000000000000000000000001", {322,39370,6729,21335,8469,50827,77985,123149,28332,109996,53560,124098,40546,130225,42489,93599,411,4824,30157,38561,46245,112537,49381,84448,12125,49559,15251,31561,44028,127754,79407,98721}},
{"0000000000000000000000000000000000000000000000000000000000000002", {5865,90924,24359,60039,66294,103210,70888,72533,71111,114155,109414,116279,72228,106752,127967,130298,6279,46969,60616,120318,107674,115613,116427,127133,22652,47624,56727,65735,31017,45711,42459,82123}}
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
// Simple block creation, nothing special yet:
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
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)
{
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);
Equihash eh {96, 5};
// Hash state
crypto_generichash_blake2b_state eh_state;
eh.InitialiseState(eh_state);
// 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 = eh.BasicSolve(curr_state);
for (auto soln : solns) {
assert(eh.IsValidSolution(curr_state, soln));
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() << "\", {";
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();
}
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);
tx.vout[0].nValue = 4000000000LL;
2012-05-22 14:55:15 -07:00
for (unsigned int i = 0; i < 1001; ++i)
{
tx.vout[0].nValue -= 1000000;
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();
tx.vout[0].nValue = 4000000000LL;
2012-05-22 14:55:15 -07:00
for (unsigned int i = 0; i < 128; ++i)
{
tx.vout[0].nValue -= 10000000;
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();
tx.vout[0].nValue = 3900000000LL;
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;
tx.vout[0].nValue = 4900000000LL;
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;
tx.vout[0].nValue = 3900000000LL;
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;
tx.vout[0].nValue -= 1000000;
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;
tx.vout[0].nValue = 3900000000LL;
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;
tx.vout[0].nValue = 3900000000LL;
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);
tx2.vout[0].nValue = 3900000000LL;
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()