()
| 133 | block_hash_size = 32 |
| 134 | |
| 135 | async def async_routine(): |
| 136 | ctx, mining = await make_mining_ctx(self) |
| 137 | blockref = await mining.getTip(ctx) |
| 138 | current_block_height = self.nodes[0].getchaintips()[0]["height"] |
| 139 | assert_equal(blockref.result.height, current_block_height) |
| 140 | |
| 141 | self.log.debug("Mine a block") |
| 142 | newblockref = (await wait_and_do( |
| 143 | mining.waitTipChanged(ctx, blockref.result.hash, self.default_ipc_timeout), |
| 144 | lambda: self.generate(self.nodes[0], 1))).result |
| 145 | assert_equal(len(newblockref.hash), block_hash_size) |
| 146 | assert_equal(newblockref.height, current_block_height + 1) |
| 147 | self.log.debug("Wait for timeout") |
| 148 | oldblockref = (await mining.waitTipChanged(ctx, newblockref.hash, self.default_ipc_timeout)).result |
| 149 | assert_equal(len(newblockref.hash), block_hash_size) |
| 150 | assert_equal(oldblockref.hash, newblockref.hash) |
| 151 | assert_equal(oldblockref.height, newblockref.height) |
| 152 | |
| 153 | self.log.debug("interrupt() should abort waitTipChanged()") |
| 154 | async def wait_for_tip(): |
| 155 | long_timeout = max(self.default_ipc_timeout, 60000.0) # at least 1 minute |
| 156 | result = (await mining.waitTipChanged(ctx, newblockref.hash, long_timeout)).result |
| 157 | # Unlike a timeout, interrupt() returns an empty BlockRef. |
| 158 | assert_equal(len(result.hash), 0) |
| 159 | await wait_and_do(wait_for_tip(), mining.interrupt()) |
| 160 | |
| 161 | asyncio.run(capnp.run(async_routine())) |
| 162 |
nothing calls this directly
no test coverage detected