Skip to content

Commit f89b092

Browse files
jonasschnelligmaxwell
authored andcommitted
add rpc test for listunspents support for zero value txouts
1 parent 219953c commit f89b092

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

qa/rpc-tests/wallet.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,33 @@ def run_test (self):
151151

152152
assert(txid1 in self.nodes[3].getrawmempool())
153153

154+
#check if we can list zero value tx as available coins
155+
#1. create rawtx
156+
#2. hex-changed one output to 0.0
157+
#3. sign and send
158+
#4. check if recipient (node0) can list the zero value tx
159+
usp = self.nodes[1].listunspent()
160+
inputs = [{"txid":usp[0]['txid'], "vout":usp[0]['vout']}]
161+
outputs = {self.nodes[1].getnewaddress(): 49.998, self.nodes[0].getnewaddress(): 11.11}
162+
163+
rawTx = self.nodes[1].createrawtransaction(inputs, outputs).replace("c0833842", "00000000") #replace 11.11 with 0.0 (int32)
164+
decRawTx = self.nodes[1].decoderawtransaction(rawTx)
165+
signedRawTx = self.nodes[1].signrawtransaction(rawTx)
166+
decRawTx = self.nodes[1].decoderawtransaction(signedRawTx['hex'])
167+
zeroValueTxid= decRawTx['txid']
168+
sendResp = self.nodes[1].sendrawtransaction(signedRawTx['hex'])
169+
170+
self.sync_all()
171+
self.nodes[1].generate(1) #mine a block
172+
self.sync_all()
173+
174+
unspentTxs = self.nodes[0].listunspent() #zero value tx must be in listunspents output
175+
found = False
176+
for uTx in unspentTxs:
177+
if uTx['txid'] == zeroValueTxid:
178+
found = True
179+
assert_equal(uTx['amount'], Decimal('0.00000000'));
180+
assert(found)
154181

155182
#do some -walletbroadcast tests
156183
stop_nodes(self.nodes)

0 commit comments

Comments
 (0)