Skip to content

Commit 809a8ab

Browse files
author
Braydon Fuller
committed
tests: expanded address index mempool testing
1 parent bd8328c commit 809a8ab

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

qa/rpc-tests/addressindex.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,25 +246,29 @@ def run_test(self):
246246
tx2 = CTransaction()
247247
tx2.vin = [CTxIn(COutPoint(int(unspent[1]["txid"], 16), unspent[1]["vout"]))]
248248
amount = unspent[1]["amount"] * 100000000
249-
tx2.vout = [CTxOut(amount, scriptPubKey3)]
249+
tx2.vout = [CTxOut(amount / 2, scriptPubKey3), CTxOut(amount / 2, scriptPubKey3)]
250250
tx2.rehash()
251251
signed_tx2 = self.nodes[2].signrawtransaction(binascii.hexlify(tx2.serialize()).decode("utf-8"))
252252
memtxid2 = self.nodes[2].sendrawtransaction(signed_tx2["hex"], True)
253253
time.sleep(2)
254254

255255
mempool = self.nodes[2].getaddressmempool({"addresses": [address3]})
256-
assert_equal(len(mempool), 2)
256+
assert_equal(len(mempool), 3)
257257
assert_equal(mempool[0]["txid"], memtxid1)
258-
assert_equal(mempool[1]["txid"], memtxid2)
259258
assert_equal(mempool[0]["address"], address3)
259+
assert_equal(mempool[0]["index"], 0)
260+
assert_equal(mempool[1]["txid"], memtxid2)
261+
assert_equal(mempool[1]["index"], 0)
262+
assert_equal(mempool[2]["txid"], memtxid2)
263+
assert_equal(mempool[2]["index"], 1)
260264

261265
self.nodes[2].generate(1);
262266
self.sync_all();
263267
mempool2 = self.nodes[2].getaddressmempool({"addresses": [address3]})
264268
assert_equal(len(mempool2), 0)
265269

266270
tx = CTransaction()
267-
tx.vin = [CTxIn(COutPoint(int(memtxid2, 16), 0))]
271+
tx.vin = [CTxIn(COutPoint(int(memtxid2, 16), 0)), CTxIn(COutPoint(int(memtxid2, 16), 1))]
268272
tx.vout = [CTxOut(amount - 10000, scriptPubKey2)]
269273
tx.rehash()
270274
self.nodes[2].importprivkey(privKey3)
@@ -273,9 +277,11 @@ def run_test(self):
273277
time.sleep(2)
274278

275279
mempool3 = self.nodes[2].getaddressmempool({"addresses": [address3]})
276-
assert_equal(len(mempool3), 1)
280+
assert_equal(len(mempool3), 2)
277281
assert_equal(mempool3[0]["prevtxid"], memtxid2)
278282
assert_equal(mempool3[0]["prevout"], 0)
283+
assert_equal(mempool3[1]["prevtxid"], memtxid2)
284+
assert_equal(mempool3[1]["prevout"], 1)
279285

280286
print "Passed\n"
281287

0 commit comments

Comments
 (0)