@@ -12,6 +12,7 @@ use hedera::{
1212 Status ,
1313 TokenCreateTransaction ,
1414 TokenId ,
15+ TokenInfoQuery ,
1516 TokenType ,
1617} ;
1718use time:: {
@@ -611,3 +612,59 @@ async fn royalty_fee() -> anyhow::Result<()> {
611612 account. delete ( & client) . await ?;
612613 Ok ( ( ) )
613614}
615+
616+ #[ tokio:: test]
617+ async fn auto_renew_account ( ) -> anyhow:: Result < ( ) > {
618+ let Some ( TestEnvironment { config : _, client } ) = setup_nonfree ( ) else {
619+ return Ok ( ( ) ) ;
620+ } ;
621+
622+ let account = Account :: create ( Hbar :: new ( 0 ) , & client) . await ?;
623+
624+ let token_id = TokenCreateTransaction :: new ( )
625+ . name ( "ffff" )
626+ . symbol ( "F" )
627+ . treasury_account_id ( account. id )
628+ . auto_renew_account_id ( account. id )
629+ . expiration_time ( OffsetDateTime :: now_utc ( ) + Duration :: minutes ( 5 ) )
630+ . sign ( account. key . clone ( ) )
631+ . execute ( & client)
632+ . await ?
633+ . get_receipt ( & client)
634+ . await ?
635+ . token_id
636+ . unwrap ( ) ;
637+
638+ let info = TokenInfoQuery :: new ( ) . token_id ( token_id) . execute ( & client) . await ?;
639+
640+ // auto renew account should be set to operator account
641+ assert_eq ! ( info. auto_renew_account. unwrap( ) , account. id) ;
642+ Ok ( ( ) )
643+ }
644+
645+ #[ tokio:: test]
646+ async fn autoset_auto_renew_account ( ) -> anyhow:: Result < ( ) > {
647+ let Some ( TestEnvironment { config : _, client } ) = setup_nonfree ( ) else {
648+ return Ok ( ( ) ) ;
649+ } ;
650+
651+ let account = Account :: create ( Hbar :: new ( 0 ) , & client) . await ?;
652+
653+ let token_id = TokenCreateTransaction :: new ( )
654+ . name ( "ffff" )
655+ . symbol ( "F" )
656+ . treasury_account_id ( account. id )
657+ . expiration_time ( OffsetDateTime :: now_utc ( ) + Duration :: minutes ( 5 ) )
658+ . sign ( account. key . clone ( ) )
659+ . execute ( & client)
660+ . await ?
661+ . get_receipt ( & client)
662+ . await ?
663+ . token_id
664+ . unwrap ( ) ;
665+
666+ let info = TokenInfoQuery :: new ( ) . token_id ( token_id) . execute ( & client) . await ?;
667+ // auto renew account should be set to operator account
668+ assert_eq ! ( info. auto_renew_account. unwrap( ) , client. get_operator_account_id( ) . unwrap( ) ) ;
669+ Ok ( ( ) )
670+ }
0 commit comments