From c90916699a6b9c1e2b38cfb088005ac2ca193a4d Mon Sep 17 00:00:00 2001 From: Jannis Froese Date: Mon, 2 Jun 2014 21:41:57 +0200 Subject: [PATCH] Fix bash based rpc tests --- qa/rpc-tests/conflictedbalance.sh | 21 +++++++++--------- qa/rpc-tests/txnmall.sh | 25 ++++++++++----------- qa/rpc-tests/util.sh | 3 ++- qa/rpc-tests/wallet.sh | 35 +++++++++++++++--------------- qa/rpc-tests/walletbackup.sh | 36 +++++++++++++++---------------- 5 files changed, 61 insertions(+), 59 deletions(-) diff --git a/qa/rpc-tests/conflictedbalance.sh b/qa/rpc-tests/conflictedbalance.sh index 849ad31fb..7873c0c65 100755 --- a/qa/rpc-tests/conflictedbalance.sh +++ b/qa/rpc-tests/conflictedbalance.sh @@ -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 diff --git a/qa/rpc-tests/txnmall.sh b/qa/rpc-tests/txnmall.sh index bd36967a6..b5732127a 100755 --- a/qa/rpc-tests/txnmall.sh +++ b/qa/rpc-tests/txnmall.sh @@ -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 diff --git a/qa/rpc-tests/util.sh b/qa/rpc-tests/util.sh index 1e7bd6a7e..6b327050e 100644 --- a/qa/rpc-tests/util.sh +++ b/qa/rpc-tests/util.sh @@ -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 diff --git a/qa/rpc-tests/wallet.sh b/qa/rpc-tests/wallet.sh index 98532fa85..a4caf0dab 100755 --- a/qa/rpc-tests/wallet.sh +++ b/qa/rpc-tests/wallet.sh @@ -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 diff --git a/qa/rpc-tests/walletbackup.sh b/qa/rpc-tests/walletbackup.sh index 744467098..25c584102 100755 --- a/qa/rpc-tests/walletbackup.sh +++ b/qa/rpc-tests/walletbackup.sh @@ -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