tweaks
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
#include <cryptoconditions.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "cc/betprotocol.h"
|
||||
#include "cc/eval.h"
|
||||
#include "base58.h"
|
||||
@@ -13,16 +12,12 @@
|
||||
#include "primitives/transaction.h"
|
||||
#include "script/interpreter.h"
|
||||
#include "script/serverchecker.h"
|
||||
|
||||
#include "testutils.h"
|
||||
|
||||
|
||||
extern Eval* EVAL_TEST;
|
||||
|
||||
|
||||
namespace TestBet {
|
||||
|
||||
|
||||
static std::vector<CKey> playerSecrets;
|
||||
static std::vector<CPubKey> players;
|
||||
|
||||
|
||||
@@ -22,23 +22,17 @@
|
||||
#include "script/interpreter.h"
|
||||
#include "testutils.h"
|
||||
|
||||
|
||||
// We need to have control of Time Itself, otherwise block production can fail.
|
||||
int64_t nMockTime;
|
||||
extern uint32_t USE_EXTERNAL_PUBKEY;
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
// This is a publicly burned keypair for Testing Purposes Only, lulz
|
||||
// Have fun, Blockchain Analysts ;)
|
||||
std::string notaryPubkey = "0205a8ad0c1dbc515f149af377981aab58b836af008d4d7ab21bd76faf80550b47";
|
||||
std::string notarySecret = "UxFWWxsf1d7w7K5TvAWSkeX4H95XQKwdwGv49DXwWUTzPTTjHBbU";
|
||||
CKey notaryKey;
|
||||
|
||||
|
||||
/*
|
||||
* We need to have control of clock,
|
||||
* otherwise block production can fail.
|
||||
*/
|
||||
int64_t nMockTime;
|
||||
|
||||
extern uint32_t USE_EXTERNAL_PUBKEY;
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
|
||||
void setupChain()
|
||||
{
|
||||
void setupChain() {
|
||||
SelectParams(CBaseChainParams::REGTEST);
|
||||
|
||||
// Settings to get block reward
|
||||
@@ -54,7 +48,7 @@ void setupChain()
|
||||
|
||||
// Init blockchain
|
||||
ClearDatadirCache();
|
||||
auto pathTemp = GetTempPath() / strprintf("test_komodo_%li_%i", GetTime(), GetRand(100000));
|
||||
auto pathTemp = GetTempPath() / strprintf("test_hush_%li_%i", GetTime(), GetRand(100000));
|
||||
if (SMART_CHAIN_SYMBOL[0])
|
||||
pathTemp = pathTemp / strprintf("_%s", SMART_CHAIN_SYMBOL);
|
||||
boost::filesystem::create_directories(pathTemp);
|
||||
@@ -74,7 +68,7 @@ void generateBlock(CBlock *block)
|
||||
params.push_back(1);
|
||||
uint256 blockId;
|
||||
|
||||
SetMockTime(nMockTime+=100); // CreateNewBlock can fail if not enough time passes
|
||||
SetMockTime(nMockTime+=100); // CreateNewBlock can fail if not enough Time Has Happened
|
||||
|
||||
try {
|
||||
UniValue out = generate(params, false, CPubKey());
|
||||
@@ -85,21 +79,18 @@ void generateBlock(CBlock *block)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void acceptTxFail(const CTransaction tx)
|
||||
{
|
||||
CValidationState state;
|
||||
if (!acceptTx(tx, state)) FAIL() << state.GetRejectReason();
|
||||
}
|
||||
|
||||
|
||||
bool acceptTx(const CTransaction tx, CValidationState &state)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
return AcceptToMemoryPool(mempool, state, tx, false, NULL);
|
||||
}
|
||||
|
||||
|
||||
CMutableTransaction spendTx(const CTransaction &txIn, int nOut)
|
||||
{
|
||||
CMutableTransaction mtx;
|
||||
@@ -111,7 +102,6 @@ CMutableTransaction spendTx(const CTransaction &txIn, int nOut)
|
||||
return mtx;
|
||||
}
|
||||
|
||||
|
||||
std::vector<uint8_t> getSig(const CMutableTransaction mtx, CScript inputPubKey, int nIn)
|
||||
{
|
||||
uint256 hash = SignatureHash(inputPubKey, mtx, nIn, SIGHASH_ALL, 0, 0);
|
||||
@@ -121,7 +111,6 @@ std::vector<uint8_t> getSig(const CMutableTransaction mtx, CScript inputPubKey,
|
||||
return vchSig;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* In order to do tests there needs to be inputs to spend.
|
||||
* This method creates a block and returns a transaction that spends the coinbase.
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
// Copyright (c) 2019-2020 The Hush developers
|
||||
// Distributed under the GPLv3 software license, see the accompanying
|
||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
#ifndef TESTUTILS_H
|
||||
#define TESTUTILS_H
|
||||
#ifndef HUSH_TESTUTILS_H
|
||||
#define HUSH_TESTUTILS_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
#define VCH(a,b) std::vector<unsigned char>(a, a + b)
|
||||
|
||||
static char ccjsonerr[1000] = "\0";
|
||||
@@ -14,12 +13,9 @@ static char ccjsonerr[1000] = "\0";
|
||||
o = cc_conditionFromJSONString(s, ccjsonerr); \
|
||||
if (!o) FAIL() << "bad json: " << ccjsonerr;
|
||||
|
||||
|
||||
extern std::string notaryPubkey;
|
||||
extern std::string notarySecret;
|
||||
extern CKey notaryKey;
|
||||
|
||||
|
||||
void setupChain();
|
||||
void generateBlock(CBlock *block=NULL);
|
||||
bool acceptTx(const CTransaction tx, CValidationState &state);
|
||||
@@ -28,5 +24,4 @@ void getInputTx(CScript scriptPubKey, CTransaction &txIn);
|
||||
CMutableTransaction spendTx(const CTransaction &txIn, int nOut=0);
|
||||
std::vector<uint8_t> getSig(const CMutableTransaction mtx, CScript inputPubKey, int nIn=0);
|
||||
|
||||
|
||||
#endif /* TESTUTILS_H */
|
||||
#endif /* HUSH_TESTUTILS_H */
|
||||
|
||||
Reference in New Issue
Block a user