macro_rules! assert_read_is {
($block_db:expr, $block_key:expr, $bytes:expr) => {
async {
if $block_db
.read($block_key)
.await
.map_err(|err| format!("Failed to read {:?} \n {err:?}", $block_key))?
.ok_or(format!("Failed to read {:?} \n Got None", $block_key))?
!= $bytes.as_ref()
{
Err(format!("Invalid read from {:?}", $block_key))
} else {
Ok(())
}
}
.await
.unwrap()
};
}
macro_rules! assert_read_is_none {
($block_db:expr, $block_key:expr) => {
async {
if $block_db
.read($block_key)
.await
.map_err(|err| format!("Failed to read {:?} \n {err:?}", $block_key))?
.is_some()
{
Err(format!("Invalid read from {:?}, expected None", $block_key))
} else {
Ok(())
}
}
.await
.unwrap();
};
}
pub(crate) use assert_read_is;
pub(crate) use assert_read_is_none;