File tree Expand file tree Collapse file tree
programs/sbf/rust/sysvar/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,6 +124,24 @@ pub fn process_instruction(
124124 assert_eq ! ( rent, sgs_rent) ;
125125 }
126126
127+ // Slot History
128+ {
129+ msg ! ( "SlotHistory identifier:" ) ;
130+ sysvar:: slot_history:: id ( ) . log ( ) ;
131+ // SlotHistory exceeds the default SBF heap, so inspecting without deserializing.
132+ // Its final `u64` field is `next_slot`.
133+ assert_eq ! ( accounts[ 8 ] . data_len( ) , solana_sysvar:: slot_history:: SIZE ) ;
134+ let data = accounts[ 8 ] . data . borrow ( ) ;
135+ let next_slot = u64:: from_le_bytes ( * data. last_chunk ( ) . unwrap ( ) ) ;
136+ assert_eq ! ( next_slot, Clock :: get( ) ?. slot) ;
137+ // Slot History is not stored in the runtime sysvar cache, so syscall
138+ // `sol_get_sysvar` does not support it.
139+ assert_eq ! (
140+ Err ( ProgramError :: UnsupportedSysvar ) ,
141+ sol_get_sysvar:: <SlotHistory >( 1 )
142+ ) ;
143+ }
144+
127145 Ok ( ( ) )
128146 }
129147 Some ( & 1 ) => {
You can’t perform that action at this time.
0 commit comments