@@ -1788,7 +1788,17 @@ impl Env {
17881788 ///
17891789 /// Used to write or read contract data, or take other actions in tests for
17901790 /// setting up tests or asserting on internal state.
1791- pub fn as_contract_with_func < T > ( & self , id : & Address , func : & crate :: Symbol , f : impl FnOnce ( ) -> T ) -> T {
1791+ ///
1792+ /// Unlike [`as_contract`][Self::as_contract], `func` is recorded as the
1793+ /// current contract function for authorization. This lets
1794+ /// [`mock_auths`][Self::mock_auths] and [`auths`][Self::auths] observe the
1795+ /// same function name that [`Address::require_auth`] uses.
1796+ pub fn as_contract_with_func < T > (
1797+ & self ,
1798+ id : & Address ,
1799+ func : & crate :: Symbol ,
1800+ f : impl FnOnce ( ) -> T ,
1801+ ) -> T {
17921802 let id = id. contract_id ( ) ;
17931803 let mut t: Option < T > = None ;
17941804 self . env_impl
@@ -1886,6 +1896,11 @@ impl Env {
18861896 ///
18871897 /// Used to write or read contract data, or take other actions in tests for
18881898 /// setting up tests or asserting on internal state.
1899+ ///
1900+ /// Unlike [`try_as_contract`][Self::try_as_contract], `func` is recorded as
1901+ /// the current contract function for authorization. This lets
1902+ /// [`mock_auths`][Self::mock_auths] and [`auths`][Self::auths] observe the
1903+ /// same function name that [`Address::require_auth`] uses.
18891904 pub fn try_as_contract_with_func < T , E > (
18901905 & self ,
18911906 id : & Address ,
@@ -1898,10 +1913,12 @@ impl Env {
18981913 {
18991914 let id = id. contract_id ( ) ;
19001915 let mut t: Option < T > = None ;
1901- let result = self . env_impl . try_with_test_contract_frame ( id, func. to_symbol_val ( ) , || {
1902- t = Some ( f ( ) ) ;
1903- Ok ( ( ) . into ( ) )
1904- } ) ;
1916+ let result = self
1917+ . env_impl
1918+ . try_with_test_contract_frame ( id, func. to_symbol_val ( ) , || {
1919+ t = Some ( f ( ) ) ;
1920+ Ok ( ( ) . into ( ) )
1921+ } ) ;
19051922
19061923 match result {
19071924 Ok ( _) => Ok ( t. unwrap ( ) ) ,
0 commit comments