Skip to content

Commit 79a007b

Browse files
make compile-time test accounts lazy (#4186)
* make test account lazy * turning top level constants that uses test ledger to functions * turning top level constants that uses test ledger to functions
1 parent a0d2c69 commit 79a007b

31 files changed

+142
-148
lines changed

src/app/cli/src/tests/coda_batch_payment_test.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ let main () =
99
Async.Scheduler.set_record_backtraces true ;
1010
let logger = Logger.create () in
1111
let keypairs =
12-
List.map Test_genesis_ledger.accounts
12+
List.map
13+
(Lazy.force Test_genesis_ledger.accounts)
1314
~f:Test_genesis_ledger.keypair_of_account_record_exn
1415
in
1516
let largest_account_keypair =

src/app/cli/src/tests/coda_change_snark_worker_test.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ let main () =
6767
wait_for_snark_worker_proof new_block_pipe1 largest_public_key
6868
in
6969
let new_snark_worker =
70-
List.find_map_exn Test_genesis_ledger.accounts ~f:(fun (_, account) ->
70+
List.find_map_exn (Lazy.force Test_genesis_ledger.accounts)
71+
~f:(fun (_, account) ->
7172
let public_key = Account.public_key account in
7273
Option.some_if
7374
(not @@ Public_key.Compressed.equal largest_public_key public_key)

src/app/cli/src/tests/coda_delegation_test.ml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ include Heartbeat.Make ()
1010
let main () =
1111
let logger = Logger.create () in
1212
let num_block_producers = 3 in
13+
let accounts = Lazy.force Test_genesis_ledger.accounts in
1314
let snark_work_public_keys ndx =
14-
List.nth_exn Test_genesis_ledger.accounts ndx
15+
List.nth_exn accounts ndx
1516
|> fun (_, acct) -> Some (Account.public_key acct)
1617
in
1718
let%bind testnet =
@@ -23,7 +24,7 @@ let main () =
2324
(* keep CI alive *)
2425
Deferred.don't_wait_for (print_heartbeat logger) ;
2526
(* dump account info to log *)
26-
List.iteri Test_genesis_ledger.accounts ~f:(fun ndx ((_, acct) as record) ->
27+
List.iteri accounts ~f:(fun ndx ((_, acct) as record) ->
2728
let keypair = Test_genesis_ledger.keypair_of_account_record_exn record in
2829
Logger.info logger ~module_:__MODULE__ ~location:__LOC__
2930
"Account: $account_number"
@@ -38,15 +39,13 @@ let main () =
3839
@@ Account.public_key acct ) )
3940
; ("balance", `Int (Currency.Balance.to_int acct.balance)) ] ) ;
4041
(* second account is delegator; see genesis_ledger/test_delegation_ledger.ml *)
41-
let ((_, delegator_account) as delegator) =
42-
List.nth_exn Test_genesis_ledger.accounts 2
43-
in
42+
let ((_, delegator_account) as delegator) = List.nth_exn accounts 2 in
4443
let delegator_pubkey = Account.public_key delegator_account in
4544
let delegator_keypair =
4645
Test_genesis_ledger.keypair_of_account_record_exn delegator
4746
in
4847
(* zeroth account is delegatee *)
49-
let _, delegatee_account = List.nth_exn Test_genesis_ledger.accounts 0 in
48+
let _, delegatee_account = List.nth_exn accounts 0 in
5049
let delegatee_pubkey = Account.public_key delegatee_account in
5150
let worker = testnet.workers.(0) in
5251
(* setup readers for produced blocks by delegator, delegatee *)

src/app/cli/src/tests/coda_five_nodes_test.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let main () =
1010
let snark_work_public_keys = function
1111
| 0 ->
1212
Some
13-
( List.nth_exn Test_genesis_ledger.accounts 5
13+
( List.nth_exn (Lazy.force Test_genesis_ledger.accounts) 5
1414
|> snd |> Account.public_key )
1515
| _ ->
1616
None

src/app/cli/src/tests/coda_long_fork.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ let name = "coda-long-fork"
66
let main n waiting_time () =
77
let logger = Logger.create () in
88
let keypairs =
9-
List.map Test_genesis_ledger.accounts
9+
List.map
10+
(Lazy.force Test_genesis_ledger.accounts)
1011
~f:Test_genesis_ledger.keypair_of_account_record_exn
1112
in
1213
let snark_work_public_keys i =

src/app/cli/src/tests/coda_restarts_and_txns_holy_grail.ml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ let main n () =
88
let wait_time = Time.Span.of_min 2. in
99
assert (n > 1) ;
1010
let logger = Logger.create () in
11+
let accounts = Lazy.force Test_genesis_ledger.accounts in
1112
let snark_work_public_keys =
12-
Fn.const
13-
@@ Some
14-
( List.nth_exn Test_genesis_ledger.accounts 5
15-
|> snd |> Account.public_key )
13+
Fn.const @@ Some (List.nth_exn accounts 5 |> snd |> Account.public_key)
1614
in
1715
let block_production_keys n = if n < 3 then Some n else None in
1816
let%bind testnet =
@@ -22,8 +20,7 @@ let main n () =
2220
in
2321
(* SEND TXNS *)
2422
let keypairs =
25-
List.map Test_genesis_ledger.accounts
26-
~f:Test_genesis_ledger.keypair_of_account_record_exn
23+
List.map accounts ~f:Test_genesis_ledger.keypair_of_account_record_exn
2724
in
2825
let random_block_producer () = Random.int 2 + 1 in
2926
let random_non_block_producer () = Random.int 2 + 3 in

src/app/cli/src/tests/coda_shared_prefix_multiproducer_test.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ let name = "coda-shared-prefix-multiproducer-test"
77
let main n enable_payments () =
88
let logger = Logger.create () in
99
let keypairs =
10-
List.map Test_genesis_ledger.accounts
10+
List.map
11+
(Lazy.force Test_genesis_ledger.accounts)
1112
~f:Test_genesis_ledger.keypair_of_account_record_exn
1213
in
1314
let snark_work_public_keys i =

src/app/cli/src/tests/coda_shared_state_test.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ let main () =
88
let logger = Logger.create () in
99
let n = 2 in
1010
let keypairs =
11-
List.map Test_genesis_ledger.accounts
11+
List.map
12+
(Lazy.force Test_genesis_ledger.accounts)
1213
~f:Test_genesis_ledger.keypair_of_account_record_exn
1314
in
1415
let snark_work_public_keys i =

src/app/cli/src/tests/coda_txns_and_restart_non_producers.ml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ let name = "coda-txns-and-restart-non-producers"
77
let main () =
88
let wait_time = Time.Span.of_min 2. in
99
let logger = Logger.create () in
10+
let accounts = Lazy.force Test_genesis_ledger.accounts in
1011
let snark_work_public_keys =
11-
Fn.const
12-
@@ Some
13-
( List.nth_exn Test_genesis_ledger.accounts 5
14-
|> snd |> Account.public_key )
12+
Fn.const @@ Some (List.nth_exn accounts 5 |> snd |> Account.public_key)
1513
in
1614
let producers n = if n < 3 then Some n else None in
1715
let%bind testnet =
@@ -21,8 +19,7 @@ let main () =
2119
in
2220
(* send txns *)
2321
let keypairs =
24-
List.map Test_genesis_ledger.accounts
25-
~f:Test_genesis_ledger.keypair_of_account_record_exn
22+
List.map accounts ~f:Test_genesis_ledger.keypair_of_account_record_exn
2623
in
2724
let%bind () = after wait_time in
2825
Coda_worker_testnet.Payments.send_several_payments testnet ~node:0 ~keypairs

src/app/cli/src/tests/coda_worker.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ module T = struct
463463
in
464464
let block_production_keypair =
465465
Option.map block_production_key ~f:(fun i ->
466-
List.nth_exn Test_genesis_ledger.accounts i
466+
List.nth_exn (Lazy.force Test_genesis_ledger.accounts) i
467467
|> Test_genesis_ledger.keypair_of_account_record_exn )
468468
in
469469
let initial_block_production_keypairs =

0 commit comments

Comments
 (0)