Update CbTx in TestChainSetup
We need to update the CbTx's merkle root for the masternode list here as tests might add transactions into a block which cause the list to change.
This commit is contained in:
parent
9674be8f96
commit
d653ace99e
@ -24,7 +24,9 @@
|
|||||||
|
|
||||||
#include "test/testutil.h"
|
#include "test/testutil.h"
|
||||||
|
|
||||||
|
#include "evo/specialtx.h"
|
||||||
#include "evo/deterministicmns.h"
|
#include "evo/deterministicmns.h"
|
||||||
|
#include "evo/cbtx.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -146,6 +148,22 @@ CBlock TestChainSetup::CreateBlock(const std::vector<CMutableTransaction>& txns,
|
|||||||
block.vtx.resize(1);
|
block.vtx.resize(1);
|
||||||
BOOST_FOREACH(const CMutableTransaction& tx, txns)
|
BOOST_FOREACH(const CMutableTransaction& tx, txns)
|
||||||
block.vtx.push_back(MakeTransactionRef(tx));
|
block.vtx.push_back(MakeTransactionRef(tx));
|
||||||
|
|
||||||
|
// Manually update CbTx as we modified the block here
|
||||||
|
if (block.vtx[0]->nType == TRANSACTION_COINBASE) {
|
||||||
|
CCbTx cbTx;
|
||||||
|
if (!GetTxPayload(*block.vtx[0], cbTx)) {
|
||||||
|
BOOST_ASSERT(false);
|
||||||
|
}
|
||||||
|
CValidationState state;
|
||||||
|
if (!CalcCbTxMerkleRootMNList(block, chainActive.Tip(), cbTx.merkleRootMNList, state)) {
|
||||||
|
BOOST_ASSERT(false);
|
||||||
|
}
|
||||||
|
CMutableTransaction tmpTx = *block.vtx[0];
|
||||||
|
SetTxPayload(tmpTx, cbTx);
|
||||||
|
block.vtx[0] = MakeTransactionRef(tmpTx);
|
||||||
|
}
|
||||||
|
|
||||||
// IncrementExtraNonce creates a valid coinbase and merkleRoot
|
// IncrementExtraNonce creates a valid coinbase and merkleRoot
|
||||||
unsigned int extraNonce = 0;
|
unsigned int extraNonce = 0;
|
||||||
IncrementExtraNonce(&block, chainActive.Tip(), extraNonce);
|
IncrementExtraNonce(&block, chainActive.Tip(), extraNonce);
|
||||||
|
Loading…
Reference in New Issue
Block a user