mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #15404: [test] Remove -txindex to start nodes
8e4b4f683a0b342cec24cd51b1e98433034ea2ea Address test todos by removing -txindex to nodes. Originally added when updating getrawtransaction to stop searching unspent utxos. (Amiti Uttarwar) Pull request description: Original todos added when removing getrawtransaction default behavior of searching unspent utxos. Tree-SHA512: d080953c3b0d2e5dca2265a15966dc25985a614c9cc86271ecd6276178ce428c85e262c24df92501695c32fed7beec0339b989f03cce91b57fb2efba201b7809
This commit is contained in:
parent
06925a1464
commit
7006a38ba5
@ -31,7 +31,8 @@ Supported API
|
|||||||
|
|
||||||
Given a transaction hash: returns a transaction in binary, hex-encoded binary, or JSON formats.
|
Given a transaction hash: returns a transaction in binary, hex-encoded binary, or JSON formats.
|
||||||
|
|
||||||
For full TX query capability, one must enable the transaction index via "txindex=1" command line / configuration option.
|
By default, this endpoint will only search the mempool.
|
||||||
|
To query for a confirmed transaction, enable the transaction index via "txindex=1" command line / configuration option.
|
||||||
|
|
||||||
#### Blocks
|
#### Blocks
|
||||||
`GET /rest/block/<BLOCK-HASH>.<bin|hex|json>`
|
`GET /rest/block/<BLOCK-HASH>.<bin|hex|json>`
|
||||||
|
@ -41,8 +41,7 @@ class RESTTest (BitcoinTestFramework):
|
|||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
self.num_nodes = 2
|
self.num_nodes = 2
|
||||||
# TODO: remove -txindex. Currently required for getrawtransaction call.
|
self.extra_args = [["-rest"], []]
|
||||||
self.extra_args = [["-rest", "-txindex"], []]
|
|
||||||
|
|
||||||
def test_rest_request(self, uri, http_method='GET', req_type=ReqType.JSON, body='', status=200, ret_type=RetType.JSON):
|
def test_rest_request(self, uri, http_method='GET', req_type=ReqType.JSON, body='', status=200, ret_type=RetType.JSON):
|
||||||
rest_uri = '/rest' + uri
|
rest_uri = '/rest' + uri
|
||||||
@ -86,15 +85,17 @@ class RESTTest (BitcoinTestFramework):
|
|||||||
|
|
||||||
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
|
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
self.nodes[1].generatetoaddress(1, not_related_address)
|
|
||||||
self.sync_all()
|
|
||||||
bb_hash = self.nodes[0].getbestblockhash()
|
|
||||||
|
|
||||||
assert_equal(self.nodes[1].getbalance(), Decimal("0.1"))
|
self.log.info("Test the /tx URI")
|
||||||
|
|
||||||
self.log.info("Load the transaction using the /tx URI")
|
|
||||||
|
|
||||||
json_obj = self.test_rest_request("/tx/{}".format(txid))
|
json_obj = self.test_rest_request("/tx/{}".format(txid))
|
||||||
|
assert_equal(json_obj['txid'], txid)
|
||||||
|
|
||||||
|
# Check hex format response
|
||||||
|
hex_response = self.test_rest_request("/tx/{}".format(txid), req_type=ReqType.HEX, ret_type=RetType.OBJ)
|
||||||
|
assert_greater_than_or_equal(int(hex_response.getheader('content-length')),
|
||||||
|
json_obj['size']*2)
|
||||||
|
|
||||||
spent = (json_obj['vin'][0]['txid'], json_obj['vin'][0]['vout']) # get the vin to later check for utxo (should be spent by then)
|
spent = (json_obj['vin'][0]['txid'], json_obj['vin'][0]['vout']) # get the vin to later check for utxo (should be spent by then)
|
||||||
# get n of 0.1 outpoint
|
# get n of 0.1 outpoint
|
||||||
n, = filter_output_indices_by_value(json_obj['vout'], Decimal('0.1'))
|
n, = filter_output_indices_by_value(json_obj['vout'], Decimal('0.1'))
|
||||||
@ -102,9 +103,14 @@ class RESTTest (BitcoinTestFramework):
|
|||||||
|
|
||||||
self.log.info("Query an unspent TXO using the /getutxos URI")
|
self.log.info("Query an unspent TXO using the /getutxos URI")
|
||||||
|
|
||||||
json_obj = self.test_rest_request("/getutxos/{}-{}".format(*spending))
|
self.nodes[1].generatetoaddress(1, not_related_address)
|
||||||
|
self.sync_all()
|
||||||
|
bb_hash = self.nodes[0].getbestblockhash()
|
||||||
|
|
||||||
|
assert_equal(self.nodes[1].getbalance(), Decimal("0.1"))
|
||||||
|
|
||||||
# Check chainTip response
|
# Check chainTip response
|
||||||
|
json_obj = self.test_rest_request("/getutxos/{}-{}".format(*spending))
|
||||||
assert_equal(json_obj['chaintipHash'], bb_hash)
|
assert_equal(json_obj['chaintipHash'], bb_hash)
|
||||||
|
|
||||||
# Make sure there is one utxo
|
# Make sure there is one utxo
|
||||||
@ -269,17 +275,6 @@ class RESTTest (BitcoinTestFramework):
|
|||||||
json_obj = self.test_rest_request("/headers/5/{}".format(bb_hash))
|
json_obj = self.test_rest_request("/headers/5/{}".format(bb_hash))
|
||||||
assert_equal(len(json_obj), 5) # now we should have 5 header objects
|
assert_equal(len(json_obj), 5) # now we should have 5 header objects
|
||||||
|
|
||||||
self.log.info("Test the /tx URI")
|
|
||||||
|
|
||||||
tx_hash = block_json_obj['tx'][0]['txid']
|
|
||||||
json_obj = self.test_rest_request("/tx/{}".format(tx_hash))
|
|
||||||
assert_equal(json_obj['txid'], tx_hash)
|
|
||||||
|
|
||||||
# Check hex format response
|
|
||||||
hex_response = self.test_rest_request("/tx/{}".format(tx_hash), req_type=ReqType.HEX, ret_type=RetType.OBJ)
|
|
||||||
assert_greater_than_or_equal(int(hex_response.getheader('content-length')),
|
|
||||||
json_obj['size']*2)
|
|
||||||
|
|
||||||
self.log.info("Test tx inclusion in the /mempool and /block URIs")
|
self.log.info("Test tx inclusion in the /mempool and /block URIs")
|
||||||
|
|
||||||
# Make 3 tx and mine them on node 1
|
# Make 3 tx and mine them on node 1
|
||||||
|
@ -99,11 +99,11 @@ class PSBTTest(BitcoinTestFramework):
|
|||||||
node1_addr = self.nodes[1].getnewaddress()
|
node1_addr = self.nodes[1].getnewaddress()
|
||||||
node2_addr = self.nodes[2].getnewaddress()
|
node2_addr = self.nodes[2].getnewaddress()
|
||||||
txid1 = self.nodes[0].sendtoaddress(node1_addr, 13)
|
txid1 = self.nodes[0].sendtoaddress(node1_addr, 13)
|
||||||
txid2 =self.nodes[0].sendtoaddress(node2_addr, 13)
|
txid2 = self.nodes[0].sendtoaddress(node2_addr, 13)
|
||||||
self.nodes[0].generate(6)
|
blockhash = self.nodes[0].generate(6)[0]
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
vout1 = find_output(self.nodes[1], txid1, 13)
|
vout1 = find_output(self.nodes[1], txid1, 13, blockhash=blockhash)
|
||||||
vout2 = find_output(self.nodes[2], txid2, 13)
|
vout2 = find_output(self.nodes[2], txid2, 13, blockhash=blockhash)
|
||||||
|
|
||||||
# Create a psbt spending outputs from nodes 1 and 2
|
# Create a psbt spending outputs from nodes 1 and 2
|
||||||
psbt_orig = self.nodes[0].createpsbt([{"txid":txid1, "vout":vout1}, {"txid":txid2, "vout":vout2}], {self.nodes[0].getnewaddress():25.999})
|
psbt_orig = self.nodes[0].createpsbt([{"txid":txid1, "vout":vout1}, {"txid":txid2, "vout":vout2}], {self.nodes[0].getnewaddress():25.999})
|
||||||
|
@ -42,7 +42,6 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
self.num_nodes = 3
|
self.num_nodes = 3
|
||||||
# TODO: remove -txindex. Currently required for getrawtransaction call.
|
|
||||||
self.extra_args = [["-txindex"], ["-txindex"], ["-txindex"]]
|
self.extra_args = [["-txindex"], ["-txindex"], ["-txindex"]]
|
||||||
|
|
||||||
def setup_network(self):
|
def setup_network(self):
|
||||||
|
@ -505,12 +505,12 @@ def force_finish_mnsync(node):
|
|||||||
# Transaction/Block functions
|
# Transaction/Block functions
|
||||||
#############################
|
#############################
|
||||||
|
|
||||||
def find_output(node, txid, amount):
|
def find_output(node, txid, amount, *, blockhash=None):
|
||||||
"""
|
"""
|
||||||
Return index to output of txid with value amount
|
Return index to output of txid with value amount
|
||||||
Raises exception if there is none.
|
Raises exception if there is none.
|
||||||
"""
|
"""
|
||||||
txdata = node.getrawtransaction(txid, 1)
|
txdata = node.getrawtransaction(txid, 1, blockhash)
|
||||||
for i in range(len(txdata["vout"])):
|
for i in range(len(txdata["vout"])):
|
||||||
if txdata["vout"][i]["value"] == amount:
|
if txdata["vout"][i]["value"] == amount:
|
||||||
return i
|
return i
|
||||||
|
@ -24,8 +24,7 @@ from test_framework.util import (
|
|||||||
class AbandonConflictTest(BitcoinTestFramework):
|
class AbandonConflictTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 2
|
self.num_nodes = 2
|
||||||
# TODO: remove -txindex. Currently required for getrawtransaction call.
|
self.extra_args = [["-minrelaytxfee=0.00001"], []]
|
||||||
self.extra_args = [["-minrelaytxfee=0.00001", "-txindex"], []]
|
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.nodes[1].generate(100)
|
self.nodes[1].generate(100)
|
||||||
|
@ -22,8 +22,7 @@ class WalletTest(BitcoinTestFramework):
|
|||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 4
|
self.num_nodes = 4
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
# TODO: remove -txindex. Currently required for getrawtransaction call.
|
self.extra_args = [['-usehd={:d}'.format(i%2==0)] for i in range(4)]
|
||||||
self.extra_args = [['-txindex', '-usehd={:d}'.format(i%2==0)] for i in range(4)]
|
|
||||||
|
|
||||||
def setup_network(self):
|
def setup_network(self):
|
||||||
self.add_nodes(4, self.extra_args)
|
self.add_nodes(4, self.extra_args)
|
||||||
|
Loading…
Reference in New Issue
Block a user