aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/interface_rest.py39
1 files changed, 32 insertions, 7 deletions
diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py
index c6cb4c54cd..6f585f6825 100755
--- a/test/functional/interface_rest.py
+++ b/test/functional/interface_rest.py
@@ -85,7 +85,7 @@ class RESTTest (BitcoinTestFramework):
#######################################
# GETUTXOS: query an unspent outpoint #
#######################################
- json_request = '/checkmempool/'+txid+'-'+str(n)
+ json_request = '/'+txid+'-'+str(n)
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
@@ -100,7 +100,7 @@ class RESTTest (BitcoinTestFramework):
#################################################
# GETUTXOS: now query an already spent outpoint #
#################################################
- json_request = '/checkmempool/'+vintx+'-0'
+ json_request = '/'+vintx+'-0'
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
@@ -117,7 +117,7 @@ class RESTTest (BitcoinTestFramework):
##################################################
# GETUTXOS: now check both with the same request #
##################################################
- json_request = '/checkmempool/'+txid+'-'+str(n)+'/'+vintx+'-0'
+ json_request = '/'+txid+'-'+str(n)+'/'+vintx+'-0'
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
assert_equal(len(json_obj['utxos']), 1)
@@ -151,23 +151,48 @@ class RESTTest (BitcoinTestFramework):
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
json_string = http_get_call(url.hostname, url.port, '/rest/tx/'+txid+self.FORMAT_SEPARATOR+"json")
json_obj = json.loads(json_string)
- vintx = json_obj['vin'][0]['txid'] # get the vin to later check for utxo (should be spent by then)
+ # get the spent output to later check for utxo (should be spent by then)
+ spent = '{}-{}'.format(json_obj['vin'][0]['txid'], json_obj['vin'][0]['vout'])
# get n of 0.1 outpoint
n = 0
for vout in json_obj['vout']:
if vout['value'] == 0.1:
n = vout['n']
+ spending = '{}-{}'.format(txid, n)
- json_request = '/'+txid+'-'+str(n)
+ json_request = '/'+spending
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
- assert_equal(len(json_obj['utxos']), 0) #there should be an outpoint because it has just added to the mempool
+ assert_equal(len(json_obj['utxos']), 0) #there should be no outpoint because it has just added to the mempool
- json_request = '/checkmempool/'+txid+'-'+str(n)
+ json_request = '/checkmempool/'+spending
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
assert_equal(len(json_obj['utxos']), 1) #there should be an outpoint because it has just added to the mempool
+ json_request = '/'+spent
+ json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
+ json_obj = json.loads(json_string)
+ assert_equal(len(json_obj['utxos']), 1) #there should be an outpoint because its spending tx is not confirmed
+
+ json_request = '/checkmempool/'+spent
+ json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
+ json_obj = json.loads(json_string)
+ assert_equal(len(json_obj['utxos']), 0) #there should be no outpoint because it has just spent (by mempool tx)
+
+ self.nodes[0].generate(1)
+ self.sync_all()
+
+ json_request = '/'+spending
+ json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
+ json_obj = json.loads(json_string)
+ assert_equal(len(json_obj['utxos']), 1) #there should be an outpoint because it was mined
+
+ json_request = '/checkmempool/'+spending
+ json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
+ json_obj = json.loads(json_string)
+ assert_equal(len(json_obj['utxos']), 1) #there should be an outpoint because it was mined
+
#do some invalid requests
json_request = '{"checkmempool'
response = http_post_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request, True)