Skip to content

Commit eae8919

Browse files
committed
test: replace bare asserts with assertion helpers in rpc_getdescriptoractivity.py
Replace 20 bare assert statements that use equality comparisons with assert_equal() for better failure diagnostics.
1 parent ca45461 commit eae8919

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

test/functional/rpc_getdescriptoractivity.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ def test_multiple_addresses(self, node, wallet):
111111
[a1] = [a for a in result['activity'] if a['output_spk']['address'] == addr_1]
112112
[a2] = [a for a in result['activity'] if a['output_spk']['address'] == addr_2]
113113

114-
assert a1['blockhash'] == blockhash
115-
assert a1['amount'] == 1.0
114+
assert_equal(a1['blockhash'], blockhash)
115+
assert_equal(a1['amount'], 1.0)
116116

117-
assert a2['blockhash'] == blockhash
118-
assert a2['amount'] == 2.0
117+
assert_equal(a2['blockhash'], blockhash)
118+
assert_equal(a2['amount'], 2.0)
119119

120120
def test_invalid_blockhash(self, node, wallet):
121121
self.log.info("Test that passing an invalid blockhash raises appropriate RPC error")
@@ -159,8 +159,8 @@ def test_confirmed_and_unconfirmed(self, node, wallet):
159159
assert_equal(len(activity), 2)
160160

161161
[confirmed] = [a for a in activity if a.get('blockhash') == blockhash]
162-
assert confirmed['txid'] == txid_1
163-
assert confirmed['height'] == node.getblockchaininfo()['blocks']
162+
assert_equal(confirmed['txid'], txid_1)
163+
assert_equal(confirmed['height'], node.getblockchaininfo()['blocks'])
164164

165165
[unconfirmed] = [a for a in activity if not a.get('blockhash')]
166166
assert 'blockhash' not in unconfirmed
@@ -185,15 +185,15 @@ def test_receive_then_spend(self, node, wallet):
185185

186186
assert_equal(len(result['activity']), 4)
187187

188-
assert result['activity'][1]['type'] == 'receive'
189-
assert result['activity'][1]['txid'] == sent1['txid']
190-
assert result['activity'][1]['blockhash'] == blockhash_1
188+
assert_equal(result['activity'][1]['type'], 'receive')
189+
assert_equal(result['activity'][1]['txid'], sent1['txid'])
190+
assert_equal(result['activity'][1]['blockhash'], blockhash_1)
191191

192-
assert result['activity'][2]['type'] == 'spend'
193-
assert result['activity'][2]['spend_txid'] == sent2['txid']
194-
assert result['activity'][2]['spend_vin'] == 0
195-
assert result['activity'][2]['prevout_txid'] == sent1['txid']
196-
assert result['activity'][2]['blockhash'] == blockhash_2
192+
assert_equal(result['activity'][2]['type'], 'spend')
193+
assert_equal(result['activity'][2]['spend_txid'], sent2['txid'])
194+
assert_equal(result['activity'][2]['spend_vin'], 0)
195+
assert_equal(result['activity'][2]['prevout_txid'], sent1['txid'])
196+
assert_equal(result['activity'][2]['blockhash'], blockhash_2)
197197

198198
# Test that reversing the blockorder yields the same result.
199199
assert_equal(result, node.getdescriptoractivity(
@@ -221,17 +221,17 @@ def test_no_address(self, node, wallet):
221221
a1 = result['activity'][0]
222222
a2 = result['activity'][1]
223223

224-
assert a1['type'] == "spend"
225-
assert a1['blockhash'] == blockhash
224+
assert_equal(a1['type'], "spend")
225+
assert_equal(a1['blockhash'], blockhash)
226226
# sPK lacks address.
227227
assert_equal(list(a1['prevout_spk'].keys()), ['asm', 'desc', 'hex', 'type'])
228-
assert a1['amount'] == no_addr_tx["fee"] + Decimal(no_addr_tx["tx"].vout[0].nValue) / COIN
228+
assert_equal(a1['amount'], no_addr_tx["fee"] + Decimal(no_addr_tx["tx"].vout[0].nValue) / COIN)
229229

230-
assert a2['type'] == "receive"
231-
assert a2['blockhash'] == blockhash
230+
assert_equal(a2['type'], "receive")
231+
assert_equal(a2['blockhash'], blockhash)
232232
# sPK lacks address.
233233
assert_equal(list(a2['output_spk'].keys()), ['asm', 'desc', 'hex', 'type'])
234-
assert a2['amount'] == Decimal(no_addr_tx["tx"].vout[0].nValue) / COIN
234+
assert_equal(a2['amount'], Decimal(no_addr_tx["tx"].vout[0].nValue) / COIN)
235235

236236
def test_required_args(self, node):
237237
self.log.info("Test that required arguments must be passed")

0 commit comments

Comments
 (0)