mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge 4ad83a9597 into merged_master (Bitcoin PR #21592)
This commit is contained in:
commit
4fc0789649
5 changed files with 14 additions and 34 deletions
|
|
@ -537,7 +537,7 @@ public:
|
|||
m_assumeutxo_data = MapAssumeutxo{
|
||||
{
|
||||
110,
|
||||
{uint256S("0x4fa9f2be16670cb097173e6b788974fb9106c2335c074267ca5f7fc297dded32"), 110},
|
||||
{uint256S("0x09a3e443dbf48f3b95207c9ce529062d9764395232c482aa7d3a0bf274d282d9"), 110},
|
||||
},
|
||||
{
|
||||
210,
|
||||
|
|
|
|||
|
|
@ -227,43 +227,31 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::string& fedp
|
|||
}
|
||||
}
|
||||
|
||||
TestChain100Setup::TestChain100Setup(bool deterministic)
|
||||
TestChain100Setup::TestChain100Setup()
|
||||
{
|
||||
m_deterministic = deterministic;
|
||||
|
||||
if (m_deterministic) {
|
||||
SetMockTime(1598887952);
|
||||
constexpr std::array<unsigned char, 32> vchKey = {
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
|
||||
}
|
||||
};
|
||||
coinbaseKey.Set(vchKey.begin(), vchKey.end(), false);
|
||||
} else {
|
||||
coinbaseKey.MakeNewKey(true);
|
||||
}
|
||||
SetMockTime(1598887952);
|
||||
constexpr std::array<unsigned char, 32> vchKey = {
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}};
|
||||
coinbaseKey.Set(vchKey.begin(), vchKey.end(), true);
|
||||
|
||||
// Generate a 100-block chain:
|
||||
this->mineBlocks(COINBASE_MATURITY);
|
||||
|
||||
if (m_deterministic) {
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
assert(
|
||||
m_node.chainman->ActiveChain().Tip()->GetBlockHash().ToString() ==
|
||||
"49c95db1e470fed04496d801c9d8fbb78155d2c7f855232c918823d2c17d0cf6");
|
||||
"571d80a9967ae599cec0448b0b0ba1cfb606f584d8069bd7166b86854ba7a191");
|
||||
}
|
||||
}
|
||||
|
||||
void TestChain100Setup::mineBlocks(int num_blocks)
|
||||
{
|
||||
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
|
||||
for (int i = 0; i < num_blocks; i++)
|
||||
{
|
||||
for (int i = 0; i < num_blocks; i++) {
|
||||
std::vector<CMutableTransaction> noTxns;
|
||||
CBlock b = CreateAndProcessBlock(noTxns, scriptPubKey);
|
||||
if (m_deterministic) {
|
||||
SetMockTime(GetTime() + 1);
|
||||
}
|
||||
SetMockTime(GetTime() + 1);
|
||||
m_coinbase_txns.push_back(b.vtx[0]);
|
||||
}
|
||||
}
|
||||
|
|
@ -340,9 +328,7 @@ CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction(CTransactio
|
|||
TestChain100Setup::~TestChain100Setup()
|
||||
{
|
||||
gArgs.ForceSetArg("-segwitheight", "0");
|
||||
if (m_deterministic) {
|
||||
SetMockTime(0);
|
||||
}
|
||||
SetMockTime(0);
|
||||
}
|
||||
|
||||
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction& tx) const
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class CScript;
|
|||
* Testing fixture that pre-creates a 100-block REGTEST-mode block chain
|
||||
*/
|
||||
struct TestChain100Setup : public RegTestingSetup {
|
||||
TestChain100Setup(bool deterministic = false);
|
||||
TestChain100Setup();
|
||||
|
||||
/**
|
||||
* Create a new block with just given transactions, coinbase paying to
|
||||
|
|
@ -143,16 +143,10 @@ struct TestChain100Setup : public RegTestingSetup {
|
|||
|
||||
~TestChain100Setup();
|
||||
|
||||
bool m_deterministic;
|
||||
std::vector<CTransactionRef> m_coinbase_txns; // For convenience, coinbase transactions
|
||||
CKey coinbaseKey; // private/public key needed to spend coinbase transactions
|
||||
};
|
||||
|
||||
|
||||
struct TestChain100DeterministicSetup : public TestChain100Setup {
|
||||
TestChain100DeterministicSetup() : TestChain100Setup(true) { }
|
||||
};
|
||||
|
||||
/**
|
||||
* Make a test setup that has disk access to the debug.log file disabled. Can
|
||||
* be used in "hot loops", for example fuzzing or benchmarking.
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ CreateAndActivateUTXOSnapshot(NodeContext& node, const fs::path root, F malleati
|
|||
}
|
||||
|
||||
//! Test basic snapshot activation.
|
||||
BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100DeterministicSetup)
|
||||
BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
|
||||
{
|
||||
ChainstateManager& chainman = *Assert(m_node.chainman);
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(test_assumeutxo)
|
|||
}
|
||||
|
||||
const auto out110 = *ExpectedAssumeutxo(110, *params);
|
||||
BOOST_CHECK_EQUAL(out110.hash_serialized, uint256S("4fa9f2be16670cb097173e6b788974fb9106c2335c074267ca5f7fc297dded32"));
|
||||
BOOST_CHECK_EQUAL(out110.hash_serialized, uint256S("09a3e443dbf48f3b95207c9ce529062d9764395232c482aa7d3a0bf274d282d9"));
|
||||
BOOST_CHECK_EQUAL(out110.nChainTx, (unsigned int)110);
|
||||
|
||||
const auto out210 = *ExpectedAssumeutxo(210, *params);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue