iroha icon indicating copy to clipboard operation
iroha copied to clipboard

Consider simplifying pattern for waiting for empty block in tests

Open dima74 opened this issue 9 months ago • 1 comments

Is there a good way to avoid this repeating pattern? At least for the block immediately following the genesis block, I think NetworkBuilder::start_blocking could imply that commit

Pattern:

// Waiting for empty block to be committed
std::thread::sleep(network.pipeline_time());

See https://github.com/hyperledger-iroha/iroha/pull/5320/commits/6fb19964009c2133c80457e0e30d6b36d7d9f7f8


Originally posted by @s8sato in https://github.com/hyperledger-iroha/iroha/pull/5320#discussion_r1971149320

dima74 avatar Mar 07 '25 12:03 dima74

NetworkPeer already provides a precise API exactly for this case: events, once, and once_block. For example:

https://github.com/hyperledger-iroha/iroha/blob/84c117a62983ec7c771353e90eac1f4c6da7edf9/crates/iroha/tests/extra_functional/restart_peer.rs#L44-L47

0x009922 avatar Mar 10 '25 07:03 0x009922