1111 solana_account:: AccountSharedData ,
1212 solana_program:: pubkey:: Pubkey ,
1313 solana_program_test:: { processor, ProgramTest , ProgramTestContext } ,
14- solana_signer:: Signer ,
1514 solana_transaction:: versioned:: VersionedTransaction ,
1615 std:: { cell:: RefCell , sync:: Arc } ,
1716 tokio:: runtime:: Runtime ,
@@ -100,26 +99,22 @@ impl LiteCoverage {
10099 }
101100 }
102101
103- /// Sign with our payer while also using our latest blockhash.
104- async fn re_sign_tx (
102+ /// Register the transaction's recent blockhash into ProgramTestContext.
103+ /// This avoids the need to pre-sign with payer.
104+ async fn register_recent_blockhash_from_transaction (
105105 & self ,
106106 tx : & VersionedTransaction ,
107- ) -> LiteCoverageError < VersionedTransaction > {
108- // TODO tx must be resigned for all signers
107+ ) -> LiteCoverageError < ( ) > {
109108 let pt_context = self . get_program_test_context ( ) ;
110109 let ctx = pt_context
111110 . as_ref ( )
112111 . ok_or ( Box :: < dyn std:: error:: Error + Send + Sync > :: from (
113112 "Missing ProgramTestContext" ,
114113 ) ) ?;
115- let payer = ctx. payer . insecure_clone ( ) ;
116- let recent_blockhash = ctx. banks_client . get_latest_blockhash ( ) . await ?;
117-
118- let mut trans = tx. clone ( ) . into_legacy_transaction ( ) . unwrap ( ) ;
119- trans. message . recent_blockhash = recent_blockhash;
120- trans. message . account_keys [ 0 ] = payer. pubkey ( ) ;
121- trans. sign ( & [ & payer] , recent_blockhash) ;
122- Ok ( VersionedTransaction :: from ( trans) )
114+
115+ let trans = tx. clone ( ) . into_legacy_transaction ( ) . unwrap ( ) ;
116+ ctx. register_recent_blockhash ( & trans. message . recent_blockhash , None ) ;
117+ Ok ( ( ) )
123118 }
124119
125120 /// Send the transaction to the natively loaded SBF avatars already prepared for
@@ -133,7 +128,7 @@ impl LiteCoverage {
133128 for ( account_pubkey, account_data) in accounts {
134129 self . add_account ( account_pubkey, account_data) ;
135130 }
136- let re_signed_tx = self . re_sign_tx ( & tx) . await ?;
131+ self . register_recent_blockhash_from_transaction ( & tx) . await ?;
137132
138133 let pt_context = self . get_program_test_context ( ) ;
139134 let ctx =
@@ -144,7 +139,7 @@ impl LiteCoverage {
144139 ) ) ?;
145140 let res = ctx
146141 . banks_client
147- . process_transaction_with_metadata ( re_signed_tx )
142+ . process_transaction_with_metadata ( tx )
148143 . await ?;
149144
150145 log:: info!( "LiteCoverage transaction result: {:#?}" , res) ;
0 commit comments