|
|
|
@ -89,8 +89,8 @@ class RESTTest (BitcoinTestFramework):
@@ -89,8 +89,8 @@ class RESTTest (BitcoinTestFramework):
|
|
|
|
|
###################################### |
|
|
|
|
# GETUTXOS: query a unspent outpoint # |
|
|
|
|
###################################### |
|
|
|
|
json_request = '{"checkmempool":true,"outpoints":[{"txid":"'+txid+'","n":'+str(n)+'}]}' |
|
|
|
|
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request) |
|
|
|
|
json_request = '/checkmempool/'+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) |
|
|
|
|
|
|
|
|
|
#check chainTip response |
|
|
|
@ -104,8 +104,8 @@ class RESTTest (BitcoinTestFramework):
@@ -104,8 +104,8 @@ class RESTTest (BitcoinTestFramework):
|
|
|
|
|
################################################ |
|
|
|
|
# GETUTXOS: now query a already spent outpoint # |
|
|
|
|
################################################ |
|
|
|
|
json_request = '{"checkmempool":true,"outpoints":[{"txid":"'+vintx+'","n":0}]}' |
|
|
|
|
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request) |
|
|
|
|
json_request = '/checkmempool/'+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) |
|
|
|
|
|
|
|
|
|
#check chainTip response |
|
|
|
@ -121,8 +121,8 @@ class RESTTest (BitcoinTestFramework):
@@ -121,8 +121,8 @@ class RESTTest (BitcoinTestFramework):
|
|
|
|
|
################################################## |
|
|
|
|
# GETUTXOS: now check both with the same request # |
|
|
|
|
################################################## |
|
|
|
|
json_request = '{"checkmempool":true,"outpoints":[{"txid":"'+txid+'","n":'+str(n)+'},{"txid":"'+vintx+'","n":0}]}' |
|
|
|
|
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request) |
|
|
|
|
json_request = '/checkmempool/'+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) |
|
|
|
|
assert_equal(json_obj['bitmap'], "10") |
|
|
|
@ -137,7 +137,6 @@ class RESTTest (BitcoinTestFramework):
@@ -137,7 +137,6 @@ class RESTTest (BitcoinTestFramework):
|
|
|
|
|
binaryRequest += pack("i", 0); |
|
|
|
|
|
|
|
|
|
bin_response = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'bin', binaryRequest) |
|
|
|
|
|
|
|
|
|
output = StringIO.StringIO() |
|
|
|
|
output.write(bin_response) |
|
|
|
|
output.seek(0) |
|
|
|
@ -163,13 +162,13 @@ class RESTTest (BitcoinTestFramework):
@@ -163,13 +162,13 @@ class RESTTest (BitcoinTestFramework):
|
|
|
|
|
if vout['value'] == 0.1: |
|
|
|
|
n = vout['n'] |
|
|
|
|
|
|
|
|
|
json_request = '{"checkmempool":false,"outpoints":[{"txid":"'+txid+'","n":'+str(n)+'}]}' |
|
|
|
|
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request) |
|
|
|
|
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) |
|
|
|
|
assert_equal(len(json_obj['utxos']), 0) #there should be a outpoint because it has just added to the mempool |
|
|
|
|
|
|
|
|
|
json_request = '{"checkmempool":true,"outpoints":[{"txid":"'+txid+'","n":'+str(n)+'}]}' |
|
|
|
|
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request) |
|
|
|
|
json_request = '/checkmempool/'+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) |
|
|
|
|
assert_equal(len(json_obj['utxos']), 1) #there should be a outpoint because it has just added to the mempool |
|
|
|
|
|
|
|
|
@ -182,21 +181,22 @@ class RESTTest (BitcoinTestFramework):
@@ -182,21 +181,22 @@ class RESTTest (BitcoinTestFramework):
|
|
|
|
|
response = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'bin', json_request, True) |
|
|
|
|
assert_equal(response.status, 500) #must be a 500 because we send a invalid bin request |
|
|
|
|
|
|
|
|
|
response = http_get_call(url.hostname, url.port, '/rest/getutxos/checkmempool'+self.FORMAT_SEPARATOR+'bin', '', True) |
|
|
|
|
assert_equal(response.status, 500) #must be a 500 because we send a invalid bin request |
|
|
|
|
|
|
|
|
|
#test limits |
|
|
|
|
json_request = '{"checkmempool":true,"outpoints":[' |
|
|
|
|
for x in range(0, 200): |
|
|
|
|
json_request += '{"txid":"'+txid+'","n":'+str(n)+'},' |
|
|
|
|
json_request = json_request.rstrip(",") |
|
|
|
|
json_request+="]}"; |
|
|
|
|
response = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request, True) |
|
|
|
|
json_request = '/checkmempool/' |
|
|
|
|
for x in range(0, 20): |
|
|
|
|
json_request += txid+'-'+str(n)+'/' |
|
|
|
|
json_request = json_request.rstrip("/") |
|
|
|
|
response = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json', '', True) |
|
|
|
|
assert_equal(response.status, 500) #must be a 500 because we exceeding the limits |
|
|
|
|
|
|
|
|
|
json_request = '{"checkmempool":true,"outpoints":[' |
|
|
|
|
for x in range(0, 90): |
|
|
|
|
json_request += '{"txid":"'+txid+'","n":'+str(n)+'},' |
|
|
|
|
json_request = json_request.rstrip(",") |
|
|
|
|
json_request+="]}"; |
|
|
|
|
response = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request, True) |
|
|
|
|
json_request = '/checkmempool/' |
|
|
|
|
for x in range(0, 15): |
|
|
|
|
json_request += txid+'-'+str(n)+'/' |
|
|
|
|
json_request = json_request.rstrip("/"); |
|
|
|
|
response = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json', '', True) |
|
|
|
|
assert_equal(response.status, 200) #must be a 500 because we exceeding the limits |
|
|
|
|
|
|
|
|
|
self.nodes[0].generate(1) #generate block to not affect upcomming tests |
|
|
|
|