From d0e8ceeb250ce362d7d9bf2c6e5c297c716259cc Mon Sep 17 00:00:00 2001 From: Determinant Date: Sat, 13 Jun 2020 15:20:39 -0400 Subject: ... --- tests/common/mod.rs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/common/mod.rs b/tests/common/mod.rs index d4645f9..b61233b 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -335,6 +335,10 @@ impl PaintStrokes { } } +impl growthring::wal::Record for PaintStrokes { + fn serialize(&self) -> WALBytes { self.to_bytes() } +} + #[test] fn test_paint_strokes() { let mut p = PaintStrokes::new(); @@ -548,22 +552,20 @@ impl PaintingSim { ) }) .collect::>(); - let payloads = - pss.iter().map(|e| e.to_bytes()).collect::>(); + let pss_ = pss.clone(); // write ahead - let rids = wal.grow(payloads); - assert_eq!(pss.len(), rids.len()); - let rids = rids + let rids = wal.grow(pss); + assert_eq!(rids.len(), self.m); + let recs = rids .into_iter() - .map(|r| futures::executor::block_on(r)) - .collect::>(); - // keep track of the operations - // grow could fail - for (ps, rid) in pss.iter().zip(rids.iter()) { - ops.push(ps.clone()); - ringid_map.insert((*rid)?, ops.len() - 1); - } - let rids = rids.into_iter().map(|r| r.unwrap()); + .zip(pss_.into_iter()) + .map(|(r, ps)| -> Result<_, _> { + ops.push(ps); + let (rec, rid) = futures::executor::block_on(r)?; + ringid_map.insert(rid, ops.len() - 1); + Ok((rec, rid)) + }) + .collect::, ()>>()?; // finish appending to WAL /* for rid in rids.iter() { @@ -571,7 +573,7 @@ impl PaintingSim { } */ // prepare data writes - for (ps, rid) in pss.into_iter().zip(rids.into_iter()) { + for (ps, rid) in recs.into_iter() { canvas.prepaint(&ps, &rid); } // run k ticks of the fine-grained scheduler -- cgit v1.2.3-70-g09d2