File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
sdk/pinocchio/src/entrypoint Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -870,15 +870,27 @@ mod tests {
870870 assert_eq ! ( account_info. data_len( ) , i) ;
871871 }
872872
873+ // Last unique account.
874+ let duplicated = unsafe { accounts[ unique - 1 ] . assume_init_ref ( ) } ;
875+
873876 // Duplicated accounts should have the same `data_len` as the
874877 // last unique account.
875878 for account in accounts[ unique..] . iter ( ) {
876879 let account_info = unsafe { account. assume_init_ref ( ) } ;
877- let duplicated = unsafe { accounts[ unique - 1 ] . assume_init_ref ( ) } ;
878880
879881 assert_eq ! ( account_info. raw, duplicated. raw) ;
880882 assert_eq ! ( account_info. data_len( ) , duplicated. data_len( ) ) ;
883+
884+ let borrowed = account_info. try_borrow_mut_data ( ) . unwrap ( ) ;
885+ // Only one mutable borrow at the same time should be allowed
886+ // on the duplicated account.
887+ assert ! ( duplicated. try_borrow_mut_data( ) . is_err( ) ) ;
888+ drop ( borrowed) ;
881889 }
890+
891+ // There should not be any mutable borrow on the duplicated account
892+ // at this point.
893+ assert ! ( duplicated. try_borrow_mut_data( ) . is_ok( ) ) ;
882894 }
883895
884896 #[ test]
You can’t perform that action at this time.
0 commit comments