Skip to content

Commit 965c0c3

Browse files
author
MarcoFalke
committed
Merge #18420: test: listsinceblock block height checks
83e1d92 test: listsinceblock block height checks (Jon Atack) Pull request description: This is the second commit of #17535. This PR extends a listsinceblock test to check the new transaction 'blockheight' field recently added in #17437. It also cleans up code in the test function without changing or removing existing checks. ACKs for top commit: fjahr: tested ACK 83e1d92 ryanofsky: Code review ACK 83e1d92. Nice test improvements! Tree-SHA512: 92874b49a3bc0236500495f32dfcf683e1971ca3d4c51702c69ed4ce7dfce21273754f02f93d1243d73793701d9fdf49e14b149477cd249cbbd9e4e8d5bd49f8
2 parents 7e1fc03 + 83e1d92 commit 965c0c3

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

test/functional/wallet_listsinceblock.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,21 @@ def test_reorg(self):
111111
senttx = self.nodes[2].sendtoaddress(self.nodes[0].getnewaddress(), 1)
112112

113113
# generate on both sides
114-
lastblockhash = self.nodes[1].generate(6)[5]
115-
self.nodes[2].generate(7)
116-
self.log.debug('lastblockhash={}'.format(lastblockhash))
114+
nodes1_last_blockhash = self.nodes[1].generate(6)[-1]
115+
nodes2_first_blockhash = self.nodes[2].generate(7)[0]
116+
self.log.debug("nodes[1] last blockhash = {}".format(nodes1_last_blockhash))
117+
self.log.debug("nodes[2] first blockhash = {}".format(nodes2_first_blockhash))
117118

118119
self.sync_all(self.nodes[:2])
119120
self.sync_all(self.nodes[2:])
120121

121122
self.join_network()
122123

123-
# listsinceblock(lastblockhash) should now include tx, as seen from nodes[0]
124-
lsbres = self.nodes[0].listsinceblock(lastblockhash)
125-
found = False
126-
for tx in lsbres['transactions']:
127-
if tx['txid'] == senttx:
128-
found = True
129-
break
130-
assert found
124+
# listsinceblock(nodes1_last_blockhash) should now include tx as seen from nodes[0]
125+
# and return the block height which listsinceblock now exposes since a5e7795.
126+
transactions = self.nodes[0].listsinceblock(nodes1_last_blockhash)['transactions']
127+
found = next(tx for tx in transactions if tx['txid'] == senttx)
128+
assert_equal(found['blockheight'], self.nodes[0].getblockheader(nodes2_first_blockhash)['height'])
131129

132130
def test_double_spend(self):
133131
'''

0 commit comments

Comments
 (0)