From: Ian Jackson Date: Sat, 27 Feb 2021 00:14:21 +0000 (+0000) Subject: apitest: resynch_pieces X-Git-Tag: otter-0.4.0~342 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=7dbb926edf93454d3b967531c3819b962cfa4fdf;p=otter.git apitest: resynch_pieces Signed-off-by: Ian Jackson --- diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index a2d79565..724a637c 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -221,6 +221,24 @@ impl Session { .send()?; ensure_eq!(resp.status(), 200); } + + #[throws(AE)] + fn resynch_pieces(&mut self) { + 'overall: loop { + let update = self.updates.recv()?; + let update = update.as_array().unwrap(); + let new_gen = &update[0]; + for ue in update[1].as_array().unwrap() { + let (k,v) = ue.as_object().unwrap().iter().next().unwrap(); + let got_cseq: RawClientSequence = match k.as_str() { + "Recorded" => v["cseq"].as_i64().unwrap().try_into().unwrap(), + "Log" => continue, + _ => throw!(anyhow!("unknown update: {}", ue)), + }; + if got_cseq == self.cseq { break 'overall } + } + } + } } impl Ctx { @@ -258,6 +276,8 @@ impl Ctx { session.api_piece_op(&self.su, &llm.id, "m", json![pos.0])?; } + session.resynch_pieces()?; + // xxx send api requests to move markers // run library-add again }