File tree Expand file tree Collapse file tree
basic-operations/anchor/reinit/programs/reinit/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,12 +136,31 @@ async fn test_reinit() {
136136 // Wait for the indexer to index the close before reading it back.
137137 wait_for_indexer_catchup ( & rpc) . await ;
138138
139- let closed = rpc
139+ // The close zeroes the account, but the indexer's merkle-tree data can lag
140+ // the slot marker, so retry until the zeroed (closed) state is reflected.
141+ let mut closed = rpc
140142 . get_compressed_account ( address, None )
141143 . await
142144 . unwrap ( )
143145 . value
144146 . unwrap ( ) ;
147+ for _ in 0 ..30 {
148+ if closed
149+ . data
150+ . as_ref ( )
151+ . map ( |d| d. discriminator == [ 0u8 ; 8 ] )
152+ . unwrap_or ( false )
153+ {
154+ break ;
155+ }
156+ tokio:: time:: sleep ( Duration :: from_millis ( 500 ) ) . await ;
157+ closed = rpc
158+ . get_compressed_account ( address, None )
159+ . await
160+ . unwrap ( )
161+ . value
162+ . unwrap ( ) ;
163+ }
145164 assert_eq ! ( closed. address. as_ref( ) . unwrap( ) , & address) ;
146165 assert_eq ! ( closed. owner, reinit:: ID ) ;
147166
Original file line number Diff line number Diff line change @@ -235,6 +235,21 @@ async fn test_create_issuer_and_add_credential() {
235235 . value
236236 . expect ( "Credential account not found" ) ;
237237 println ! ( "credential_account {:?}" , credential_account) ;
238+
239+ // The credential account is indexed before its merkle-tree leaf/proof is,
240+ // so wait until the proof is available before verifying (avoids
241+ // "Leaf nodes not found for hashes").
242+ for _ in 0 ..30 {
243+ if rpc
244+ . get_multiple_compressed_account_proofs ( vec ! [ credential_account. hash] , None )
245+ . await
246+ . is_ok ( )
247+ {
248+ break ;
249+ }
250+ tokio:: time:: sleep ( Duration :: from_millis ( 500 ) ) . await ;
251+ }
252+
238253 verify_credential (
239254 & mut rpc,
240255 & payer,
You can’t perform that action at this time.
0 commit comments