13 #include <boost/test/unit_test.hpp>
14 #include "test_prcycoin.h"
21 #define RANDOM_REPEATS 5
24 typedef std::set<std::pair<const CWalletTx*,unsigned int> >
CoinSet;
30 static void generate_block(
int count) {
34 int nGenerate = count;
40 nHeight = nHeightStart;
41 nHeightEnd = nHeightStart + nGenerate;
43 unsigned int nExtraNonce = 0;
44 while (nHeight < nHeightEnd) {
45 bool createPoSBlock =
false;
46 if (nHeight >
Params().LAST_POW_BLOCK())
47 createPoSBlock =
true;
49 std::unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey,
pwalletMain, createPoSBlock));
52 CBlock* pblock = &pblocktemplate->block;
68 #ifdef DISABLE_FAILED_TEST
70 static std::vector<COutput> vCoins;
72 static void add_coin(
const CAmount& nValue,
int nAge = 6*24,
bool fIsFromMe =
false,
int nInput=0)
74 static int nextLockTime = 0;
77 tx.
vout.resize(nInput+1);
78 tx.
vout[nInput].nValue = nValue;
90 COutput output(wtx, nInput, nAge,
true);
91 vCoins.push_back(output);
94 static void empty_wallet(
void)
103 pair<CoinSet::iterator, CoinSet::iterator> ret = mismatch(a.begin(), a.end(),
b.begin());
104 return ret.first == a.end() && ret.second ==
b.end();
109 CoinSet setCoinsRet, setCoinsRet2;
141 add_coin(10*CENT, 3,
true);
159 BOOST_CHECK_GT(nValueRet, 34 * CENT);
258 for (
int i = 0; i < 20; i++)
259 add_coin(50000 * COIN);
270 add_coin(0.5 * CENT);
271 add_coin(0.6 * CENT);
272 add_coin(0.7 * CENT);
273 add_coin(1111 * CENT);
280 add_coin(0.4 * CENT);
281 add_coin(0.6 * CENT);
282 add_coin(0.8 * CENT);
283 add_coin(1111 * CENT);
290 add_coin(0.0005 * COIN);
291 add_coin(0.01 * COIN);
307 for (
int i2 = 0; i2 < 100; i2++)
314 BOOST_CHECK(!equal_sets(setCoinsRet, setCoinsRet2));
323 if (equal_sets(setCoinsRet, setCoinsRet2))
331 add_coin( 5*CENT); add_coin(10*CENT); add_coin(15*CENT); add_coin(20*CENT); add_coin(25*CENT);
340 if (equal_sets(setCoinsRet, setCoinsRet2))
352 std::string stealthAddr =
"Pap9NcoXyLMQxDLoJ56faM5aRHVvWhmdTfrtBkmbySmb6cDjygrVcNUWqpUrLLrtQt89Ev3nDutQRMYcs7gWHtr11AN6pGMEELj";
361 }
catch (
const std::exception& e) {
364 BOOST_CHECK_MESSAGE(!ret,
"Sending to stealth address have to be failed on 0 balance wallet");
372 }
catch (
const std::exception& e) {
375 BOOST_CHECK_MESSAGE(ret,
"Sending to stealth address have to be success with reservebalance wallet");
382 }
catch (
const std::exception& e) {
385 BOOST_CHECK_MESSAGE(ret,
"Sending to stealth address have to be success on enough balance wallet");