From 54ce471c15fda9812d3cd7ef6222701b19892d30 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 12 Oct 2020 20:13:26 -0400 Subject: add assertion for empty record payload; make `load` async func --- tests/common/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 9ec9e8e..fa6c343 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,6 +1,7 @@ #[cfg(test)] #[allow(dead_code)] use async_trait::async_trait; +use futures::executor::block_on; use growthring::wal::{ WALBytes, WALFile, WALLoader, WALPos, WALRingId, WALStore, }; @@ -71,7 +72,7 @@ impl WALFile for WALFileEmul { Ok(()) } - fn read( + async fn read( &self, offset: WALPos, length: usize, @@ -513,13 +514,13 @@ impl PaintingSim { let mut rng = ::seed_from_u64(self.seed); let mut wal = - loader.load(WALStoreEmul::new(state, fgen.clone()), |_, _| { + block_on(loader.load(WALStoreEmul::new(state, fgen.clone()), |_, _| { if fgen.next_fail() { Err(()) } else { Ok(()) } - })?; + }))?; for _ in 0..self.n { let pss = (0..self.m) .map(|_| { @@ -616,7 +617,7 @@ impl PaintingSim { let mut last_idx = 0; let mut napplied = 0; canvas.clear_queued(); - wal.load( + block_on(wal.load( WALStoreEmul::new(state, Rc::new(ZeroFailGen)), |payload, ringid| { let s = PaintStrokes::from_bytes(&payload); @@ -625,7 +626,7 @@ impl PaintingSim { napplied += 1; Ok(()) }, - ) + )) .unwrap(); println!("last = {}/{}, applied = {}", last_idx, ops.len(), napplied); canvas.paint_all(); -- cgit v1.2.3