1
+ (* * Testing
2
+ -------
3
+ Component: Mina base
4
+ Invocation: dune exec src/lib/mina_base/test/main.exe -- \
5
+ test '^zero vesting period$'
6
+ Subject: Test zero vesting period detection
7
+ *)
8
+
1
9
open Core_kernel
2
10
open Mina_base
3
11
4
- let % test_module " zero_vesting" =
5
- ( module struct
6
- let mk_zkapp_with_vesting_period n =
7
- sprintf
8
- {json|
12
+ let mk_zkapp_with_vesting_period n =
13
+ let res =
14
+ sprintf
15
+ {json|
9
16
{
10
17
" fee_payer" : {
11
18
" body" : {
12
19
" public_key" : " B62qkb7Sed1VVsogq7qXzi79JNx9MkcbRihwwuSphUtBiEFPNTQfzNR" ,
13
- " fee" : " 0.01 " ,
20
+ " fee" : " 2.0 " ,
14
21
" valid_until" : null,
15
22
" nonce" : " 0"
16
23
},
@@ -112,7 +119,25 @@ let%test_module "zero_vesting" =
112
119
" epoch_length" : [ " Ignore" ]
113
120
}
114
121
},
115
- " account" : [ " Accept" ],
122
+ " account" : {
123
+ " balance" : [ " Ignore" ],
124
+ " nonce" : [ " Ignore" ],
125
+ " receipt_chain_hash" : [ " Ignore" ],
126
+ " delegate" : [ " Ignore" ],
127
+ " state" : [
128
+ [ " Ignore" ],
129
+ [ " Ignore" ],
130
+ [ " Ignore" ],
131
+ [ " Ignore" ],
132
+ [ " Ignore" ],
133
+ [ " Ignore" ],
134
+ [ " Ignore" ],
135
+ [ " Ignore" ]
136
+ ],
137
+ " action_state" : [ " Ignore" ],
138
+ " proved_state" : [ " Ignore" ],
139
+ " is_new" : [ " Ignore" ]
140
+ },
116
141
" valid_while" : [ " Ignore" ]
117
142
},
118
143
" use_full_commitment" : true ,
@@ -202,7 +227,25 @@ let%test_module "zero_vesting" =
202
227
" epoch_length" : [ " Ignore" ]
203
228
}
204
229
},
205
- " account" : [ " Accept" ],
230
+ " account" : {
231
+ " balance" : [ " Ignore" ],
232
+ " nonce" : [ " Ignore" ],
233
+ " receipt_chain_hash" : [ " Ignore" ],
234
+ " delegate" : [ " Ignore" ],
235
+ " state" : [
236
+ [ " Ignore" ],
237
+ [ " Ignore" ],
238
+ [ " Ignore" ],
239
+ [ " Ignore" ],
240
+ [ " Ignore" ],
241
+ [ " Ignore" ],
242
+ [ " Ignore" ],
243
+ [ " Ignore" ]
244
+ ],
245
+ " action_state" : [ " Ignore" ],
246
+ " proved_state" : [ " Ignore" ],
247
+ " is_new" : [ " Ignore" ]
248
+ },
206
249
" valid_while" : [ " Ignore" ]
207
250
},
208
251
" use_full_commitment" : false ,
@@ -224,33 +267,37 @@ let%test_module "zero_vesting" =
224
267
}
225
268
226
269
| json}
227
- n
228
- |> Yojson.Safe. from_string |> Zkapp_command. of_yojson
229
- |> Result. ok_or_failwith
270
+ n
271
+ |> Yojson.Safe. from_string |> Zkapp_command. of_yojson
272
+ in
273
+ match res with
274
+ | Ppx_deriving_yojson_runtime.Result. Ok zkapp ->
275
+ zkapp
276
+ | Ppx_deriving_yojson_runtime.Result. Error err ->
277
+ failwith err
230
278
231
- let zkapp_zero_vesting_period = mk_zkapp_with_vesting_period 0
279
+ let zkapp_zero_vesting_period = mk_zkapp_with_vesting_period 0
232
280
233
- let % test " zero vesting period is error " =
234
- match
235
- User_command. check_well_formedness
236
- ~genesis_constants: Genesis_constants. for_unit_tests
237
- (Zkapp_command zkapp_zero_vesting_period)
238
- with
239
- | Error [ Zero_vesting_period ] ->
240
- true
241
- | Ok _ | Error _ ->
242
- false
281
+ let zero_vesting_period_is_error () =
282
+ match
283
+ User_command. check_well_formedness
284
+ ~genesis_constants: Genesis_constants. for_unit_tests
285
+ (Zkapp_command zkapp_zero_vesting_period)
286
+ with
287
+ | Error [ Zero_vesting_period ] ->
288
+ ()
289
+ | Ok _ | Error _ ->
290
+ assert false
243
291
244
- let zkapp_nonzero_vesting_period = mk_zkapp_with_vesting_period 1
292
+ let zkapp_nonzero_vesting_period = mk_zkapp_with_vesting_period 1
245
293
246
- let % test " nonzero vesting period is ok" =
247
- match
248
- User_command. check_well_formedness
249
- ~genesis_constants: Genesis_constants. for_unit_tests
250
- (Zkapp_command zkapp_nonzero_vesting_period)
251
- with
252
- | Ok () ->
253
- true
254
- | Error errs ->
255
- false
256
- end )
294
+ let nonzero_vesting_period_ok () =
295
+ match
296
+ User_command. check_well_formedness
297
+ ~genesis_constants: Genesis_constants. for_unit_tests
298
+ (Zkapp_command zkapp_nonzero_vesting_period)
299
+ with
300
+ | Ok () ->
301
+ ()
302
+ | Error _ ->
303
+ assert false
0 commit comments