Browse Source

Fixed most miner tests.

Still three failures.
cn
Jianping Wu 6 years ago
parent
commit
c436fe9b65
  1. 68
      src/test/miner_tests.cpp

68
src/test/miner_tests.cpp

@ -52,34 +52,34 @@ struct {
unsigned char extranonce; unsigned char extranonce;
unsigned int nonce; unsigned int nonce;
} blockinfo[] = { } blockinfo[] = {
{4, 0xa4ad9f65}, {2, 0x15cf2b27}, {1, 0x037620ac}, {1, 0x700d9c54}, {4, 0x00002cf8}, {2, 0x000007a6}, {1, 0x000007a6}, {1, 0x00000682},
{2, 0xce79f74f}, {2, 0x52d9c194}, {1, 0x77bc3efc}, {2, 0xbb62c5e8}, {2, 0x00000de2}, {2, 0x00000797}, {1, 0x00003029}, {2, 0x00000069},
{2, 0x83ff997a}, {1, 0x48b984ee}, {1, 0xef925da0}, {2, 0x680d2979}, {2, 0x00000f05}, {1, 0x00001288}, {1, 0x00000195}, {2, 0x0000254f},
{2, 0x08953af7}, {1, 0x087dd553}, {2, 0x210e2818}, {2, 0xdfffcdef}, {2, 0x000000de}, {1, 0x00000169}, {2, 0x000008de}, {2, 0x00000040},
{1, 0xeea1b209}, {2, 0xba4a8943}, {1, 0xa7333e77}, {1, 0x344f3e2a}, {1, 0x00000792}, {2, 0x00000380}, {1, 0x00000352}, {1, 0x0000089a},
{3, 0xd651f08e}, {2, 0xeca3957f}, {2, 0xca35aa49}, {1, 0x6bb2065d}, {3, 0x00000cb8}, {2, 0x000015c4}, {2, 0x00000267}, {1, 0x00004ab9},
{2, 0x0170ee44}, {1, 0x6e12f4aa}, {2, 0x43f4f4db}, {2, 0x279c1c44}, {2, 0x00001857}, {1, 0x0000123c}, {2, 0x000009c2}, {2, 0x00002da3},
{2, 0xb5a50f10}, {2, 0xb3902841}, {2, 0xd198647e}, {2, 0x6bc40d88}, {2, 0x000002c4}, {2, 0x00001935}, {2, 0x00000355}, {2, 0x00003084},
{1, 0x633a9a1c}, {2, 0x9a722ed8}, {2, 0x55580d10}, {1, 0xd65022a1}, {1, 0x00000def}, {2, 0x00000b90}, {2, 0x00000362}, {1, 0x00001082},
{2, 0xa12ffcc8}, {1, 0x75a6a9c7}, {2, 0xfb7c80b7}, {1, 0xe8403e6c}, {2, 0x00000237}, {1, 0x000001c5}, {2, 0x00000211}, {1, 0x0000016d},
{1, 0xe34017a0}, {3, 0x659e177b}, {2, 0xba5c40bf}, {5, 0x022f11ef}, {1, 0x000014aa}, {3, 0x00000660}, {2, 0x00001e36}, {5, 0x0000051c},
{1, 0xa9ab516a}, {5, 0xd0999ed4}, {1, 0x37277cb3}, {1, 0x830f735f}, {1, 0x000002dd}, {5, 0x00000006}, {1, 0x000009bd}, {1, 0x0000014f},
{1, 0xc6e3d947}, {2, 0x824a0c1b}, {1, 0x99962416}, {1, 0x75336f63}, {1, 0x00001ecd}, {2, 0x000019ac}, {1, 0x000048c7}, {1, 0x00000a9a},
{1, 0xaacf0fea}, {1, 0xd6531aec}, {5, 0x7afcf541}, {5, 0x9d6fac0d}, {1, 0x00001e22}, {1, 0x00000975}, {5, 0x00001155}, {5, 0x00001637},
{1, 0x4cf5c4df}, {1, 0xabe0f2a0}, {6, 0x4a3dac18}, {2, 0xf265febe}, {1, 0x00001048}, {1, 0x00000433}, {6, 0x00001cbb}, {2, 0x0000044b},
{2, 0x1bc9f23f}, {1, 0xad49ab71}, {1, 0x9f2d8923}, {1, 0x15acb65d}, {2, 0x00000962}, {1, 0x000001bb}, {1, 0x00001095}, {1, 0x000022ff},
{2, 0xd1cecb52}, {2, 0xf856808b}, {1, 0x0fa96e29}, {1, 0xe063ecbc}, {2, 0x00001200}, {2, 0x000032c3}, {1, 0x00000666}, {1, 0x0000040f},
{1, 0x78d926c6}, {5, 0x3e38ad35}, {5, 0x73901915}, {1, 0x63424be0}, {1, 0x00001207}, {5, 0x00000353}, {5, 0x00001f8d}, {1, 0x000001cd},
{1, 0x6d6b0a1d}, {2, 0x888ba681}, {2, 0xe96b0714}, {1, 0xb7fcaa55}, {1, 0x000002f9}, {2, 0x00003758}, {2, 0x00002452}, {1, 0x000002af},
{2, 0x19c106eb}, {1, 0x5aa13484}, {2, 0x5bf4c2f3}, {2, 0x94d401dd}, {2, 0x0000228a}, {1, 0x00001375}, {2, 0x000004e1}, {2, 0x00000384},
{1, 0xa9bc23d9}, {1, 0x3a69c375}, {1, 0x56ed2006}, {5, 0x85ba6dbd}, {1, 0x000008a5}, {1, 0x00000aaa}, {1, 0x00001375}, {5, 0x0000110e},
{1, 0xfd9b2000}, {1, 0x2b2be19a}, {1, 0xba724468}, {1, 0x717eb6e5}, {1, 0x00001857}, {1, 0x00000330}, {1, 0x0000008f}, {1, 0x00000a92},
{1, 0x70de86d9}, {1, 0x74e23a42}, {1, 0x49e92832}, {2, 0x6926dbb9}, {1, 0x000000be}, {1, 0x000011a6}, {1, 0x000008b4}, {2, 0x00001247},
{0, 0x64452497}, {1, 0x54306d6f}, {2, 0x97ebf052}, {2, 0x55198b70}, {0, 0x00000486}, {1, 0x0000005c}, {2, 0x0000115c}, {2, 0x000001b3},
{2, 0x03fe61f0}, {1, 0x98f9e67f}, {1, 0xc0842a09}, {1, 0xdfed39c5}, {2, 0x000014df}, {1, 0x0000170b}, {1, 0x000000ae}, {1, 0x0000015e},
{1, 0x3144223e}, {1, 0xb3d12f84}, {1, 0x7366ceb7}, {5, 0x6240691b}, {1, 0x0000059f}, {1, 0x00001d6e}, {1, 0x00000050}, {5, 0x000000d5},
{2, 0xd3529b57}, {1, 0xf4cae3b1}, {1, 0x5b1df222}, {1, 0xa16a5c70}, {2, 0x000007cc}, {1, 0x000002db}, {1, 0x00000313}, {1, 0x00000961},
{2, 0xbbccedc6}, {2, 0xfe38d0ef}, {2, 0x00000cb3}, {2, 0x00003404},
}; };
CBlockIndex CreateBlockIndex(int nHeight) CBlockIndex CreateBlockIndex(int nHeight)
@ -220,6 +220,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
// Simple block creation, nothing special yet: // Simple block creation, nothing special yet:
BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey)); BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
uint32_t nStartTime = chainActive.Tip()->GetMedianTimePast()+1;
// We can't make transactions until we have inputs // We can't make transactions until we have inputs
// Therefore, load 100 blocks :) // Therefore, load 100 blocks :)
@ -230,14 +231,19 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
CBlock *pblock = &pblocktemplate->block; // pointer for convenience CBlock *pblock = &pblocktemplate->block; // pointer for convenience
{ {
LOCK(cs_main); LOCK(cs_main);
pblock->nVersion = 1; CBlockIndex* pindexPrev = chainActive.Tip();
pblock->nTime = chainActive.Tip()->GetMedianTimePast()+1; pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus());
pblock->nVersion = 0x20000000;
// Average block time 2 minutes, but use 4 minutes to make it faster
// to find the nonce for test cases (DigiShield adjusts the difficulty)
nStartTime += 240;
pblock->nTime = nStartTime;
CMutableTransaction txCoinbase(*pblock->vtx[0]); CMutableTransaction txCoinbase(*pblock->vtx[0]);
txCoinbase.nVersion = 1; txCoinbase.nVersion = 1;
txCoinbase.vin[0].scriptSig = CScript(); txCoinbase.vin[0].scriptSig = CScript();
txCoinbase.vin[0].scriptSig.push_back(blockinfo[i].extranonce); txCoinbase.vin[0].scriptSig.push_back(blockinfo[i].extranonce);
txCoinbase.vin[0].scriptSig.push_back(chainActive.Height()); txCoinbase.vin[0].scriptSig.push_back(chainActive.Height());
txCoinbase.vout.resize(1); // Ignore the (optional) segwit commitment added by CreateNewBlock (as the hardcoded nonces don't account for this) //txCoinbase.vout.resize(1); // Ignore the (optional) segwit commitment added by CreateNewBlock (as the hardcoded nonces don't account for this)
txCoinbase.vout[0].scriptPubKey = CScript(); txCoinbase.vout[0].scriptPubKey = CScript();
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase)); pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
if (txFirst.size() == 0) if (txFirst.size() == 0)

Loading…
Cancel
Save