11use distributed_verification:: KaniList ;
2- use std:: process:: Command ;
2+ use std:: { collections :: HashMap , process:: Command } ;
33
44mod utils;
5- use utils:: * ;
5+ use utils:: { assert_eq , * } ;
66
77#[ test]
88fn validate_kani_list_json ( ) -> Result < ( ) > {
99 let proofs = get_proofs ( "tests/proofs" ) ?;
1010
1111 for path in & proofs {
12- let kani_list = get_kani_list ( path. to_str ( ) . unwrap ( ) ) ;
1312 let file_stem = file_stem ( path) ;
1413 let list_path = format ! ( "kani_list/{file_stem}.txt" ) ;
1514 dbg ! ( & list_path) ;
15+
16+ let path = path. to_str ( ) . unwrap ( ) ;
17+ // run `kani list`
18+ let kani_list = get_kani_list ( path) ;
1619 expect_file ! [ list_path] . assert_debug_eq ( & kani_list) ;
20+
21+ // run `distributed_verification`
22+ let text = cmd ( & [ path] ) ;
23+ let v_ser_function: Vec < SerFunction > = serde_json:: from_str ( & text) . unwrap ( ) ;
24+ merge ( & kani_list, & v_ser_function) ;
1725 }
1826
1927 Ok ( ( ) )
@@ -33,3 +41,53 @@ fn get_kani_list(file: &str) -> KaniList {
3341 let file_json = std:: fs:: File :: open ( "kani-list.json" ) . unwrap ( ) ;
3442 serde_json:: from_reader ( file_json) . unwrap ( )
3543}
44+
45+ fn merge ( list : & KaniList , v_ser_fun : & [ SerFunction ] ) {
46+ // sanity check
47+ let totals = & list. totals ;
48+ assert_eq ! ( v_ser_fun. len( ) , totals. standard_harnesses + totals. contract_harnesses) ;
49+ assert_eq ! (
50+ list. standard_harnesses. values( ) . map( |s| s. len( ) ) . sum:: <usize >( ) ,
51+ totals. standard_harnesses
52+ ) ;
53+ assert_eq ! (
54+ list. contract_harnesses. values( ) . map( |s| s. len( ) ) . sum:: <usize >( ) ,
55+ totals. contract_harnesses
56+ ) ;
57+
58+ let map: HashMap < _ , _ > = v_ser_fun
59+ . iter ( )
60+ . enumerate ( )
61+ . map ( |( idx, f) | ( ( & * f. func . file , & * f. func . name ) , idx) )
62+ . collect ( ) ;
63+
64+ // check all standard proofs are in distributed-verification json
65+ for ( path, proofs) in & list. standard_harnesses {
66+ for proof in proofs {
67+ let key = ( path. as_str ( ) , proof. as_str ( ) ) ;
68+ let idx = map. get ( & key) . unwrap ( ) ;
69+ dbg ! ( idx) ;
70+ }
71+ }
72+
73+ // check all contract proofs are in distributed-verification json
74+ for ( path, proofs) in & list. contract_harnesses {
75+ for proof in proofs {
76+ let key = ( path. as_str ( ) , proof. as_str ( ) ) ;
77+ let idx = map. get ( & key) . unwrap ( ) ;
78+ dbg ! ( idx) ;
79+ }
80+ }
81+
82+ // douoble check
83+ for & ( path, proof) in map. keys ( ) {
84+ // FIXME: split standard and contract proofs if kind supported
85+ match list. standard_harnesses . get ( path) {
86+ Some ( set) => _ = set. get ( proof) . unwrap ( ) ,
87+ None => match list. contract_harnesses . get ( path) {
88+ Some ( set) => _ = set. get ( proof) . unwrap ( ) ,
89+ None => panic ! ( "{path} {proof} does not exist" ) ,
90+ } ,
91+ } ;
92+ }
93+ }
0 commit comments