Skip to content

Commit

Permalink
[Tests] move pwalletMain to wallet test fixture + use smart pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed May 17, 2021
1 parent d6cf608 commit d10acd5
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 101 deletions.
53 changes: 40 additions & 13 deletions src/test/librust/sapling_rpc_wallet_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include <univalue.h>

extern CWallet* pwalletMain;

extern UniValue CallRPC(std::string args); // Implemented in rpc_tests.cpp

Expand Down Expand Up @@ -57,6 +56,8 @@ BOOST_FIXTURE_TEST_SUITE(sapling_rpc_wallet_tests, WalletTestingSetup)
BOOST_AUTO_TEST_CASE(rpc_wallet_sapling_validateaddress)
{
SelectParams(CBaseChainParams::MAIN);
vpwallets.insert(vpwallets.begin(), pwalletMain.get());

UniValue retValue;

// Check number of args
Expand All @@ -83,6 +84,8 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_sapling_validateaddress)
BOOST_CHECK_EQUAL(b, false);
BOOST_CHECK_EQUAL(find_value(resultObj, "diversifier").get_str(), "e1fd627f1b9a8e4c7e6657");
BOOST_CHECK_EQUAL(find_value(resultObj, "diversifiedtransmissionkey").get_str(), "d35e0d0897edbd3cf02b3d2327622a14c685534dbd2d3f4f4fa3e0e56cc2f008");

vpwallets.erase(vpwallets.begin());
}

BOOST_AUTO_TEST_CASE(rpc_wallet_getbalance)
Expand All @@ -92,6 +95,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_getbalance)
pwalletMain->SetMinVersion(FEATURE_SAPLING);
pwalletMain->SetupSPKM(false);
}
vpwallets.insert(vpwallets.begin(), pwalletMain.get());

BOOST_CHECK_THROW(CallRPC("getshieldbalance too many args"), std::runtime_error);
BOOST_CHECK_THROW(CallRPC("getshieldbalance invalidaddress"), std::runtime_error);
Expand All @@ -111,6 +115,8 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_getbalance)
BOOST_CHECK_THROW(CallRPC("listreceivedbyshieldaddress DMKU6mc52un1MThGCsnNwAtEvncaTdAuaZ 0"), std::runtime_error);
// don't have the spending key
BOOST_CHECK_THROW(CallRPC("listreceivedbyshieldaddress ps1u87kylcmn28yclnx2uy0psnvuhs2xn608ukm6n2nshrpg2nzyu3n62ls8j77m9cgp40dx40evej 1"), std::runtime_error);

vpwallets.erase(vpwallets.begin());
}

BOOST_AUTO_TEST_CASE(rpc_wallet_sapling_importkey_paymentaddress)
Expand All @@ -120,6 +126,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_sapling_importkey_paymentaddress)
pwalletMain->SetMinVersion(FEATURE_SAPLING);
pwalletMain->SetupSPKM(false);
}
vpwallets.insert(vpwallets.begin(), pwalletMain.get());

auto testAddress = [](const std::string& key) {
UniValue ret;
Expand All @@ -137,6 +144,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_sapling_importkey_paymentaddress)
"8uqmqlx8ccxpsw7ae243quhwr0zyekrrc520gs9z0j8pm954c3cev2yvp29vrc"
"0zweu7stxkwhp593p6drheps9uhz9pvkrfgvpxzte8d60uzw0qxadnsc77tcd");

vpwallets.erase(vpwallets.begin());
}

/*
Expand All @@ -149,6 +157,8 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_sapling_importexport)
pwalletMain->SetMinVersion(FEATURE_SAPLING);
pwalletMain->SetupSPKM(false);
}
vpwallets.insert(vpwallets.begin(), pwalletMain.get());

UniValue retValue;
int n1 = 1000; // number of times to import/export
int n2 = 1000; // number of addresses to create and list
Expand Down Expand Up @@ -223,15 +233,17 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_sapling_importexport)
BOOST_CHECK((int) listaddrs.size() == numAddrs);
BOOST_CHECK(myaddrs == listaddrs);

vpwallets.erase(vpwallets.begin());
}

// Check if address is of given type and spendable from our wallet.
void CheckHaveAddr(const libzcash::PaymentAddress& addr) {
void CheckHaveAddr(std::unique_ptr<CWallet>& pwallet, const libzcash::PaymentAddress& addr)
{

BOOST_CHECK(IsValidPaymentAddress(addr));
auto addr_of_type = boost::get<libzcash::SaplingPaymentAddress>(&addr);
BOOST_ASSERT(addr_of_type != nullptr);
BOOST_CHECK(pwalletMain->HaveSpendingKeyForPaymentAddress(*addr_of_type));
BOOST_CHECK(pwallet->HaveSpendingKeyForPaymentAddress(*addr_of_type));
}

BOOST_AUTO_TEST_CASE(rpc_wallet_getnewshieldaddress)
Expand All @@ -241,12 +253,15 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_getnewshieldaddress)
pwalletMain->SetMinVersion(FEATURE_SAPLING);
pwalletMain->SetupSPKM(false);
}
vpwallets.insert(vpwallets.begin(), pwalletMain.get());

// No parameter defaults to sapling address
UniValue addr = CallRPC("getnewshieldaddress");
CheckHaveAddr(KeyIO::DecodePaymentAddress(addr.get_str()));
CheckHaveAddr(pwalletMain, KeyIO::DecodePaymentAddress(addr.get_str()));
// Too many arguments will throw with the help
BOOST_CHECK_THROW(CallRPC("getnewshieldaddress many args"), std::runtime_error);

vpwallets.erase(vpwallets.begin());
}

BOOST_AUTO_TEST_CASE(rpc_shieldsendmany_parameters)
Expand All @@ -256,6 +271,7 @@ BOOST_AUTO_TEST_CASE(rpc_shieldsendmany_parameters)
pwalletMain->SetMinVersion(FEATURE_SAPLING);
pwalletMain->SetupSPKM(false);
}
vpwallets.insert(vpwallets.begin(), pwalletMain.get());

BOOST_CHECK_THROW(CallRPC("shieldsendmany"), std::runtime_error);
BOOST_CHECK_THROW(CallRPC("shieldsendmany toofewargs"), std::runtime_error);
Expand Down Expand Up @@ -308,16 +324,20 @@ BOOST_AUTO_TEST_CASE(rpc_shieldsendmany_parameters)
std::string zaddr1 = KeyIO::EncodePaymentAddress(pa);
BOOST_CHECK_THROW(CallRPC(std::string("shieldsendmany DMKU6mc52un1MThGCsnNwAtEvncaTdAuaZ ")
+ "[{\"address\":\"" + zaddr1 + "\", \"amount\":123.456}]"), std::runtime_error);

vpwallets.erase(vpwallets.begin());
}

// TODO: test private methods
BOOST_AUTO_TEST_CASE(saplingOperationTests)
{
{
LOCK2(cs_main, pwalletMain->cs_wallet);
pwalletMain->SetupSPKM(false);
}

auto consensusParams = Params().GetConsensus();
vpwallets.insert(vpwallets.begin(), pwalletMain.get());

UniValue retValue;

// add keys manually
Expand All @@ -330,7 +350,7 @@ BOOST_AUTO_TEST_CASE(saplingOperationTests)
// there are no utxos to spend
{
std::vector<SendManyRecipient> recipients = { SendManyRecipient(zaddr1, COIN, "DEADBEEF") };
SaplingOperation operation(consensusParams, 1, pwalletMain);
SaplingOperation operation(consensusParams, 1, pwalletMain.get());
operation.setFromAddress(taddr1);
auto res = operation.setRecipients(recipients)->buildAndSend(ret);
BOOST_CHECK(!res);
Expand All @@ -340,7 +360,7 @@ BOOST_AUTO_TEST_CASE(saplingOperationTests)
// minconf cannot be zero when sending from zaddr
{
std::vector<SendManyRecipient> recipients = { SendManyRecipient(zaddr1, COIN, "DEADBEEF") };
SaplingOperation operation(consensusParams, 1, pwalletMain);
SaplingOperation operation(consensusParams, 1, pwalletMain.get());
operation.setFromAddress(zaddr1);
auto res = operation.setRecipients(recipients)->setMinDepth(0)->buildAndSend(ret);
BOOST_CHECK(!res);
Expand All @@ -350,7 +370,7 @@ BOOST_AUTO_TEST_CASE(saplingOperationTests)
// there are no unspent notes to spend
{
std::vector<SendManyRecipient> recipients = { SendManyRecipient(taddr1, COIN) };
SaplingOperation operation(consensusParams, 1, pwalletMain);
SaplingOperation operation(consensusParams, 1, pwalletMain.get());
operation.setFromAddress(zaddr1);
auto res = operation.setRecipients(recipients)->buildAndSend(ret);
BOOST_CHECK(!res);
Expand Down Expand Up @@ -385,6 +405,8 @@ BOOST_AUTO_TEST_CASE(saplingOperationTests)
const std::string& errStr = res.getError();
BOOST_CHECK(errStr.find("too big") != std::string::npos);
}

vpwallets.erase(vpwallets.begin());
}


Expand All @@ -394,6 +416,7 @@ BOOST_AUTO_TEST_CASE(rpc_shieldsendmany_taddr_to_sapling)
LOCK2(cs_main, pwalletMain->cs_wallet);
pwalletMain->SetupSPKM(false);
}
vpwallets.insert(vpwallets.begin(), pwalletMain.get());

UniValue retValue;

Expand All @@ -411,7 +434,7 @@ BOOST_AUTO_TEST_CASE(rpc_shieldsendmany_taddr_to_sapling)
CMutableTransaction mtx;
mtx.vout.emplace_back(5 * COIN, GetScriptForDestination(taddr));
// Add to wallet and get the updated wtx
CWalletTx wtxIn(pwalletMain, MakeTransactionRef(mtx));
CWalletTx wtxIn(pwalletMain.get(), MakeTransactionRef(mtx));
pwalletMain->LoadToWallet(wtxIn);
CWalletTx& wtx = pwalletMain->mapWallet.at(mtx.GetHash());

Expand All @@ -433,15 +456,15 @@ BOOST_AUTO_TEST_CASE(rpc_shieldsendmany_taddr_to_sapling)
BOOST_CHECK_MESSAGE(pwalletMain->GetAvailableBalance() > 0, "tx not confirmed");

std::vector<SendManyRecipient> recipients = { SendManyRecipient(zaddr1, 1 * COIN, "ABCD") };
SaplingOperation operation(consensusParams, nextBlockHeight, pwalletMain);
SaplingOperation operation(consensusParams, nextBlockHeight, pwalletMain.get());
operation.setFromAddress(taddr);
BOOST_CHECK(operation.setRecipients(recipients)
->setMinDepth(0)
->build());

// try from auto-selected transparent address
std::vector<SendManyRecipient> recipients2 = { SendManyRecipient(zaddr1, 1 * COIN, "ABCD") };
SaplingOperation operation2(consensusParams, nextBlockHeight, pwalletMain);
SaplingOperation operation2(consensusParams, nextBlockHeight, pwalletMain.get());
BOOST_CHECK(operation2.setSelectTransparentCoins(true)
->setRecipients(recipients2)
->setMinDepth(0)
Expand Down Expand Up @@ -472,6 +495,7 @@ BOOST_AUTO_TEST_CASE(rpc_shieldsendmany_taddr_to_sapling)
// Tear down
chainActive.SetTip(nullptr);
mapBlockIndex.erase(blockHash);
vpwallets.erase(vpwallets.begin());
}

BOOST_AUTO_TEST_CASE(rpc_wallet_encrypted_wallet_sapzkeys)
Expand All @@ -484,6 +508,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_encrypted_wallet_sapzkeys)
pwalletMain->SetMinVersion(FEATURE_SAPLING);
pwalletMain->SetupSPKM(false);
}
vpwallets.insert(vpwallets.begin(), pwalletMain.get());

// wallet should currently be empty
std::set<libzcash::SaplingPaymentAddress> addrs;
Expand Down Expand Up @@ -532,8 +557,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_encrypted_wallet_sapzkeys)
arr = retValue.get_array();
BOOST_CHECK((int) arr.size() == n+1);

// We can't simulate over RPC the wallet closing and being reloaded
// but there are tests for this in gtest.
vpwallets.erase(vpwallets.begin());
}

BOOST_AUTO_TEST_CASE(rpc_listshieldunspent_parameters)
Expand All @@ -542,6 +566,7 @@ BOOST_AUTO_TEST_CASE(rpc_listshieldunspent_parameters)
LOCK(pwalletMain->cs_wallet);
pwalletMain->SetupSPKM(false);
}
vpwallets.insert(vpwallets.begin(), pwalletMain.get());

UniValue retValue;

Expand Down Expand Up @@ -583,6 +608,8 @@ BOOST_AUTO_TEST_CASE(rpc_listshieldunspent_parameters)

// duplicate address error
BOOST_CHECK_THROW(CallRPC("listshieldunspent 1 999 false [\"" + myzaddr + "\", \"" + myzaddr + "\"]"), std::runtime_error);

vpwallets.erase(vpwallets.begin());
}

BOOST_AUTO_TEST_SUITE_END()
2 changes: 0 additions & 2 deletions src/test/librust/sapling_wallet_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

#include <boost/test/unit_test.hpp>

extern CWallet* pwalletMain;

void setupWallet(CWallet& wallet)
{
wallet.SetMinVersion(FEATURE_SAPLING);
Expand Down
4 changes: 1 addition & 3 deletions src/test/librust/wallet_zkeys_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "util/system.h"
#include <boost/test/unit_test.hpp>

extern CWallet* pwalletMain;

/**
* This test covers methods on CWallet
* GenerateNewZKey()
Expand Down Expand Up @@ -172,7 +170,7 @@ BOOST_AUTO_TEST_CASE(WriteCryptedSaplingZkeyDirectToDb) {
BOOST_CHECK_EQUAL(DB_LOAD_OK, wallet2.LoadWallet(fFirstRun));

// Confirm it's not the same as the other wallet
BOOST_CHECK(pwalletMain != &wallet2);
BOOST_CHECK(pwalletMain.get() != &wallet2);
BOOST_CHECK(wallet2.HasSaplingSPKM());

// wallet should have two keys
Expand Down
25 changes: 12 additions & 13 deletions src/test/miner_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include <boost/test/unit_test.hpp>

extern CWallet* pwalletMain;

// future: this should be MAINNET.
BOOST_FIXTURE_TEST_SUITE(miner_tests, WalletRegTestingSetup)
Expand Down Expand Up @@ -91,7 +90,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
Checkpoints::fEnabled = false;

// Simple block creation, nothing special yet:
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false));
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false));
// Set genesis block
pblocktemplate->block.hashPrevBlock = chainparams.GetConsensus().hashGenesisBlock;

Expand All @@ -117,7 +116,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
}

// Just to make sure we can still make simple blocks
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false));
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false));

// block sigops > limit: 2000 CHECKMULTISIG + 1
tx.vin.resize(1);
Expand All @@ -135,7 +134,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
mempool.addUnchecked(hash, entry.Fee(1000000).Time(GetTime()).SpendsCoinbaseOrCoinstake(spendsCoinbase).FromTx(tx));
tx.vin[0].prevout.hash = hash;
}
BOOST_CHECK_EXCEPTION(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false), std::runtime_error, HasReason("bad-blk-sigops"));
BOOST_CHECK_EXCEPTION(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false), std::runtime_error, HasReason("bad-blk-sigops"));
mempool.clear();

tx.vin[0].prevout.hash = txFirst[0]->GetHash();
Expand All @@ -148,7 +147,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
mempool.addUnchecked(hash, entry.Fee(1000000).Time(GetTime()).SpendsCoinbaseOrCoinstake(spendsCoinbase).SigOps(20).FromTx(tx));
tx.vin[0].prevout.hash = hash;
}
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false));
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false));
mempool.clear();

// block size > limit
Expand All @@ -168,13 +167,13 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
mempool.addUnchecked(hash, entry.Fee(1000000).Time(GetTime()).SpendsCoinbaseOrCoinstake(spendsCoinbase).FromTx(tx));
tx.vin[0].prevout.hash = hash;
}
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false));
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false));
mempool.clear();

// orphan in mempool, template creation fails
hash = tx.GetHash();
mempool.addUnchecked(hash, entry.Fee(1000000).Time(GetTime()).FromTx(tx));
BOOST_CHECK_EXCEPTION(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
BOOST_CHECK_EXCEPTION(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
mempool.clear();

// child with higher priority than parent
Expand All @@ -191,7 +190,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
tx.vout[0].nValue = 5900000000LL;
hash = tx.GetHash();
mempool.addUnchecked(hash, entry.Fee(400000000LL).Time(GetTime()).SpendsCoinbaseOrCoinstake(true).FromTx(tx));
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false));
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false));
mempool.clear();

// coinbase in mempool, template creation fails
Expand All @@ -202,7 +201,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
hash = tx.GetHash();
// give it a fee so it'll get mined
mempool.addUnchecked(hash, entry.Fee(100000).Time(GetTime()).SpendsCoinbaseOrCoinstake(false).FromTx(tx));
BOOST_CHECK_EXCEPTION(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false), std::runtime_error, HasReason("bad-cb-multiple"));
BOOST_CHECK_EXCEPTION(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false), std::runtime_error, HasReason("bad-cb-multiple"));
mempool.clear();

// invalid (pre-p2sh) txn in mempool, template creation fails
Expand All @@ -220,7 +219,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
hash = tx.GetHash();
mempool.addUnchecked(hash, entry.Fee(1000000).Time(GetTime()).SpendsCoinbaseOrCoinstake(false).FromTx(tx));
// Should throw block-validation-failed
BOOST_CHECK_EXCEPTION(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false), std::runtime_error, HasReason("block-validation-failed"));
BOOST_CHECK_EXCEPTION(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false), std::runtime_error, HasReason("block-validation-failed"));
mempool.clear();

// double spend txn pair in mempool, template creation fails
Expand All @@ -233,7 +232,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
tx.vout[0].scriptPubKey = CScript() << OP_2;
hash = tx.GetHash();
mempool.addUnchecked(hash, entry.Fee(100000000L).Time(GetTime()).SpendsCoinbaseOrCoinstake(true).FromTx(tx));
BOOST_CHECK_EXCEPTION(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
BOOST_CHECK_EXCEPTION(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false), std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
mempool.clear();

// non-final txs in mempool
Expand Down Expand Up @@ -264,7 +263,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
mempool.addUnchecked(hash, entry.Fee(100000000L).Time(GetTime()).SpendsCoinbaseOrCoinstake(true).FromTx(tx2));
{ LOCK(cs_main); BOOST_CHECK(!CheckFinalTx(MakeTransactionRef(tx2), LOCKTIME_MEDIAN_TIME_PAST)); }

BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false));
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false));

// Neither tx should have make it into the template.
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 1);
Expand All @@ -281,7 +280,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
//BOOST_CHECK(CheckFinalTx(tx));
//BOOST_CHECK(CheckFinalTx(tx2));

BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain, false));
BOOST_CHECK(pblocktemplate = BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwalletMain.get(), false));
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 3);

WITH_LOCK(cs_main, chainActive.Tip()->nHeight--);
Expand Down
2 changes: 1 addition & 1 deletion src/test/script_P2CS_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ BOOST_AUTO_TEST_CASE(fake_script_test)
{
BOOST_ASSERT(!g_IsV6Active);

CWallet& wallet = *vpwallets[0];
CWallet& wallet = *pwalletMain;
LOCK(wallet.cs_wallet);
setupWallet(wallet);
CKey stakerKey; // dummy staker key (not in the wallet)
Expand Down
Loading

0 comments on commit d10acd5

Please sign in to comment.