Validation of pegin inputs

This commit is contained in:
Steven Roose 2018-12-12 11:44:04 +01:00
parent f4adb464e8
commit 5cbb014fe4
15 changed files with 369 additions and 79 deletions

View file

@ -46,7 +46,7 @@ std::ostream& operator<<(std::ostream& os, const uint256& num)
return os;
}
BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::string& fedpegscript)
: m_path_root(fs::temp_directory_path() / "test_bitcoin" / strprintf("%lu_%i", (unsigned long)GetTime(), (int)(InsecureRandRange(1 << 30))))
{
SHA256AutoDetect();
@ -57,6 +57,10 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
InitSignatureCache();
InitScriptExecutionCache();
fCheckBlockIndex = true;
// Hack to allow testing of fedpeg args
if (!fedpegscript.empty()) {
gArgs.SoftSetArg("-fedpegscript", fedpegscript);
}
// CreateAndProcessBlock() does not support building SegWit blocks, so don't activate in these tests.
// TODO: fix the code to support SegWit blocks.
gArgs.ForceSetArg("-vbparams", strprintf("segwit:0:%d", (int64_t)Consensus::BIP9Deployment::NO_TIMEOUT));
@ -78,7 +82,7 @@ fs::path BasicTestingSetup::SetDataDir(const std::string& name)
return ret;
}
TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
TestingSetup::TestingSetup(const std::string& chainName, const std::string& fedpegscript) : BasicTestingSetup(chainName, fedpegscript)
{
SetDataDir("tempdir");
const CChainParams& chainparams = Params();
@ -184,7 +188,7 @@ CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CMutableTransaction &tx) {
CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CTransactionRef& tx)
{
return CTxMemPoolEntry(tx, nFee, nTime, nHeight,
spendsCoinbase, sigOpCost, lp);
spendsCoinbase, sigOpCost, lp, setPeginsSpent);
}
/**