@@ -412,17 +412,27 @@ void test_simulation_reconciliation(float p_frame_confirmation_timespan) {
412412 // Run another 30 frames.
413413 test.do_test (30 );
414414
415- // Ensure it was able to reconcily in exactly 1 frame.
416- ASSERT_COND (test.peer1_desync_detected .size () == 1 );
417- ASSERT_COND (test.peer2_desync_detected .size () == 1 );
418-
419- // Make sure the reconciliation was successful.
420- // NOTE: 45 is a margin established basing on the `p_frame_confirmation_timespan`.
421- const NS::FrameIndex ensure_no_desync_after{ 45 };
422- test.assert_no_desync (ensure_no_desync_after, ensure_no_desync_after);
423-
424- // and despite that the simulations are correct.
425- test.assert_positions (ensure_no_desync_after, ensure_no_desync_after);
415+ if (p_frame_confirmation_timespan <= 0.0 ) {
416+ // Ensure it was able to reconcile right away.
417+ // With `p_frame_confirmation_timespan == 0` the server snapshot is
418+ // received before the doll process it, and since the doll is able to
419+ // apply the server's snapshot during the normal processing, the desync
420+ // is not even triggered.
421+ ASSERT_COND (test.peer1_desync_detected .size () == 0 );
422+ ASSERT_COND (test.peer2_desync_detected .size () == 0 );
423+ } else {
424+ // Ensure it was able to reconcile in exactly 1 frame.
425+ ASSERT_COND (test.peer1_desync_detected .size () == 1 );
426+ ASSERT_COND (test.peer2_desync_detected .size () == 1 );
427+
428+ // Make sure the reconciliation was successful.
429+ // NOTE: 45 is a margin established basing on the `p_frame_confirmation_timespan`.
430+ const NS::FrameIndex ensure_no_desync_after{ 45 };
431+ test.assert_no_desync (ensure_no_desync_after, ensure_no_desync_after);
432+
433+ // and despite that the simulations are correct.
434+ test.assert_positions (ensure_no_desync_after, ensure_no_desync_after);
435+ }
426436}
427437
428438void test_simulation_with_hiccups (TestDollSimulationStorePositions &test) {
@@ -433,7 +443,7 @@ void test_simulation_with_hiccups(TestDollSimulationStorePositions &test) {
433443 NS::FrameIndex controller_1_doll_frame_index = test.peer_2_scene .scene_sync ->get_controller_for_peer (test.peer_1_scene .get_peer ())->get_current_frame_index ();
434444 NS::FrameIndex controller_2_doll_frame_index = test.peer_1_scene .scene_sync ->get_controller_for_peer (test.peer_2_scene .get_peer ())->get_current_frame_index ();
435445
436- for (int i = 0 ; i < 10 ; i++) {
446+ for (int i = 0 ; i < 20 ; i++) {
437447 if (i % 2 == 0 ) {
438448 test.do_test (10 , false , true , false , true );
439449 } else {
@@ -635,10 +645,10 @@ void test_simulation_with_wrong_input() {
635645 test.assert_positions (NS::FrameIndex{ 0 }, NS::FrameIndex{ 0 });
636646
637647 // 2. Now introduce a desync on the server.
638- for (int test_count = 0 ; test_count < 5 ; test_count++) {
648+ for (int test_count = 0 ; test_count < 20 ; test_count++) {
639649 for (int i = 0 ; i < 3 ; i++) {
640- const NS::FrameIndex c1_assert_after = server_controller_1->get_current_frame_index () + 20 ;
641- const NS::FrameIndex c2_assert_after = server_controller_2->get_current_frame_index () + 20 ;
650+ const NS::FrameIndex c1_assert_after = server_controller_1->get_current_frame_index () + 40 ;
651+ const NS::FrameIndex c2_assert_after = server_controller_2->get_current_frame_index () + 40 ;
642652 const int c1_desync_vec_size = test.peer1_desync_detected .size ();
643653 const int c2_desync_vec_size = test.peer2_desync_detected .size ();
644654
@@ -656,11 +666,7 @@ void test_simulation_with_wrong_input() {
656666 test.assert_positions (c1_assert_after, c2_assert_after);
657667 }
658668
659- if (test_count == 1 ) {
660- test.network_properties .rtt_seconds = 0.1 ;
661- } else if (test_count == 2 ) {
662- test.network_properties .rtt_seconds = 0.0 ;
663- } else if (test_count == 3 ) {
669+ if (test_count % 2 == 0 ) {
664670 test.network_properties .rtt_seconds = 0.1 ;
665671 } else {
666672 test.network_properties .rtt_seconds = 0.0 ;
0 commit comments