@@ -69,54 +69,10 @@ macro_rules! get_account {
6969}
7070
7171#[ allow( dead_code) ]
72- pub async fn print_log_messages ( rpc_client : & RpcClient , signature : & Signature ) {
73- const MAX_RETRIES : usize = 5 ;
74- let mut retries = MAX_RETRIES ;
75- let tx = loop {
76- match rpc_client
77- . get_transaction_with_config (
78- signature,
79- RpcTransactionConfig {
80- commitment : Some ( CommitmentConfig :: confirmed ( ) ) ,
81- max_supported_transaction_version : Some ( 0 ) ,
82- ..Default :: default ( )
83- } ,
84- )
85- . await
86- {
87- Ok ( tx) => break tx,
88- Err ( err) => {
89- log:: error!( "Failed to get transaction: {}" , err) ;
90- retries -= 1 ;
91- if retries == 0 {
92- panic ! (
93- "Failed to get transaction after {} retries" ,
94- MAX_RETRIES
95- ) ;
96- }
97- tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 100 ) )
98- . await ;
99- }
100- } ;
101- } ;
102- let logs = tx
103- . transaction
104- . meta
105- . as_ref ( )
106- . unwrap ( )
107- . log_messages
108- . clone ( )
109- . unwrap_or_else ( Vec :: new) ;
110-
111- println ! ( "logs: {:#?}" , logs) ;
112- }
113-
114- #[ allow( dead_code) ]
115- pub async fn tx_logs_contain (
72+ pub async fn fetch_tx_logs (
11673 rpc_client : & RpcClient ,
11774 signature : & Signature ,
118- needle : & str ,
119- ) -> bool {
75+ ) -> Vec < String > {
12076 // NOTE: we encountered the following error a few times which makes tests fail for the
12177 // wrong reason:
12278 // Error {
@@ -156,25 +112,40 @@ pub async fn tx_logs_contain(
156112 }
157113 } ;
158114 } ;
159- let logs = tx
160- . transaction
115+ tx. transaction
161116 . meta
162117 . as_ref ( )
163118 . unwrap ( )
164119 . log_messages
165120 . clone ( )
166- . unwrap_or_else ( Vec :: new) ;
167- logs. iter ( ) . any ( |log| {
168- // Lots of existing tests pass "CommitState" as needle argument to this function, but since now CommitTask
169- // could invoke CommitState or CommitDiff depending on the size of the account, we also look for "CommitDiff"
170- // in the logs when needle == CommitState. It's easier to make this little adjustment here than computing
171- // the decision and passing either CommitState or CommitDiff from the tests themselves.
172- if needle == "CommitState" {
173- log. contains ( needle) || log. contains ( "CommitDiff" )
174- } else {
175- log. contains ( needle)
176- }
177- } )
121+ . unwrap_or_else ( Vec :: new)
122+ }
123+
124+ #[ allow( dead_code) ]
125+ pub async fn print_tx_logs ( rpc_client : & RpcClient , signature : & Signature ) {
126+ println ! ( "logs: {:#?}" , fetch_tx_logs( rpc_client, signature) . await ) ;
127+ }
128+
129+ #[ allow( dead_code) ]
130+ pub async fn tx_logs_contain (
131+ rpc_client : & RpcClient ,
132+ signature : & Signature ,
133+ needle : & str ,
134+ ) -> bool {
135+ fetch_tx_logs ( rpc_client, signature)
136+ . await
137+ . iter ( )
138+ . any ( |log| {
139+ // Lots of existing tests pass "CommitState" as needle argument to this function, but since now CommitTask
140+ // could invoke CommitState or CommitDiff depending on the size of the account, we also look for "CommitDiff"
141+ // in the logs when needle == CommitState. It's easier to make this little adjustment here than computing
142+ // the decision and passing either CommitState or CommitDiff from the tests themselves.
143+ if needle == "CommitState" {
144+ log. contains ( needle) || log. contains ( "CommitDiff" )
145+ } else {
146+ log. contains ( needle)
147+ }
148+ } )
178149}
179150
180151/// This needs to be run for each test that required a new counter to be delegated
0 commit comments