Browse Source

Merge pull request #1911 from CJentzsch/ficInChainUncleTests

fix in chain uncle tests
cl-refactor
Gav Wood 10 years ago
parent
commit
8164ada83d
  1. 35
      test/libethereum/blockchain.cpp

35
test/libethereum/blockchain.cpp

@ -204,6 +204,20 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
blObj["transactions"] = writeTransactionsToJson(txList);
BlockInfo current_BlockHeader = state.info();
RLPStream uncleStream;
uncleStream.appendList(vBiUncles.size());
for (unsigned i = 0; i < vBiUncles.size(); ++i)
{
RLPStream uncleRlp;
vBiUncles[i].streamRLP(uncleRlp, WithNonce);
uncleStream.appendRaw(uncleRlp.out());
}
// update unclehash in case of invalid uncles
current_BlockHeader.sha3Uncles = sha3(uncleStream.out());
updatePoW(current_BlockHeader);
if (blObj.count("blockHeader"))
overwriteBlockHeader(current_BlockHeader, blObj);
@ -223,15 +237,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
txStream.appendRaw(txrlp.out());
}
RLPStream uncleStream;
uncleStream.appendList(vBiUncles.size());
for (unsigned i = 0; i < vBiUncles.size(); ++i)
{
RLPStream uncleRlp;
vBiUncles[i].streamRLP(uncleRlp, WithNonce);
uncleStream.appendRaw(uncleRlp.out());
}
RLPStream block2 = createFullBlockFromHeader(current_BlockHeader, txStream.out(), uncleStream.out());
blObj["rlp"] = toHex(block2.out(), 2, HexPrefix::Add);
@ -497,14 +502,20 @@ mArray importUncles(mObject const& blObj, vector<BlockInfo>& vBiUncles, vector<B
writeBlockHeaderToJson(uncleHeaderObj_pre, vBiUncles[vBiUncles.size()-1]);
aUncleList.push_back(uncleHeaderObj_pre);
vBiUncles.push_back(vBiUncles[vBiUncles.size()-1]);
uncleHeaderObj_pre = uncleHeaderObj;
continue;
}
if (uncleHeaderObj.count("sameAsBlock"))
{
writeBlockHeaderToJson(uncleHeaderObj_pre, vBiBlocks[(size_t)toInt(uncleHeaderObj["sameAsBlock"])]);
aUncleList.push_back(uncleHeaderObj_pre);
vBiUncles.push_back(vBiBlocks[(size_t)toInt(uncleHeaderObj["sameAsBlock"])]);
size_t number = (size_t)toInt(uncleHeaderObj["sameAsBlock"]);
uncleHeaderObj.erase("sameAsBlock");
BlockInfo currentUncle = vBiBlocks[number];
writeBlockHeaderToJson(uncleHeaderObj, currentUncle);
aUncleList.push_back(uncleHeaderObj);
vBiUncles.push_back(currentUncle);
uncleHeaderObj_pre = uncleHeaderObj;
continue;
}
string overwrite = "false";

Loading…
Cancel
Save