33use {
44 mollusk_svm:: { result:: Check , Mollusk } ,
55 mollusk_svm_fuzz_fixture:: Fixture ,
6- solana_sdk:: {
7- account:: AccountSharedData , instruction:: Instruction , pubkey:: Pubkey , system_instruction,
8- system_program,
9- } ,
6+ solana_sdk:: { account:: AccountSharedData , pubkey:: Pubkey , system_instruction, system_program} ,
107 std:: path:: Path ,
118} ;
129
@@ -62,7 +59,12 @@ fn clear() {
6259 }
6360}
6461
65- fn mollusk_test ( ) -> ( Mollusk , Instruction , [ ( Pubkey , AccountSharedData ) ; 2 ] ) {
62+ #[ test]
63+ fn test_dump ( ) {
64+ clear ( ) ;
65+ std:: env:: set_var ( "EJECT_FUZZ_FIXTURES" , EJECT_FUZZ_FIXTURES ) ;
66+ std:: env:: set_var ( "EJECT_FUZZ_FIXTURES_JSON" , EJECT_FUZZ_FIXTURES ) ;
67+
6668 let sender = Pubkey :: new_unique ( ) ;
6769 let recipient = Pubkey :: new_unique ( ) ;
6870
@@ -72,7 +74,7 @@ fn mollusk_test() -> (Mollusk, Instruction, [(Pubkey, AccountSharedData); 2]) {
7274 let mollusk = Mollusk :: default ( ) ;
7375
7476 let instruction = system_instruction:: transfer ( & sender, & recipient, transfer_amount) ;
75- let accounts = [
77+ let accounts = vec ! [
7678 (
7779 sender,
7880 AccountSharedData :: new( base_lamports, 0 , & system_program:: id( ) ) ,
@@ -94,54 +96,51 @@ fn mollusk_test() -> (Mollusk, Instruction, [(Pubkey, AccountSharedData); 2]) {
9496
9597 mollusk. process_and_validate_instruction ( & instruction, & accounts, & checks) ;
9698
97- ( mollusk, instruction, accounts)
98- }
99-
100- #[ test]
101- fn test_dump ( ) {
102- clear ( ) ;
103-
104- // First try protobuf.
105- {
106- std:: env:: set_var ( "EJECT_FUZZ_FIXTURES" , EJECT_FUZZ_FIXTURES ) ;
107-
108- let ( mollusk, instruction, accounts) = mollusk_test ( ) ;
109-
110- let fixture_path = find_fixture ( & FileType :: Blob ) . unwrap ( ) ;
111- let fixture = Fixture :: load_from_blob_file ( & fixture_path) ;
112-
113- assert_eq ! ( fixture. input. compute_budget, mollusk. compute_budget) ;
114- assert_eq ! ( fixture. input. feature_set, mollusk. feature_set) ;
115- assert_eq ! ( fixture. input. sysvars. clock, mollusk. sysvars. clock) ;
116- assert_eq ! ( fixture. input. sysvars. rent, mollusk. sysvars. rent) ;
117- assert_eq ! ( fixture. input. program_id, instruction. program_id) ;
118- assert_eq ! ( fixture. input. instruction_accounts, instruction. accounts) ;
119- assert_eq ! ( fixture. input. instruction_data, instruction. data) ;
120- assert_eq ! ( fixture. input. accounts, accounts) ;
121-
122- std:: env:: remove_var ( "EJECT_FUZZ_FIXTURES" ) ;
123- }
124-
125- // Now try JSON.
126- {
127- std:: env:: set_var ( "EJECT_FUZZ_FIXTURES_JSON" , EJECT_FUZZ_FIXTURES ) ;
128-
129- let ( mollusk, instruction, accounts) = mollusk_test ( ) ;
130-
131- let fixture_path = find_fixture ( & FileType :: Json ) . unwrap ( ) ;
132- let fixture = Fixture :: load_from_json_file ( & fixture_path) ;
133-
134- assert_eq ! ( fixture. input. compute_budget, mollusk. compute_budget) ;
135- assert_eq ! ( fixture. input. feature_set, mollusk. feature_set) ;
136- assert_eq ! ( fixture. input. sysvars. clock, mollusk. sysvars. clock) ;
137- assert_eq ! ( fixture. input. sysvars. rent, mollusk. sysvars. rent) ;
138- assert_eq ! ( fixture. input. program_id, instruction. program_id) ;
139- assert_eq ! ( fixture. input. instruction_accounts, instruction. accounts) ;
140- assert_eq ! ( fixture. input. instruction_data, instruction. data) ;
141- assert_eq ! ( fixture. input. accounts, accounts) ;
142-
143- std:: env:: remove_var ( "EJECT_FUZZ_FIXTURES_JSON" ) ;
144- }
145-
99+ // Validate the protobuf fixture matches the test environment.
100+ let blob_fixture_path = find_fixture ( & FileType :: Blob ) . unwrap ( ) ;
101+ let blob_fixture = Fixture :: load_from_blob_file ( & blob_fixture_path) ;
102+ assert_eq ! ( blob_fixture. input. compute_budget, mollusk. compute_budget) ;
103+ assert_eq ! ( blob_fixture. input. feature_set, mollusk. feature_set) ;
104+ assert_eq ! ( blob_fixture. input. sysvars. clock, mollusk. sysvars. clock) ;
105+ assert_eq ! ( blob_fixture. input. sysvars. rent, mollusk. sysvars. rent) ;
106+ assert_eq ! ( blob_fixture. input. program_id, instruction. program_id) ;
107+ assert_eq ! (
108+ blob_fixture. input. instruction_accounts,
109+ instruction. accounts
110+ ) ;
111+ assert_eq ! ( blob_fixture. input. instruction_data, instruction. data) ;
112+ assert_eq ! ( blob_fixture. input. accounts, accounts) ;
113+
114+ // Validate the JSON fixture matches the test environment.
115+ let json_fixture_path = find_fixture ( & FileType :: Json ) . unwrap ( ) ;
116+ let json_fixture = Fixture :: load_from_json_file ( & json_fixture_path) ;
117+ assert_eq ! ( json_fixture. input. compute_budget, mollusk. compute_budget) ;
118+ assert_eq ! ( json_fixture. input. feature_set, mollusk. feature_set) ;
119+ assert_eq ! ( json_fixture. input. sysvars. clock, mollusk. sysvars. clock) ;
120+ assert_eq ! ( json_fixture. input. sysvars. rent, mollusk. sysvars. rent) ;
121+ assert_eq ! ( json_fixture. input. program_id, instruction. program_id) ;
122+ assert_eq ! (
123+ json_fixture. input. instruction_accounts,
124+ instruction. accounts
125+ ) ;
126+ assert_eq ! ( json_fixture. input. instruction_data, instruction. data) ;
127+ assert_eq ! ( json_fixture. input. accounts, accounts) ;
128+
129+ // Ensure both files have the same name.
130+ assert_eq ! (
131+ Path :: new( & blob_fixture_path)
132+ . file_stem( )
133+ . unwrap( )
134+ . to_str( )
135+ . unwrap( ) ,
136+ Path :: new( & json_fixture_path)
137+ . file_stem( )
138+ . unwrap( )
139+ . to_str( )
140+ . unwrap( )
141+ ) ;
142+
143+ std:: env:: remove_var ( "EJECT_FUZZ_FIXTURES" ) ;
144+ std:: env:: remove_var ( "EJECT_FUZZ_FIXTURES_JSON" ) ;
146145 clear ( ) ;
147146}
0 commit comments