Skip to content

Commit

Permalink
Stabilize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reorder committed May 4, 2019
1 parent 9085825 commit 3c72670
Show file tree
Hide file tree
Showing 31 changed files with 268 additions and 632 deletions.
10 changes: 5 additions & 5 deletions src/auxpow/auxpow.h
Expand Up @@ -5,11 +5,11 @@
#ifndef BITCOIN_AUXPOW_AUXPOW_H
#define BITCOIN_AUXPOW_AUXPOW_H

#include "versionbits.h"
#include "consensus/params.h"
#include "wallet/wallet.h"
#include "primitives/blockheader.h"
#include "auxpow/consensus.h"
#include <versionbits.h>
#include <consensus/params.h>
#include <utilstrencodings.h>
#include <primitives/blockheader.h>
#include <auxpow/consensus.h>


class CAuxPow : public CMerkleTx
Expand Down
3 changes: 2 additions & 1 deletion src/chainparams.cpp
Expand Up @@ -77,6 +77,7 @@ class CMainParams : public CChainParams {
CMainParams() {
strNetworkID = "main";
consensus.nSubsidyHalvingInterval = 657000;
consensus.BIP16Height = 0;
consensus.BIP34Height = 0;
consensus.BIP34Hash = uint256S("0x4e9b54001f9976049830128ec0331515eaabe35a70970d79971da1539a400ba1");
consensus.BIP65Height = 598725;
Expand Down Expand Up @@ -272,7 +273,7 @@ class CRegTestParams : public CChainParams {
strNetworkID = "regtest";
consensus.nSubsidyHalvingInterval = 150;
consensus.BIP16Height = 0; // always enforce P2SH BIP16 on regtest
consensus.BIP34Height = -1; // BIP34 has not activated on regtest (far in the future so block v1 are not rejected in tests)
consensus.BIP34Height = 100000000; // BIP34 has not activated on regtest (far in the future so block v1 are not rejected in tests)
consensus.BIP34Hash = uint256();
consensus.BIP65Height = 1251; // BIP65 activated on regtest (Used in rpc activation tests)
consensus.BIP66Height = 1351; // BIP66 activated on regtest (Used in rpc activation tests)
Expand Down
3 changes: 2 additions & 1 deletion src/primitives/block.cpp
Expand Up @@ -26,8 +26,9 @@ uint256 CBlockHeader::GetPoWHash() const
std::string CBlock::ToString() const
{
std::stringstream s;
s << strprintf("CBlock(hash=%s, ver=0x%08x, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
s << strprintf("CBlock(hash=%s, powhash=%s, ver=0x%08x, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
GetHash().ToString(),
GetPoWHash().ToString(),
nVersion,
hashPrevBlock.ToString(),
hashMerkleRoot.ToString(),
Expand Down
5 changes: 3 additions & 2 deletions src/primitives/blockheader.h
@@ -1,8 +1,9 @@
#ifndef VIACOIN_BLOCKHEADER_H
#define VIACOIN_BLOCKHEADER_H

#include "auxpow/consensus.h"
#include "auxpow/serialize.h"
#include <primitives/transaction.h>
#include <auxpow/consensus.h>
#include <auxpow/serialize.h>

/** Nodes collect new transactions into a block, hash them into a hash tree,
* and scan through nonce values to make the block's hash satisfy proof-of-work
Expand Down
78 changes: 78 additions & 0 deletions src/primitives/transaction.h
Expand Up @@ -410,4 +410,82 @@ typedef std::shared_ptr<const CTransaction> CTransactionRef;
static inline CTransactionRef MakeTransactionRef() { return std::make_shared<const CTransaction>(); }
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }

class CBlockIndex;

/** A transaction with a merkle branch linking it to the block chain. */
class CMerkleTx
{
private:
/** Constant used in hashBlock to indicate tx has been abandoned */
static const uint256 ABANDON_HASH;

public:
CTransactionRef tx;
uint256 hashBlock;

// Viacoin: SegWit removed the coinbase merkle tree and only included it for
// Viacoin: backwards compatibility with older bitcoin clients.
// Viacoin: Viacoin still needs it here
std::vector<uint256> vMerkleBranch;

/* An nIndex == -1 means that hashBlock (in nonzero) refers to the earliest
* block in the chain we know this or any in-wallet dependency conflicts
* with. Older clients interpret nIndex == -1 as unconfirmed for backward
* compatibility.
*/
int nIndex;

CMerkleTx()
{
SetTx(MakeTransactionRef());
Init();
}

explicit CMerkleTx(CTransactionRef arg)
{
SetTx(std::move(arg));
Init();
}

void Init()
{
hashBlock = uint256();
nIndex = -1;
}

void SetTx(CTransactionRef arg)
{
tx = std::move(arg);
}

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(tx);
READWRITE(hashBlock);
READWRITE(vMerkleBranch);
READWRITE(nIndex);
}

void SetMerkleBranch(const CBlockIndex* pIndex, int posInBlock);

/**
* Return depth of transaction in blockchain:
* <0 : conflicts with a transaction this deep in the blockchain
* 0 : in memory pool, waiting to be included in a block
* >=1 : this many blocks deep in the main chain
*/
int GetDepthInMainChain(const CBlockIndex* &pindexRet) const;
int GetDepthInMainChain() const { const CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); }
bool IsInMainChain() const { const CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet) > 0; }
int GetBlocksToMaturity() const;
bool hashUnset() const { return (hashBlock.IsNull() || hashBlock == ABANDON_HASH); }
bool isAbandoned() const { return (hashBlock == ABANDON_HASH); }
void setAbandoned() { hashBlock = ABANDON_HASH; }

const uint256& GetHash() const { return tx->GetHash(); }
bool IsCoinBase() const { return tx->IsCoinBase(); }
};

#endif // BITCOIN_PRIMITIVES_TRANSACTION_H
2 changes: 1 addition & 1 deletion src/qt/test/wallettests.cpp
Expand Up @@ -237,7 +237,7 @@ void TestGUI()
QString paymentText = rlist->toPlainText();
QStringList paymentTextList = paymentText.split('\n');
QCOMPARE(paymentTextList.at(0), QString("Payment information"));
QVERIFY(paymentTextList.at(1).indexOf(QString("URI: bitcoin:")) != -1);
QVERIFY(paymentTextList.at(1).indexOf(QString("URI: viacoin:")) != -1);
QVERIFY(paymentTextList.at(2).indexOf(QString("Address:")) != -1);
QCOMPARE(paymentTextList.at(3), QString("Amount: 0.00000001 ") + QString::fromStdString(CURRENCY_UNIT));
QCOMPARE(paymentTextList.at(4), QString("Label: TEST_LABEL_1"));
Expand Down
2 changes: 1 addition & 1 deletion src/test/data/base58_keys_invalid.json
Expand Up @@ -99,7 +99,7 @@
"JKSnxB43ogNNPW9F27d8amwPWimdRLG95EUCiSrFJybfxVFPUjBFZFdeGdjzBygXCi7rinvS6Rz"
],
[
"tJgWcJ8FqGWWuX6DGeMxnCKjfhm2osTu6Q"
"dB7cwYdcPSgiyAwKWL3JwCVwSk6epU2txw"
],
[
"2UDnhZGfuHzAKd4HSo99ALrVax5TgKxzALJR1Ct36ibrZqXsnwRBsVvKneDYWxiQjcpnQ3NWK2as"
Expand Down

0 comments on commit 3c72670

Please sign in to comment.