summaryrefslogtreecommitdiff
path: root/tests/common
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2020-06-13 15:20:39 -0400
committerDeterminant <[email protected]>2020-06-13 15:20:39 -0400
commitd0e8ceeb250ce362d7d9bf2c6e5c297c716259cc (patch)
tree0a2d915d2c332c73e1fb1fa1eea2608936e26da9 /tests/common
parentf02152a1c3ff0123efd2076fd9190feb81107b8e (diff)
...
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common/mod.rs32
1 files changed, 17 insertions, 15 deletions
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::<Vec<PaintStrokes>>();
- let payloads =
- pss.iter().map(|e| e.to_bytes()).collect::<Vec<WALBytes>>();
+ 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::<Vec<_>>();
- // 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::<Result<Vec<_>, ()>>()?;
// 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