tests: fix resume mock session registration and RDRAM sizing
Some checks failed
Rust / build-linux (linux-x86_64, X64, ubuntu-24.04, x86_64-unknown-linux-gnu) (pull_request) Failing after 2s
Rust / build-android (29.0.14206865, ubuntu-24.04, 33) (pull_request) Failing after 1s
Rust-lint / lint-linux (pull_request) Failing after 1s
Rust / build-linux (linux-aarch64, ARM64, ubuntu-24.04-arm, aarch64-unknown-linux-gnu) (pull_request) Has been cancelled
Rust / build-windows (windows-aarch64, woa64, windows-11-arm, aarch64-pc-windows-msvc) (pull_request) Has been cancelled
Rust / build-windows (windows-x86_64, win64, windows-2025, x86_64-pc-windows-msvc) (pull_request) Has been cancelled
Rust / build-macos (macos-aarch64, ARM64, aarch64-apple-darwin) (pull_request) Has been cancelled
Rust / Collect release artifacts (pull_request) Has been cancelled
Some checks failed
Rust / build-linux (linux-x86_64, X64, ubuntu-24.04, x86_64-unknown-linux-gnu) (pull_request) Failing after 2s
Rust / build-android (29.0.14206865, ubuntu-24.04, 33) (pull_request) Failing after 1s
Rust-lint / lint-linux (pull_request) Failing after 1s
Rust / build-linux (linux-aarch64, ARM64, ubuntu-24.04-arm, aarch64-unknown-linux-gnu) (pull_request) Has been cancelled
Rust / build-windows (windows-aarch64, woa64, windows-11-arm, aarch64-pc-windows-msvc) (pull_request) Has been cancelled
Rust / build-windows (windows-x86_64, win64, windows-2025, x86_64-pc-windows-msvc) (pull_request) Has been cancelled
Rust / build-macos (macos-aarch64, ARM64, aarch64-apple-darwin) (pull_request) Has been cancelled
Rust / Collect release artifacts (pull_request) Has been cancelled
mock_netplay built a one-player session for a local handle of 1, which the vendored ggrs fork rejects; register every handle (the local player at player_number, dummy Remote PeerIds elsewhere). The resume tests loaded saved states into fresh Device::new(false) instances whose RDRAM backing store is empty, tripping copy_from_slice in apply_savestate; pre-size the RDRAM like a real emulated device, matching the saved session's RDRAM.
This commit is contained in:
parent
79127f9240
commit
79e88dc821
@ -1219,13 +1219,24 @@ mod tests {
|
||||
.build();
|
||||
let reliable_channel = socket.take_channel(1).unwrap();
|
||||
|
||||
let session = ggrs::SessionBuilder::<GgrsConfig>::new()
|
||||
.with_num_players(1)
|
||||
.unwrap()
|
||||
.add_player(ggrs::PlayerType::Local, player_number)
|
||||
.unwrap()
|
||||
.start_p2p_session(TestSocket)
|
||||
let mut builder = ggrs::SessionBuilder::<GgrsConfig>::new()
|
||||
.with_num_players(player_number + 1)
|
||||
.unwrap();
|
||||
// GGRS requires every handle to be registered: the local player at
|
||||
// `player_number`, Remote placeholders (a dummy nil PeerId — the
|
||||
// socket never sends to it) for the rest.
|
||||
let dummy_peer: matchbox_socket::PeerId =
|
||||
serde_json::from_str("\"00000000-0000-0000-0000-000000000000\"")
|
||||
.expect("nil PeerId parses");
|
||||
for handle in 0..=player_number {
|
||||
let player_type = if handle == player_number {
|
||||
ggrs::PlayerType::Local
|
||||
} else {
|
||||
ggrs::PlayerType::Remote(dummy_peer)
|
||||
};
|
||||
builder = builder.add_player(player_type, handle).unwrap();
|
||||
}
|
||||
let session = builder.start_p2p_session(TestSocket).unwrap();
|
||||
|
||||
Netplay {
|
||||
disconnected: false,
|
||||
@ -1301,8 +1312,11 @@ mod tests {
|
||||
|
||||
// Peer loads the embedded savestate into a fresh device (no disk),
|
||||
// exactly like resume_session_peer: load_from_memory ->
|
||||
// load_savestate_from_data, then issue #5's frame reset.
|
||||
// load_savestate_from_data, then issue #5's frame reset. The RDRAM
|
||||
// backing store is pre-sized like a real emulated device, matching
|
||||
// the saved session's RDRAM.
|
||||
let mut peer_device = crate::device::Device::new(false);
|
||||
peer_device.rdram.mem.resize(0x800, 0);
|
||||
peer_device.netplay = Some(mock_netplay(1));
|
||||
apply_resume_state(&mut peer_device, &peer_save).expect("peer applies the state");
|
||||
|
||||
@ -1363,7 +1377,10 @@ mod tests {
|
||||
|
||||
// Fresh device stands in for the host's just-launched session; the
|
||||
// savestate was captured from a different Device instance above.
|
||||
// RDRAM is pre-sized like a real emulated device so the saved
|
||||
// session's RDRAM can be restored.
|
||||
let mut host_session = Device::new(false);
|
||||
host_session.rdram.mem.resize(0x800, 0);
|
||||
host_session.ui.game_hash = "DEADBEEF-C01DF00D".to_string();
|
||||
host_session.netplay = Some(mock_netplay(0));
|
||||
host_session.netplay.as_mut().unwrap().state_path = Some(path.clone());
|
||||
|
||||
Reference in New Issue
Block a user