@@ -85,7 +85,7 @@ def run_test(self):
85
85
#######################################
86
86
# GETUTXOS: query an unspent outpoint #
87
87
#######################################
88
- json_request = '/checkmempool/ ' + txid + '-' + str (n )
88
+ json_request = '/' + txid + '-' + str (n )
89
89
json_string = http_get_call (url .hostname , url .port , '/rest/getutxos' + json_request + self .FORMAT_SEPARATOR + 'json' )
90
90
json_obj = json .loads (json_string )
91
91
@@ -100,7 +100,7 @@ def run_test(self):
100
100
#################################################
101
101
# GETUTXOS: now query an already spent outpoint #
102
102
#################################################
103
- json_request = '/checkmempool/ ' + vintx + '-0'
103
+ json_request = '/' + vintx + '-0'
104
104
json_string = http_get_call (url .hostname , url .port , '/rest/getutxos' + json_request + self .FORMAT_SEPARATOR + 'json' )
105
105
json_obj = json .loads (json_string )
106
106
@@ -117,7 +117,7 @@ def run_test(self):
117
117
##################################################
118
118
# GETUTXOS: now check both with the same request #
119
119
##################################################
120
- json_request = '/checkmempool/ ' + txid + '-' + str (n )+ '/' + vintx + '-0'
120
+ json_request = '/' + txid + '-' + str (n )+ '/' + vintx + '-0'
121
121
json_string = http_get_call (url .hostname , url .port , '/rest/getutxos' + json_request + self .FORMAT_SEPARATOR + 'json' )
122
122
json_obj = json .loads (json_string )
123
123
assert_equal (len (json_obj ['utxos' ]), 1 )
@@ -151,23 +151,48 @@ def run_test(self):
151
151
txid = self .nodes [0 ].sendtoaddress (self .nodes [1 ].getnewaddress (), 0.1 )
152
152
json_string = http_get_call (url .hostname , url .port , '/rest/tx/' + txid + self .FORMAT_SEPARATOR + "json" )
153
153
json_obj = json .loads (json_string )
154
- vintx = json_obj ['vin' ][0 ]['txid' ] # get the vin to later check for utxo (should be spent by then)
154
+ # get the spent output to later check for utxo (should be spent by then)
155
+ spent = '{}-{}' .format (json_obj ['vin' ][0 ]['txid' ], json_obj ['vin' ][0 ]['vout' ])
155
156
# get n of 0.1 outpoint
156
157
n = 0
157
158
for vout in json_obj ['vout' ]:
158
159
if vout ['value' ] == 0.1 :
159
160
n = vout ['n' ]
161
+ spending = '{}-{}' .format (txid , n )
160
162
161
- json_request = '/' + txid + '-' + str ( n )
163
+ json_request = '/' + spending
162
164
json_string = http_get_call (url .hostname , url .port , '/rest/getutxos' + json_request + self .FORMAT_SEPARATOR + 'json' )
163
165
json_obj = json .loads (json_string )
164
- assert_equal (len (json_obj ['utxos' ]), 0 ) #there should be an outpoint because it has just added to the mempool
166
+ assert_equal (len (json_obj ['utxos' ]), 0 ) #there should be no outpoint because it has just added to the mempool
165
167
166
- json_request = '/checkmempool/' + txid + '-' + str ( n )
168
+ json_request = '/checkmempool/' + spending
167
169
json_string = http_get_call (url .hostname , url .port , '/rest/getutxos' + json_request + self .FORMAT_SEPARATOR + 'json' )
168
170
json_obj = json .loads (json_string )
169
171
assert_equal (len (json_obj ['utxos' ]), 1 ) #there should be an outpoint because it has just added to the mempool
170
172
173
+ json_request = '/' + spent
174
+ json_string = http_get_call (url .hostname , url .port , '/rest/getutxos' + json_request + self .FORMAT_SEPARATOR + 'json' )
175
+ json_obj = json .loads (json_string )
176
+ assert_equal (len (json_obj ['utxos' ]), 1 ) #there should be an outpoint because its spending tx is not confirmed
177
+
178
+ json_request = '/checkmempool/' + spent
179
+ json_string = http_get_call (url .hostname , url .port , '/rest/getutxos' + json_request + self .FORMAT_SEPARATOR + 'json' )
180
+ json_obj = json .loads (json_string )
181
+ assert_equal (len (json_obj ['utxos' ]), 0 ) #there should be no outpoint because it has just spent (by mempool tx)
182
+
183
+ self .nodes [0 ].generate (1 )
184
+ self .sync_all ()
185
+
186
+ json_request = '/' + spending
187
+ json_string = http_get_call (url .hostname , url .port , '/rest/getutxos' + json_request + self .FORMAT_SEPARATOR + 'json' )
188
+ json_obj = json .loads (json_string )
189
+ assert_equal (len (json_obj ['utxos' ]), 1 ) #there should be an outpoint because it was mined
190
+
191
+ json_request = '/checkmempool/' + spending
192
+ json_string = http_get_call (url .hostname , url .port , '/rest/getutxos' + json_request + self .FORMAT_SEPARATOR + 'json' )
193
+ json_obj = json .loads (json_string )
194
+ assert_equal (len (json_obj ['utxos' ]), 1 ) #there should be an outpoint because it was mined
195
+
171
196
#do some invalid requests
172
197
json_request = '{"checkmempool'
173
198
response = http_post_call (url .hostname , url .port , '/rest/getutxos' + self .FORMAT_SEPARATOR + 'json' , json_request , True )
0 commit comments