feat(m5): client-server sync, offline queue and replay playback
This commit is contained in:
@@ -99,12 +99,12 @@ async fn create_match_and_play_a_turn() {
|
||||
let (status, body) = call(&app, req).await;
|
||||
assert_eq!(status, StatusCode::CREATED, "body: {body}");
|
||||
let match_id = body["match_id"].as_str().unwrap().to_string();
|
||||
let state_hash = body["state_hash"].as_u64().unwrap();
|
||||
let state_hash = body["state_hash"].as_str().unwrap().to_string();
|
||||
assert!(state.has_live_match(&match_id));
|
||||
|
||||
// Wrong expect_hash must be rejected.
|
||||
let turn = json!({
|
||||
"expect_hash": state_hash ^ 0xFF,
|
||||
"expect_hash": "ffffffffffffffff",
|
||||
"command": {"kind": "fire", "angle": 45000, "power": 65536, "w": 1}
|
||||
});
|
||||
let req = Request::builder()
|
||||
@@ -134,7 +134,7 @@ async fn create_match_and_play_a_turn() {
|
||||
assert_eq!(status, StatusCode::OK, "body: {body}");
|
||||
assert_eq!(body["accepted"], true);
|
||||
assert_eq!(body["turn"], 2);
|
||||
assert!(body["state_hash"].as_u64().unwrap() != state_hash);
|
||||
assert_ne!(body["state_hash"].as_str().unwrap(), state_hash);
|
||||
}
|
||||
|
||||
fn build_replay(seed: u64) -> ReplayV1 {
|
||||
@@ -175,7 +175,10 @@ async fn valid_replay_is_accepted() {
|
||||
let (status, body) = call(&app, req).await;
|
||||
assert_eq!(status, StatusCode::OK, "body: {body}");
|
||||
assert_eq!(body["valid"], true);
|
||||
assert_eq!(body["final_hash"].as_u64().unwrap(), replay.final_hash);
|
||||
assert_eq!(
|
||||
body["final_hash"].as_str().unwrap(),
|
||||
format!("{:016x}", replay.final_hash)
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user