aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd <[email protected]>2021-08-11 14:01:42 -0500
committerRoss Nicoll <[email protected]>2021-08-17 08:51:18 +0100
commite90e8e5cba03639292b68d055fab08c57ef47d81 (patch)
treeb115d23064dce9238d88eb3501661842bac882a6
parentRemove relay-only rounding (diff)
downloaddiscoin-e90e8e5cba03639292b68d055fab08c57ef47d81.tar.xz
discoin-e90e8e5cba03639292b68d055fab08c57ef47d81.zip
Create feelimit.py test
Create feelimit.py test to verify the updated fee values now rounding has been eliminated.
-rwxr-xr-xqa/pull-tester/rpc-tests.py1
-rw-r--r--qa/rpc-tests/feelimit.py77
2 files changed, 78 insertions, 0 deletions
diff --git a/qa/pull-tester/rpc-tests.py b/qa/pull-tester/rpc-tests.py
index 71c7b5f20..c5528118e 100755
--- a/qa/pull-tester/rpc-tests.py
+++ b/qa/pull-tester/rpc-tests.py
@@ -156,6 +156,7 @@ testScripts = [
'import-rescan.py',
'harddustlimit.py',
'paytxfee.py',
+ 'feelimit.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',
diff --git a/qa/rpc-tests/feelimit.py b/qa/rpc-tests/feelimit.py
new file mode 100644
index 000000000..aef63564c
--- /dev/null
+++ b/qa/rpc-tests/feelimit.py
@@ -0,0 +1,77 @@
+#!/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.
+"""Fee limit QA test.
+# Tests nodes under fee limit, verifies fee rounding
+"""
+
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import *
+from decimal import Decimal
+
+class FeeLimitTest(BitcoinTestFramework):
+
+ def __init__(self):
+ super().__init__()
+ self.setup_clean_chain = True
+ self.num_nodes = 2
+
+ def setup_network(self, split=False):
+ self.nodes = []
+ self.nodes.append(start_node(0, self.options.tmpdir, []))
+ self.nodes.append(start_node(1, self.options.tmpdir, []))
+
+ connect_nodes_bi(self.nodes,0,1)
+
+ self.is_network_split=False
+ self.sync_all()
+
+ def run_test(self):
+ # mine some blocks
+ self.nodes[0].generate(101)
+ self.sync_all()
+
+ # Output address
+ addr_to = self.nodes[1].getnewaddress()
+ lower_fee_per_kb = Decimal("0.001")
+
+ # Force generating a transaction with 1.14.5-like fees by manually building the tx
+ utx = self.nodes[0].listunspent()[0]
+ inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']}]
+ outputs = { addr_to : utx['amount'] - Decimal("1.0") }
+ rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
+
+ # Work out how big this transaction would be, then change the output to match
+ tx_size = count_bytes(self.nodes[0].signrawtransaction(rawtx)['hex'])
+ fee = lower_fee_per_kb * (tx_size + 1) / Decimal("1000")
+ outputs = { addr_to : utx['amount'] - fee }
+ rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
+ signedtx = self.nodes[0].signrawtransaction(rawtx)
+ self.nodes[0].sendrawtransaction(signedtx["hex"])
+
+ # Sync all of the nodes
+ self.sync_all()
+
+ # Check if the TX made it to node 2
+ assert_equal(self.nodes[1].getmempoolinfo()['size'], 1)
+ assert_equal(self.nodes[0].getmempoolinfo()['size'], 1)
+
+ # Force generating a transaction with fees which are too low to relay
+ too_low_fee = lower_fee_per_kb * (tx_size - 4) / Decimal("1000")
+ utx = self.nodes[0].listunspent()[0]
+ inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']}]
+ outputs = { self.nodes[1].getnewaddress() : utx['amount'] - too_low_fee }
+ rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
+ signedtx = self.nodes[0].signrawtransaction(rawtx)
+ self.nodes[0].sendrawtransaction(signedtx["hex"])
+
+ # wait 10 seconds to sync mempools
+ time.sleep(10)
+
+ # Check the TX did not relay, so is only on node 0
+ assert_equal(self.nodes[1].getmempoolinfo()['size'], 1)
+ assert_equal(self.nodes[0].getmempoolinfo()['size'], 2)
+
+if __name__ == '__main__':
+ FeeLimitTest().main()