Merge pull request #549 from leofidus/1.7-rpctests
Fix bash-based rpc tests
This commit is contained in:
commit
15dee2a91e
|
@ -6,7 +6,7 @@ before_install:
|
|||
- sudo apt-get update -qq
|
||||
- sudo apt-get install build-essential libtool autotools-dev autoconf libssl-dev pkg-config ccache
|
||||
- sudo apt-get install libboost1.48-dev libboost-chrono1.48-dev libboost-filesystem1.48-dev libboost-program-options1.48-dev libboost-system1.48-dev libboost-test1.48-dev libboost-thread1.48-dev
|
||||
- sudo apt-get install libdb++-dev
|
||||
- sudo apt-get install libdb++-dev bc dc
|
||||
- sudo apt-get install libqt4-dev
|
||||
- sudo apt-get install libprotobuf-dev protobuf-compiler
|
||||
- mkdir $HOME/.ccache
|
||||
|
@ -17,6 +17,10 @@ script:
|
|||
- CFLAGS="-O1" CXXFLAGS="-O1" ./configure
|
||||
- make -j 2
|
||||
- make check
|
||||
- qa/rpc-tests/conflictedbalance.sh src
|
||||
- qa/rpc-tests/txnmall.sh src
|
||||
- qa/rpc-tests/wallet.sh src
|
||||
- qa/rpc-tests/walletbackup.sh src
|
||||
- make clean
|
||||
- CFLAGS="-O1" CXXFLAGS="-O1" ./configure --disable-wallet
|
||||
- make -j 2
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Copyright (c) 2014 The Dogecoin Core developers
|
||||
# Distributed under the MIT/X11 software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
@ -23,8 +24,8 @@ fi
|
|||
|
||||
set -f
|
||||
|
||||
BITCOIND=${1}/bitcoind
|
||||
CLI=${1}/bitcoin-cli
|
||||
BITCOIND=${1}/dogecoind
|
||||
CLI=${1}/dogecoin-cli
|
||||
|
||||
DIR="${BASH_SOURCE%/*}"
|
||||
SENDANDWAIT="${DIR}/send.sh"
|
||||
|
@ -81,16 +82,16 @@ echo "Generating test blockchain..."
|
|||
$CLI $B2ARGS addnode 127.0.0.1:11000 onetry
|
||||
WaitPeers "$B1ARGS" 1
|
||||
|
||||
# 2 block, 50 XBT each == 100 XBT
|
||||
# 2 block, 500000 XDG each == 1000000 XDG
|
||||
# These will be transactions "A" and "B"
|
||||
$CLI $B1ARGS setgenerate true 2
|
||||
|
||||
WaitBlocks
|
||||
# 100 blocks, 0 mature == 0 XBT
|
||||
$CLI $B2ARGS setgenerate true 100
|
||||
# 49 blocks, 0 mature == 0 XDG
|
||||
$CLI $B2ARGS setgenerate true 49
|
||||
WaitBlocks
|
||||
|
||||
CheckBalance "$B1ARGS" 100
|
||||
CheckBalance "$B1ARGS" 1000000
|
||||
CheckBalance "$B2ARGS" 0
|
||||
|
||||
# restart B2 with no connection
|
||||
|
@ -103,10 +104,10 @@ B1ADDRESS=$( $CLI $B1ARGS getnewaddress )
|
|||
B2ADDRESS=$( $CLI $B2ARGS getnewaddress )
|
||||
|
||||
# Transaction C: send-to-self, spend A
|
||||
TXID_C=$( $CLI $B1ARGS sendtoaddress $B1ADDRESS 50.0)
|
||||
TXID_C=$( $CLI $B1ARGS sendtoaddress $B1ADDRESS 500000.0)
|
||||
|
||||
# Transaction D: spends B and C
|
||||
TXID_D=$( $CLI $B1ARGS sendtoaddress $B2ADDRESS 100.0)
|
||||
TXID_D=$( $CLI $B1ARGS sendtoaddress $B2ADDRESS 1000000.0)
|
||||
|
||||
CheckBalance "$B1ARGS" 0
|
||||
|
||||
|
@ -132,9 +133,9 @@ WaitPeers "$B1ARGS" 1
|
|||
$CLI $B2ARGS setgenerate true 1
|
||||
WaitBlocks
|
||||
|
||||
# B1 should still be able to spend 100, because D is conflicted
|
||||
# B1 should still be able to spend 1000000, because D is conflicted
|
||||
# so does not count as a spend of B
|
||||
CheckBalance "$B1ARGS" 100
|
||||
CheckBalance "$B1ARGS" 1000000
|
||||
|
||||
$CLI $B2ARGS stop > /dev/null 2>&1
|
||||
wait $B2PID
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Copyright (c) 2014 The Dogecoin Core developers
|
||||
# Distributed under the MIT/X11 software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
@ -13,8 +14,8 @@ fi
|
|||
|
||||
set -f
|
||||
|
||||
BITCOIND=${1}/bitcoind
|
||||
CLI=${1}/bitcoin-cli
|
||||
BITCOIND=${1}/dogecoind
|
||||
CLI=${1}/dogecoin-cli
|
||||
|
||||
DIR="${BASH_SOURCE%/*}"
|
||||
SENDANDWAIT="${DIR}/send.sh"
|
||||
|
@ -71,15 +72,15 @@ echo "Generating test blockchain..."
|
|||
$CLI $B2ARGS addnode 127.0.0.1:11000 onetry
|
||||
WaitPeers "$B1ARGS" 1
|
||||
|
||||
# 1 block, 50 XBT each == 50 XBT
|
||||
# 1 block, 500000 XDG each == 50 XDG
|
||||
$CLI $B1ARGS setgenerate true 1
|
||||
|
||||
WaitBlocks
|
||||
# 100 blocks, 0 mature == 0 XBT
|
||||
$CLI $B2ARGS setgenerate true 100
|
||||
# 49 blocks, 0 mature == 0 XDG
|
||||
$CLI $B2ARGS setgenerate true 49
|
||||
WaitBlocks
|
||||
|
||||
CheckBalance "$B1ARGS" 50
|
||||
CheckBalance "$B1ARGS" 500000
|
||||
CheckBalance "$B2ARGS" 0
|
||||
|
||||
# restart B2 with no connection
|
||||
|
@ -92,7 +93,7 @@ B2ADDRESS=$( $CLI $B2ARGS getaccountaddress "from1" )
|
|||
|
||||
# Have B1 create two transactions; second will
|
||||
# spend change from first, since B1 starts with only a single
|
||||
# 50 bitcoin output:
|
||||
# 500000 dogecoin output:
|
||||
$CLI $B1ARGS move "" "foo" 10.0 > /dev/null
|
||||
$CLI $B1ARGS move "" "bar" 10.0 > /dev/null
|
||||
TXID1=$( $CLI $B1ARGS sendfrom foo $B2ADDRESS 1.0 0)
|
||||
|
@ -129,16 +130,16 @@ $CLI $B2ARGS addnode 127.0.0.1:11000 onetry
|
|||
$CLI $B2ARGS setgenerate true 1
|
||||
WaitBlocks
|
||||
|
||||
# B1 should have 49 BTC; the 2 BTC send is
|
||||
# B1 should have 499999 DOGE; the 2 DOGE send is
|
||||
# conflicted, and should not count in
|
||||
# balances.
|
||||
CheckBalance "$B1ARGS" 49
|
||||
CheckBalance "$B1ARGS" 49 "*"
|
||||
CheckBalance "$B1ARGS" 499999
|
||||
CheckBalance "$B1ARGS" 499999 "*"
|
||||
CheckBalance "$B1ARGS" 9 "foo"
|
||||
CheckBalance "$B1ARGS" 10 "bar"
|
||||
|
||||
# B2 should have 51 BTC
|
||||
CheckBalance "$B2ARGS" 51
|
||||
# B2 should have 500001 DOGE
|
||||
CheckBalance "$B2ARGS" 500001
|
||||
CheckBalance "$B2ARGS" 1 "from1"
|
||||
|
||||
$CLI $B2ARGS stop > /dev/null 2>&1
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Copyright (c) 2014 The Dogecoin Core developers
|
||||
# Distributed under the MIT/X11 software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
@ -20,7 +21,7 @@ function ExtractKey {
|
|||
function CreateDataDir {
|
||||
DIR=$1
|
||||
mkdir -p $DIR
|
||||
CONF=$DIR/bitcoin.conf
|
||||
CONF=$DIR/dogecoin.conf
|
||||
echo "regtest=1" >> $CONF
|
||||
echo "keypool=2" >> $CONF
|
||||
echo "rpcuser=rt" >> $CONF
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright (c) 2013-2014 The Bitcoin Core developers
|
||||
# Copyright (c) 2014 The Dogecoin Core developers
|
||||
# Distributed under the MIT/X11 software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
@ -13,8 +14,8 @@ fi
|
|||
|
||||
set -f
|
||||
|
||||
BITCOIND=${1}/bitcoind
|
||||
CLI=${1}/bitcoin-cli
|
||||
BITCOIND=${1}/dogecoind
|
||||
CLI=${1}/dogecoin-cli
|
||||
|
||||
DIR="${BASH_SOURCE%/*}"
|
||||
SENDANDWAIT="${DIR}/send.sh"
|
||||
|
@ -58,21 +59,21 @@ function WaitBlocks {
|
|||
|
||||
echo "Generating test blockchain..."
|
||||
|
||||
# 1 block, 50 XBT each == 50 XBT
|
||||
# 1 block, 500000 XDG each == 500000 XDG
|
||||
$CLI $B1ARGS setgenerate true 1
|
||||
WaitBlocks
|
||||
# 101 blocks, 1 mature == 50 XBT
|
||||
$CLI $B2ARGS setgenerate true 101
|
||||
# 50 blocks, 1 mature == 500000 XDG
|
||||
$CLI $B2ARGS setgenerate true 50
|
||||
WaitBlocks
|
||||
|
||||
CheckBalance "$B1ARGS" 50
|
||||
CheckBalance "$B2ARGS" 50
|
||||
CheckBalance "$B1ARGS" 500000
|
||||
CheckBalance "$B2ARGS" 500000
|
||||
|
||||
# Send 21 XBT from 1 to 3. Second
|
||||
# Send 210000 XDG from 1 to 3. Second
|
||||
# transaction will be child of first, and
|
||||
# will require a fee
|
||||
Send $B1ARGS $B3ARGS 11
|
||||
Send $B1ARGS $B3ARGS 10
|
||||
Send $B1ARGS $B3ARGS 110000
|
||||
Send $B1ARGS $B3ARGS 100000
|
||||
|
||||
# Have B1 mine a new block, and mature it
|
||||
# to recover transaction fees
|
||||
|
@ -80,13 +81,13 @@ $CLI $B1ARGS setgenerate true 1
|
|||
WaitBlocks
|
||||
|
||||
# Have B2 mine 100 blocks so B1's block is mature:
|
||||
$CLI $B2ARGS setgenerate true 100
|
||||
$CLI $B2ARGS setgenerate true 49
|
||||
WaitBlocks
|
||||
|
||||
# B1 should end up with 100 XBT in block rewards plus fees,
|
||||
# minus the 21 XBT sent to B3:
|
||||
CheckBalance "$B1ARGS" "100-21"
|
||||
CheckBalance "$B3ARGS" "21"
|
||||
# B1 should end up with 1000k XDG in block rewards plus fees,
|
||||
# minus the 210k XDG sent to B3:
|
||||
CheckBalance "$B1ARGS" "1000000-210000"
|
||||
CheckBalance "$B3ARGS" "210000"
|
||||
|
||||
# B1 should have two unspent outputs; create a couple
|
||||
# of raw transactions to send them to B3, submit them through
|
||||
|
@ -102,8 +103,8 @@ WaitBlocks
|
|||
|
||||
# Check balances after confirmation
|
||||
CheckBalance "$B1ARGS" 0
|
||||
CheckBalance "$B3ARGS" 100
|
||||
CheckBalance "$B3ARGS" "100-21" "from1"
|
||||
CheckBalance "$B3ARGS" 1000000
|
||||
CheckBalance "$B3ARGS" "1000000-210000" "from1"
|
||||
|
||||
$CLI $B3ARGS stop > /dev/null 2>&1
|
||||
wait $B3PID
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright (c) 2014 The Bitcoin Core developers
|
||||
# Copyright (c) 2014 The Dogecoin Core developers
|
||||
# Distributed under the MIT/X11 software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
@ -9,7 +10,7 @@
|
|||
# 4 nodes. 1 2 3 and send transactions between each other,
|
||||
# fourth node is a miner.
|
||||
# 1 2 3 and each mine a block to start, then
|
||||
# miner creates 100 blocks so 1 2 3 each have 50 mature
|
||||
# miner creates 49 blocks so 1 2 3 each have 500k mature
|
||||
# coins to spend.
|
||||
# Then 5 iterations of 1/2/3 sending coins amongst
|
||||
# themselves to get transactions in the wallets,
|
||||
|
@ -18,13 +19,9 @@
|
|||
# Wallets are backed up using dumpwallet/backupwallet.
|
||||
# Then 5 more iterations of transactions, then block.
|
||||
#
|
||||
# Miner then generates 101 more blocks, so any
|
||||
# Miner then generates 50 more blocks, so any
|
||||
# transaction fees paid mature.
|
||||
#
|
||||
# Sanity checks done:
|
||||
# Miner balance >= 150*50
|
||||
# Sum(1,2,3,4 balances) == 153*150
|
||||
#
|
||||
# 1/2/3 are shutdown, and their wallets erased.
|
||||
# Then restore using wallet.dat backup. And
|
||||
# confirm 1/2/3/4 balances are same as before.
|
||||
|
@ -39,8 +36,8 @@ if [ $# -lt 1 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
BITCOIND=${1}/bitcoind
|
||||
CLI=${1}/bitcoin-cli
|
||||
BITCOIND=${1}/dogecoind
|
||||
CLI=${1}/dogecoin-cli
|
||||
|
||||
DIR="${BASH_SOURCE%/*}"
|
||||
SENDANDWAIT="${DIR}/send.sh"
|
||||
|
@ -64,7 +61,7 @@ B4PID=$!
|
|||
function CreateConfDir {
|
||||
DIR=$1
|
||||
mkdir -p $DIR
|
||||
CONF=$DIR/bitcoin.conf
|
||||
CONF=$DIR/dogecoin.conf
|
||||
echo "regtest=1" >> $CONF
|
||||
echo "rpcuser=rt" >> $CONF
|
||||
echo "rpcpassword=rt" >> $CONF
|
||||
|
@ -128,7 +125,7 @@ function WaitMemPools {
|
|||
|
||||
echo "Generating initial blockchain..."
|
||||
|
||||
# 1 block, 50 XBT each == 50 BTC
|
||||
# 1 block, 500000 XDG each == 500000 DOGE
|
||||
$CLI $B1ARGS setgenerate true 1
|
||||
WaitBlocks
|
||||
$CLI $B2ARGS setgenerate true 1
|
||||
|
@ -136,13 +133,13 @@ WaitBlocks
|
|||
$CLI $B3ARGS setgenerate true 1
|
||||
WaitBlocks
|
||||
|
||||
# 100 blocks, 0 mature
|
||||
$CLI $B4ARGS setgenerate true 100
|
||||
# 49 blocks, 0 mature
|
||||
$CLI $B4ARGS setgenerate true 49
|
||||
WaitBlocks
|
||||
|
||||
CheckBalance "$B1ARGS" 50
|
||||
CheckBalance "$B2ARGS" 50
|
||||
CheckBalance "$B3ARGS" 50
|
||||
CheckBalance "$B1ARGS" 500000
|
||||
CheckBalance "$B2ARGS" 500000
|
||||
CheckBalance "$B3ARGS" 500000
|
||||
CheckBalance "$B4ARGS" 0
|
||||
|
||||
echo "Creating transactions..."
|
||||
|
@ -150,7 +147,7 @@ echo "Creating transactions..."
|
|||
function S {
|
||||
TXID=$( $CLI -datadir=${D}/node${1} sendtoaddress ${2} "${3}" 0 )
|
||||
if [[ $TXID == "" ]] ; then
|
||||
echoerr "node${1}: error sending ${3} btc"
|
||||
echoerr "node${1}: error sending ${3} doge"
|
||||
echo -n "node${1} balance: "
|
||||
$CLI -datadir=${D}/node${1} getbalance "*" 0
|
||||
exit 1
|
||||
|
@ -204,9 +201,9 @@ for i in {1..5}; do OneRound ; done
|
|||
|
||||
WaitMemPools
|
||||
|
||||
# Generate 101 more blocks, so any fees paid
|
||||
# Generate 50 more blocks, so any fees paid
|
||||
# mature
|
||||
$CLI "$B4ARGS" setgenerate true 101
|
||||
$CLI "$B4ARGS" setgenerate true 50
|
||||
|
||||
BALANCE1=$( $CLI "$B1ARGS" getbalance )
|
||||
BALANCE2=$( $CLI "$B2ARGS" getbalance )
|
||||
|
@ -215,7 +212,8 @@ BALANCE4=$( $CLI "$B4ARGS" getbalance )
|
|||
|
||||
TOTAL=$( dc -e "$BALANCE1 $BALANCE2 $BALANCE3 $BALANCE4 + + + p" )
|
||||
|
||||
AssertEqual $TOTAL 5700.00000000
|
||||
#500000 * (3 + 49 + 5 + 5 + 1 (+49 unmature))
|
||||
AssertEqual $TOTAL 31500000.00000000
|
||||
|
||||
function StopThree {
|
||||
$CLI $B1ARGS stop > /dev/null 2>&1
|
||||
|
|
|
@ -262,6 +262,7 @@ public:
|
|||
}
|
||||
|
||||
virtual bool RequireRPCPassword() const { return false; }
|
||||
virtual bool SimplifiedRewards() const { return true; }
|
||||
virtual Network NetworkID() const { return CChainParams::REGTEST; }
|
||||
};
|
||||
static CRegTestParams regTestParams;
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
int SubsidyHalvingInterval() const { return nSubsidyHalvingInterval; }
|
||||
virtual const CBlock& GenesisBlock() const = 0;
|
||||
virtual bool RequireRPCPassword() const { return true; }
|
||||
virtual bool SimplifiedRewards() const { return false; }
|
||||
const string& DataDir() const { return strDataDir; }
|
||||
virtual Network NetworkID() const = 0;
|
||||
const vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
|
||||
|
|
|
@ -1203,11 +1203,11 @@ int64_t GetBlockValue(int nHeight, int64_t nFees, uint256 prevHash)
|
|||
int rand = generateMTRandom(seed, 999999);
|
||||
int rand1 = 0;
|
||||
|
||||
if(nHeight < 100000)
|
||||
if(nHeight < 100000 && !Params().SimplifiedRewards())
|
||||
{
|
||||
nSubsidy = (1 + rand) * COIN;
|
||||
}
|
||||
else if(nHeight < 145000)
|
||||
else if(nHeight < 145000 && !Params().SimplifiedRewards())
|
||||
{
|
||||
cseed_str = prevHash.ToString().substr(7,7);
|
||||
cseed = cseed_str.c_str();
|
||||
|
|
|
@ -473,10 +473,10 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
|||
return false;
|
||||
|
||||
//// debug print
|
||||
printf("DogecoinMiner:\n");
|
||||
printf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());
|
||||
LogPrintf("DogecoinMiner:\n");
|
||||
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());
|
||||
pblock->print();
|
||||
printf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue).c_str());
|
||||
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue).c_str());
|
||||
|
||||
// Found a solution
|
||||
{
|
||||
|
@ -504,7 +504,7 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
|||
|
||||
void static DogecoinMiner(CWallet *pwallet)
|
||||
{
|
||||
printf("DogecoinMiner started\n");
|
||||
LogPrintf("DogecoinMiner started\n");
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
RenameThread("dogecoin-miner");
|
||||
|
||||
|
@ -532,7 +532,7 @@ void static DogecoinMiner(CWallet *pwallet)
|
|||
CBlock *pblock = &pblocktemplate->block;
|
||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||
|
||||
printf("Running DogecoinMiner with %" PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(),
|
||||
LogPrintf("Running DogecoinMiner with %" PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(),
|
||||
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
|
||||
|
||||
//
|
||||
|
@ -571,6 +571,12 @@ void static DogecoinMiner(CWallet *pwallet)
|
|||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||
CheckWork(pblock, *pwallet, reservekey);
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
|
||||
// In regression test mode, stop mining after a block is found. This
|
||||
// allows developers to controllably generate a block on demand.
|
||||
if (Params().NetworkID() == CChainParams::REGTEST)
|
||||
throw boost::thread_interrupted();
|
||||
|
||||
break;
|
||||
}
|
||||
pblock->nNonce += 1;
|
||||
|
@ -632,7 +638,7 @@ void static DogecoinMiner(CWallet *pwallet)
|
|||
} }
|
||||
catch (boost::thread_interrupted)
|
||||
{
|
||||
printf("DogecoinMiner terminated\n");
|
||||
LogPrintf("DogecoinMiner terminated\n");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -664,4 +670,3 @@ void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue