@@ -66,6 +66,9 @@ let setup_time_offsets () = ()
6666
6767let heartbeat_flag = ref true
6868
69+ [%% inject
70+ " test_full_epoch" , test_full_epoch]
71+
6972let print_heartbeat logger =
7073 let rec loop () =
7174 if ! heartbeat_flag then (
@@ -217,14 +220,14 @@ let run_test () : unit Deferred.t =
217220 (Coda_lib. validated_transitions coda)
218221 ~f: ignore) ;
219222 let % bind () = Ivar. read @@ Coda_lib. initialization_finish_signal coda in
220- let wait_until_cond ~(f : Coda_lib.t -> bool ) ~(timeout : Float.t ) =
223+ let wait_until_cond ~(f : Coda_lib.t -> bool ) ~(timeout_min : Float.t ) =
221224 let rec go () =
222225 if f coda then return ()
223226 else
224227 let % bind () = after (Time.Span. of_sec 10. ) in
225228 go ()
226229 in
227- Deferred. any [after (Time.Span. of_min timeout ); go () ]
230+ Deferred. any [after (Time.Span. of_min timeout_min ); go () ]
228231 in
229232 let balance_change_or_timeout ~initial_receiver_balance receiver_pk =
230233 let cond t =
@@ -238,7 +241,7 @@ let run_test () : unit Deferred.t =
238241 | _ ->
239242 false
240243 in
241- wait_until_cond ~f: cond ~timeout : 3.
244+ wait_until_cond ~f: cond ~timeout_min : 3.
242245 in
243246 let assert_balance pk amount =
244247 match
@@ -374,11 +377,11 @@ let run_test () : unit Deferred.t =
374377 |> Participating_state. active_exn |> Protocol_state. consensus_state
375378 |> Consensus.Data.Consensus_state. blockchain_length
376379 in
377- let wait_for_proof_or_timeout timeout () =
380+ let wait_for_proof_or_timeout timeout_min () =
378381 let cond t = Option. is_some @@ Coda_lib. staged_ledger_ledger_proof t in
379- wait_until_cond ~f: cond ~timeout
382+ wait_until_cond ~f: cond ~timeout_min
380383 in
381- let test_multiple_payments accounts ~txn_count timeout =
384+ let test_multiple_payments accounts ~txn_count timeout_min =
382385 let balance_sheet =
383386 Public_key.Compressed.Map. of_alist_exn
384387 (List. map accounts
@@ -391,7 +394,7 @@ let run_test () : unit Deferred.t =
391394 Currency.Amount. of_int ((i + 1 ) * 10 ) )
392395 in
393396 (* After mining a few blocks and emitting a ledger_proof (by the parallel scan), check if the balances match *)
394- let % map () = wait_for_proof_or_timeout timeout () in
397+ let % map () = wait_for_proof_or_timeout timeout_min () in
395398 assert (Option. is_some @@ Coda_lib. staged_ledger_ledger_proof coda) ;
396399 Map. fold updated_balance_sheet ~init: () ~f: (fun ~key ~data () ->
397400 assert_balance key data ) ;
@@ -443,23 +446,40 @@ let run_test () : unit Deferred.t =
443446 else if with_snark then 15.
444447 else 7.
445448 in
449+ let wait_till_length =
450+ if medium_curves then Coda_numbers.Length. of_int 1
451+ else if test_full_epoch then
452+ (* Note: wait to produce (2*slots_per_epoch) blocks. This could take a while depending on what k and c are*)
453+ Coda_numbers.Length. of_int
454+ (Unsigned.UInt32. to_int
455+ Consensus.Constants. (
456+ Unsigned.UInt32. (mul slots_per_epoch (of_int 2 ))))
457+ else Coda_numbers.Length. of_int 5
458+ in
446459 let % map () =
447460 if with_snark then
448461 let accounts = List. take other_accounts 2 in
449462 let % bind blockchain_length' =
450463 test_multiple_payments accounts ~txn_count: 2 timeout_mins
451464 in
452- (* wait for a block after the ledger_proof is emitted*)
465+ (* wait for some blocks after the ledger_proof is emitted*)
453466 let % map () =
454467 wait_until_cond
455- ~f: (fun t -> blockchain_length t > blockchain_length')
456- ~timeout:
468+ ~f: (fun t ->
469+ blockchain_length t
470+ > Coda_numbers.Length. add blockchain_length' wait_till_length
471+ )
472+ ~timeout_min:
457473 ( Consensus.Constants. (
458- (delta + c) * Consensus.Constants. block_window_duration_ms)
474+ (delta + c)
475+ * ( block_window_duration_ms
476+ * (Coda_numbers.Length. to_int wait_till_length + 1 ) ))
459477 / 1000 / 60
460478 |> Float. of_int )
461479 in
462- assert (blockchain_length coda > blockchain_length')
480+ assert (
481+ blockchain_length coda
482+ > Coda_numbers.Length. add blockchain_length' wait_till_length )
463483 else if with_check then
464484 let % map _ =
465485 test_multiple_payments other_accounts
0 commit comments