Skip to content

Commit 46cda78

Browse files
committed
fix: address comments
1 parent 37e99b8 commit 46cda78

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

program/rust/src/processor/upd_price.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,12 @@ mod test {
362362
assert_eq!(find_publisher_index(&comps, &comp.pub_), Some(idx));
363363
});
364364

365-
assert_eq!(find_publisher_index(&comps, &Pubkey::new_unique()), None);
365+
let mut key_not_in_list = Pubkey::new_unique();
366+
while comps.iter().any(|comp| comp.pub_ == key_not_in_list) {
367+
key_not_in_list = Pubkey::new_unique();
368+
}
369+
370+
assert_eq!(find_publisher_index(&comps, &key_not_in_list), None);
366371
}
367372

368373
/// Test the find_publisher_index method works with a sorted list of components.
@@ -374,6 +379,11 @@ mod test {
374379
assert_eq!(find_publisher_index(&comps, &comp.pub_), Some(idx));
375380
});
376381

377-
assert_eq!(find_publisher_index(&comps, &Pubkey::new_unique()), None);
382+
let mut key_not_in_list = Pubkey::new_unique();
383+
while comps.iter().any(|comp| comp.pub_ == key_not_in_list) {
384+
key_not_in_list = Pubkey::new_unique();
385+
}
386+
387+
assert_eq!(find_publisher_index(&comps, &key_not_in_list), None);
378388
}
379389
}

program/rust/src/tests/test_add_publisher.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn test_add_publisher() {
199199
// Make sure that publishers get sorted after adding the default publisher
200200
{
201201
let price_data = load_checked::<PriceAccount>(&price_account, PC_VERSION).unwrap();
202-
println!("{:?}", price_data.comp_.map(|x| x.pub_));
202+
assert!(price_data.num_ == PC_NUM_COMP);
203203
for i in 1..PC_NUM_COMP {
204204
assert!(price_data.comp_[i as usize].pub_ > price_data.comp_[(i - 1) as usize].pub_);
205205
}

0 commit comments

Comments
 (0)