@@ -2152,6 +2152,17 @@ pub struct ReserveArgs {
2152
2152
pub struct ObligationArgs {
2153
2153
pub deposits : Vec < ( Pubkey , u64 ) > ,
2154
2154
pub borrows : Vec < ( Pubkey , u64 ) > ,
2155
+ pub should_refresh : bool ,
2156
+ }
2157
+
2158
+ impl Default for ObligationArgs {
2159
+ fn default ( ) -> Self {
2160
+ ObligationArgs {
2161
+ deposits : vec ! [ ] ,
2162
+ borrows : vec ! [ ] ,
2163
+ should_refresh : true ,
2164
+ }
2165
+ }
2155
2166
}
2156
2167
2157
2168
pub async fn custom_scenario (
@@ -2264,17 +2275,19 @@ pub async fn custom_scenario(
2264
2275
}
2265
2276
}
2266
2277
2267
- for ( i, obligation_arg) in obligation_args. iter ( ) . enumerate ( ) {
2278
+ for ( ( obligation, obligation_owner) , obligation_arg) in obligations
2279
+ . iter_mut ( )
2280
+ . zip ( obligation_owners. iter_mut ( ) )
2281
+ . zip ( obligation_args. iter ( ) )
2282
+ {
2268
2283
for ( mint, amount) in obligation_arg. borrows . iter ( ) {
2269
2284
let reserve = reserves
2270
2285
. iter ( )
2271
2286
. find ( |reserve| reserve. account . liquidity . mint_pubkey == * mint)
2272
2287
. unwrap ( ) ;
2273
2288
2274
- obligation_owners[ i]
2275
- . create_token_account ( mint, & mut test)
2276
- . await ;
2277
- obligation_owners[ i]
2289
+ obligation_owner. create_token_account ( mint, & mut test) . await ;
2290
+ obligation_owner
2278
2291
. create_token_account ( & reserve. account . collateral . mint_pubkey , & mut test)
2279
2292
. await ;
2280
2293
@@ -2284,8 +2297,8 @@ pub async fn custom_scenario(
2284
2297
. borrow_obligation_liquidity (
2285
2298
& mut test,
2286
2299
reserve,
2287
- & obligations [ i ] ,
2288
- & obligation_owners [ i ] ,
2300
+ obligation ,
2301
+ obligation_owner ,
2289
2302
fee_receiver. get_account ( mint) ,
2290
2303
* amount,
2291
2304
)
@@ -2294,7 +2307,11 @@ pub async fn custom_scenario(
2294
2307
}
2295
2308
}
2296
2309
2297
- for obligation in obligations. iter_mut ( ) {
2310
+ for obligation in obligations
2311
+ . iter_mut ( )
2312
+ . zip ( obligation_args. iter ( ) )
2313
+ . filter_map ( |( obligation, arg) | arg. should_refresh . then_some ( obligation) )
2314
+ {
2298
2315
lending_market
2299
2316
. refresh_obligation ( & mut test, obligation)
2300
2317
. await
0 commit comments