aboutsummaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
Diffstat (limited to 'qa')
-rwxr-xr-xqa/pull-tester/rpc-tests.py5
-rwxr-xr-xqa/rpc-tests/bumpfee.py7
-rwxr-xr-xqa/rpc-tests/p2p-acceptblock.py10
-rw-r--r--qa/rpc-tests/paytxfee.py82
-rw-r--r--qa/rpc-tests/test_framework/blocktools.py2
-rwxr-xr-xqa/rpc-tests/txn_doublespend.py50
6 files changed, 120 insertions, 36 deletions
diff --git a/qa/pull-tester/rpc-tests.py b/qa/pull-tester/rpc-tests.py
index fd78d3701..71c7b5f20 100755
--- a/qa/pull-tester/rpc-tests.py
+++ b/qa/pull-tester/rpc-tests.py
@@ -116,6 +116,7 @@ testScripts = [
'wallet-dump.py',
'listtransactions.py',
# vv Tests less than 60s vv
+ 'p2p-acceptblock.py',
'sendheaders.py',
'zapwallettxes.py',
'importmulti.py',
@@ -128,7 +129,7 @@ testScripts = [
'reindex.py',
# vv Tests less than 30s vv
'mempool_resurrect_test.py',
- #'txn_doublespend.py --mineblock',
+ 'txn_doublespend.py --mineblock',
'txn_clone.py',
'getchaintips.py',
'rest.py',
@@ -154,6 +155,7 @@ testScripts = [
# 'nulldummy.py',
'import-rescan.py',
'harddustlimit.py',
+ 'paytxfee.py',
# While fee bumping should work in Doge, these tests depend on free transactions, which we don't support.
# Disable until we can do a full rewrite of the tests (possibly upstream), or revise fee schedule, or something
'bumpfee.py',
@@ -191,7 +193,6 @@ testScriptsExt = [
'forknotify.py',
'invalidateblock.py',
'maxblocksinflight.py',
- 'p2p-acceptblock.py',
]
diff --git a/qa/rpc-tests/bumpfee.py b/qa/rpc-tests/bumpfee.py
index b23761b06..20a683922 100755
--- a/qa/rpc-tests/bumpfee.py
+++ b/qa/rpc-tests/bumpfee.py
@@ -210,9 +210,10 @@ def test_rebumping(rbf_node, dest_address):
# check that re-bumping the original tx fails, but bumping the bumper succeeds
rbf_node.settxfee(Decimal("10.00000000"))
rbfid = create_fund_sign_send(rbf_node, {dest_address: 7.00000000})
- bumped = rbf_node.bumpfee(rbfid, {"totalFee": 150000000})
- assert_raises_jsonrpc(-4, "already bumped", rbf_node.bumpfee, rbfid, {"totalFee": 2000})
- rbf_node.bumpfee(bumped["txid"], {"totalFee": 200000000})
+ bumped = rbf_node.bumpfee(rbfid, {"totalFee": 1050000000})
+ assert_raises_jsonrpc(-4, "already bumped", rbf_node.bumpfee, rbfid, {"totalFee": 11000})
+ rbf_node.bumpfee(bumped["txid"], {"totalFee": 1100000000})
+ rbf_node.settxfee(Decimal("0.00000000"))
def test_rebumping_not_replaceable(rbf_node, dest_address):
diff --git a/qa/rpc-tests/p2p-acceptblock.py b/qa/rpc-tests/p2p-acceptblock.py
index c6a3a2258..f7ade0696 100755
--- a/qa/rpc-tests/p2p-acceptblock.py
+++ b/qa/rpc-tests/p2p-acceptblock.py
@@ -39,7 +39,7 @@ The test:
it's missing an intermediate block.
Node1 should reorg to this longer chain.
-4b.Send 288 more blocks on the longer chain.
+4b.Send 1440 more blocks on the longer chain.
Node0 should process all but the last block (too far ahead in height).
Send all headers to Node1, and then send the last block in that chain.
Node1 should accept the block because it's coming from a whitelisted peer.
@@ -206,14 +206,14 @@ class AcceptBlockTest(BitcoinTestFramework):
assert_equal(self.nodes[1].getblockcount(), 3)
print("Successfully reorged to length 3 chain from whitelisted peer")
- # 4b. Now mine 288 more blocks and deliver; all should be processed but
+ # 4b. Now mine 1440 more blocks and deliver; all should be processed but
# the last (height-too-high) on node0. Node1 should process the tip if
# we give it the headers chain leading to the tip.
tips = blocks_h3
headers_message = msg_headers()
all_blocks = [] # node0's blocks
for j in range(2):
- for i in range(288):
+ for i in range(1440):
next_block = create_block(tips[j].sha256, create_coinbase(i + 4), tips[j].nTime+1)
next_block.solve()
if j==0:
@@ -224,7 +224,7 @@ class AcceptBlockTest(BitcoinTestFramework):
tips[j] = next_block
time.sleep(2)
- # Blocks 1-287 should be accepted, block 288 should be ignored because it's too far ahead
+ # Blocks 1-1439 should be accepted, block 1440 should be ignored because it's too far ahead
for x in all_blocks[:-1]:
self.nodes[0].getblock(x.hash)
assert_raises_jsonrpc(-1, "Block not found on disk", self.nodes[0].getblock, all_blocks[-1].hash)
@@ -270,7 +270,7 @@ class AcceptBlockTest(BitcoinTestFramework):
test_node.send_message(msg_block(blocks_h2f[0]))
test_node.sync_with_ping()
- assert_equal(self.nodes[0].getblockcount(), 290)
+ assert_equal(self.nodes[0].getblockcount(), 1442)
print("Successfully reorged to longer chain from non-whitelisted peer")
[ c.disconnect_node() for c in connections ]
diff --git a/qa/rpc-tests/paytxfee.py b/qa/rpc-tests/paytxfee.py
new file mode 100644
index 000000000..feec0c45c
--- /dev/null
+++ b/qa/rpc-tests/paytxfee.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python3
+# Copyright (c) 2021 The Dogecoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+"""PayTxFee QA test.
+
+# Tests wallet behavior of -paytxfee in relation to -mintxfee
+"""
+
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import *
+from decimal import Decimal
+
+class PayTxFeeTest(BitcoinTestFramework):
+
+ def __init__(self):
+ super().__init__()
+ self.setup_clean_chain = True
+ self.num_nodes = 4
+
+ def setup_nodes(self, split=False):
+ nodes = []
+
+ # node 0 has txindex to track txs
+ nodes.append(start_node(0, self.options.tmpdir,
+ ["-debug", '-txindex']))
+
+ # node 1 pays 0.1 DOGE on all txs due to implicit mintxfee = paytxfee
+ nodes.append(start_node(1, self.options.tmpdir,
+ ["-paytxfee=0.1", "-debug"]))
+
+ # node 2 will always pay 1 DOGE on all txs because of explicit mintxfee
+ nodes.append(start_node(2, self.options.tmpdir,
+ ["-mintxfee=1", "-paytxfee=0.1", "-debug"]))
+
+ # node 3 will always pay 0.1 DOGE on all txs despite explicit mintxfee of 0.01
+ nodes.append(start_node(3, self.options.tmpdir,
+ ["-mintxfee=0.01", "-paytxfee=0.1", "-debug"]))
+
+ return nodes
+
+ def run_test(self):
+
+ seed = 1000 # the amount to seed wallets with
+ amount = 995 # the amount to send back
+ targetAddress = self.nodes[0].getnewaddress()
+
+ # mine some blocks and prepare some coins
+ self.nodes[0].generate(102)
+ self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), seed)
+ self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), seed)
+ self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), seed)
+ self.nodes[0].generate(1)
+ self.sync_all()
+
+ # create transactions
+ txid1 = self.nodes[1].sendtoaddress(targetAddress, amount)
+ txid2 = self.nodes[2].sendtoaddress(targetAddress, amount)
+ txid3 = self.nodes[3].sendtoaddress(targetAddress, amount)
+ self.sync_all()
+
+ # make sure correct fees were paid
+ tx1 = self.nodes[0].getrawtransaction(txid1, True)
+ tx2 = self.nodes[0].getrawtransaction(txid2, True)
+ tx3 = self.nodes[0].getrawtransaction(txid3, True)
+
+ assert_equal(tx1['vout'][0]['value'] + tx1['vout'][1]['value'], Decimal("999.9"))
+ assert_equal(tx2['vout'][0]['value'] + tx2['vout'][1]['value'], Decimal("999"))
+ assert_equal(tx3['vout'][0]['value'] + tx3['vout'][1]['value'], Decimal("999.9"))
+
+ # mine a block
+ self.nodes[0].generate(1);
+ self.sync_all()
+
+ # make sure all fees were mined
+ block = self.nodes[0].getblock(self.nodes[0].getbestblockhash())
+ coinbaseTx = self.nodes[0].getrawtransaction(block['tx'][0], True)
+
+ assert_equal(coinbaseTx['vout'][0]['value'], Decimal("500001.2"))
+
+if __name__ == '__main__':
+ PayTxFeeTest().main()
diff --git a/qa/rpc-tests/test_framework/blocktools.py b/qa/rpc-tests/test_framework/blocktools.py
index 47a68f435..44ad2adb5 100644
--- a/qa/rpc-tests/test_framework/blocktools.py
+++ b/qa/rpc-tests/test_framework/blocktools.py
@@ -11,7 +11,7 @@ from .script import CScript, OP_TRUE, OP_CHECKSIG, OP_RETURN
def create_block(hashprev, coinbase, nTime=None):
block = CBlock()
# Dogecoin: Create a non-AuxPoW block but include chain ID
- block.nVersion = 0x620003
+ block.nVersion = 0x620004
if nTime is None:
import time
block.nTime = int(time.time()+600)
diff --git a/qa/rpc-tests/txn_doublespend.py b/qa/rpc-tests/txn_doublespend.py
index 5b9399dc5..46f8743e3 100755
--- a/qa/rpc-tests/txn_doublespend.py
+++ b/qa/rpc-tests/txn_doublespend.py
@@ -34,40 +34,40 @@ class TxnMallTest(BitcoinTestFramework):
# Assign coins to foo and bar accounts:
node0_address_foo = self.nodes[0].getnewaddress("foo")
- fund_foo_txid = self.nodes[0].sendfrom("", node0_address_foo, 7499970)
+ fund_foo_txid = self.nodes[0].sendfrom("", node0_address_foo, 7314000)
fund_foo_tx = self.nodes[0].gettransaction(fund_foo_txid)
node0_address_bar = self.nodes[0].getnewaddress("bar")
- fund_bar_txid = self.nodes[0].sendfrom("", node0_address_bar, 30)
+ fund_bar_txid = self.nodes[0].sendfrom("", node0_address_bar, 174000)
fund_bar_tx = self.nodes[0].gettransaction(fund_bar_txid)
assert_equal(self.nodes[0].getbalance(""),
- starting_balance - 1219 - 29 + fund_foo_tx["fee"] + fund_bar_tx["fee"])
+ starting_balance - 7314000 - 174000 + fund_foo_tx["fee"] + fund_bar_tx["fee"])
# Coins are sent to node1_address
node1_address = self.nodes[1].getnewaddress("from0")
- # First: use raw transaction API to send 7499960 DOGE to node1_address,
+ # First: use raw transaction API to send 7440000 DOGE to node1_address,
# but don't broadcast:
- doublespend_fee = Decimal('-2')
+ doublespend_fee = Decimal('-120')
rawtx_input_0 = {}
rawtx_input_0["txid"] = fund_foo_txid
- rawtx_input_0["vout"] = find_output(self.nodes[0], fund_foo_txid, 1219)
+ rawtx_input_0["vout"] = find_output(self.nodes[0], fund_foo_txid, 7314000)
rawtx_input_1 = {}
rawtx_input_1["txid"] = fund_bar_txid
- rawtx_input_1["vout"] = find_output(self.nodes[0], fund_bar_txid, 29)
+ rawtx_input_1["vout"] = find_output(self.nodes[0], fund_bar_txid, 174000)
inputs = [rawtx_input_0, rawtx_input_1]
change_address = self.nodes[0].getnewaddress()
outputs = {}
- outputs[node1_address] = 7499960
- outputs[change_address] = 7499998 - 1219 + doublespend_fee
+ outputs[node1_address] = 7440000
+ outputs[change_address] = 7488000 - 7440000 + doublespend_fee
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
doublespend = self.nodes[0].signrawtransaction(rawtx)
assert_equal(doublespend["complete"], True)
- # Create two spends using 1 50 BTC coin each
- txid1 = self.nodes[0].sendfrom("foo", node1_address, 7499960, 0)
- txid2 = self.nodes[0].sendfrom("bar", node1_address, 20, 0)
+ # Create two spends
+ txid1 = self.nodes[0].sendfrom("foo", node1_address, 240000, 0)
+ txid2 = self.nodes[0].sendfrom("bar", node1_address, 120000, 0)
# Have node0 mine a block:
if (self.options.mine_block):
@@ -78,7 +78,7 @@ class TxnMallTest(BitcoinTestFramework):
tx2 = self.nodes[0].gettransaction(txid2)
# Node0's balance should be starting balance, plus 500,000 DOGE for another
- # matured block, minus 7499960, minus 20, and minus transaction fees:
+ # matured block, minus 7499960, minus 120000, and minus transaction fees:
expected = starting_balance + fund_foo_tx["fee"] + fund_bar_tx["fee"]
if self.options.mine_block: expected += 500000
expected += tx1["amount"] + tx1["fee"]
@@ -86,8 +86,8 @@ class TxnMallTest(BitcoinTestFramework):
assert_equal(self.nodes[0].getbalance(), expected)
# foo and bar accounts should be debited:
- assert_equal(self.nodes[0].getbalance("foo", 0), 7499970+tx1["amount"]+tx1["fee"])
- assert_equal(self.nodes[0].getbalance("bar", 0), 30+tx2["amount"]+tx2["fee"])
+ assert_equal(self.nodes[0].getbalance("foo", 0), 7314000+tx1["amount"]+tx1["fee"])
+ assert_equal(self.nodes[0].getbalance("bar", 0), 174000+tx2["amount"]+tx2["fee"])
if self.options.mine_block:
assert_equal(tx1["confirmations"], 1)
@@ -119,28 +119,28 @@ class TxnMallTest(BitcoinTestFramework):
assert_equal(tx1["confirmations"], -2)
assert_equal(tx2["confirmations"], -2)
- # Node0's total balance should be starting balance, plus 100BTC for
- # two more matured blocks, minus 1240 for the double-spend, plus fees (which are
+ # Node0's total balance should be starting balance, plus 1000000 DOGE for
+ # two more matured blocks, minus 7440000 for the double-spend, plus fees (which are
# negative):
- expected = starting_balance + 1000000 - 7499960 + fund_foo_tx["fee"] + fund_bar_tx["fee"] + doublespend_fee
+ expected = starting_balance + 1000000 - 7440000 + fund_foo_tx["fee"] + fund_bar_tx["fee"] + doublespend_fee
assert_equal(self.nodes[0].getbalance(), expected)
assert_equal(self.nodes[0].getbalance("*"), expected)
# Final "" balance is starting_balance - amount moved to accounts - doublespend + subsidies +
# fees (which are negative)
- assert_equal(self.nodes[0].getbalance("foo"), 7499970-7499960)
- assert_equal(self.nodes[0].getbalance("bar"), 30)
+ assert_equal(self.nodes[0].getbalance("foo"), 7314000)
+ assert_equal(self.nodes[0].getbalance("bar"), 174000)
assert_equal(self.nodes[0].getbalance(""), starting_balance
- -1219
- - 29
- -1240
- + 100
+ -7314000
+ - 174000
+ -7440000
+ + 1000000
+ fund_foo_tx["fee"]
+ fund_bar_tx["fee"]
+ doublespend_fee)
# Node1's "from0" account balance should be just the doublespend:
- assert_equal(self.nodes[1].getbalance("from0"), 7499960)
+ assert_equal(self.nodes[1].getbalance("from0"), 7440000)
if __name__ == '__main__':
TxnMallTest().main()