Skip to content

Commit

Permalink
fix: other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos committed Jul 24, 2024
1 parent 5d7dc45 commit a9e93d9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
43 changes: 23 additions & 20 deletions target_chains/cosmwasm/contracts/pyth/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ mod test {
let feed1 = create_dummy_price_feed_message(100);
let feed2 = create_dummy_price_feed_message(200);
let feed3 = create_dummy_price_feed_message(300);
let data = create_accumulator_message(&[feed1, feed2, feed3], &[feed1], false, false);
let data = create_accumulator_message(&[&feed1, &feed2, &feed3], &[&feed1], false, false);
check_sufficient_fee(&deps.as_ref(), &[data.into()])
}

Expand Down Expand Up @@ -1246,21 +1246,22 @@ mod test {
let feed2 = create_dummy_price_feed_message(200);
let feed3 = create_dummy_price_feed_message(300);

let msg = create_accumulator_message(&[feed1, feed2, feed3], &[feed1, feed3], false, false);
let msg =
create_accumulator_message(&[&feed1, &feed2, &feed3], &[&feed1, &feed3], false, false);
assert_eq!(
get_update_fee_amount(&deps.as_ref(), &[msg.into()]).unwrap(),
200
);

let msg = create_accumulator_message(&[feed1, feed2, feed3], &[feed1], false, false);
let msg = create_accumulator_message(&[&feed1, &feed2, &feed3], &[&feed1], false, false);
assert_eq!(
get_update_fee_amount(&deps.as_ref(), &[msg.into()]).unwrap(),
100
);

let msg = create_accumulator_message(
&[feed1, feed2, feed3],
&[feed1, feed2, feed3, feed1, feed3],
&[&feed1, &feed2, &feed3],
&[&feed1, &feed2, &feed3, &feed1, &feed3],
false,
false,
);
Expand All @@ -1272,8 +1273,8 @@ mod test {
let batch_msg =
create_batch_price_update_msg_from_attestations(vec![PriceAttestation::default()]);
let msg = create_accumulator_message(
&[feed1, feed2, feed3],
&[feed1, feed2, feed3],
&[&feed1, &feed2, &feed3],
&[&feed1, &feed2, &feed3],
false,
false,
);
Expand All @@ -1293,7 +1294,7 @@ mod test {

let feed1 = create_dummy_price_feed_message(100);
let feed2 = create_dummy_price_feed_message(200);
let msg = create_accumulator_message(&[feed1, feed2], &[feed1], false, false);
let msg = create_accumulator_message(&[&feed1, &feed2], &[&feed1], false, false);
let info = mock_info("123", &[]);
let result = update_price_feeds(deps.as_mut(), env, info, &[msg.into()]);
assert!(result.is_ok());
Expand All @@ -1310,12 +1311,13 @@ mod test {
for i in 0..10000 {
all_feeds.push(create_dummy_price_feed_message(i));
}
let all_feeds: Vec<&Message> = all_feeds.iter().collect();
let msg = create_accumulator_message(&all_feeds, &all_feeds[100..110], false, false);
let info = mock_info("123", &[]);
let result = update_price_feeds(deps.as_mut(), env, info, &[msg.into()]);
assert!(result.is_ok());
for i in 100..110 {
check_price_match(&deps, &all_feeds[i]);
check_price_match(&deps, all_feeds[i]);
}
}

Expand All @@ -1338,8 +1340,8 @@ mod test {
let mut feed2 = create_dummy_price_feed_message(200);
let mut feed3 = create_dummy_price_feed_message(300);
let msg = create_accumulator_message(
&[feed1, feed2, feed3],
&[feed1, feed2, feed3],
&[&feed1, &feed2, &feed3],
&[&feed1, &feed2, &feed3],
false,
false,
);
Expand All @@ -1350,8 +1352,8 @@ mod test {
as_mut_price_feed(&mut feed2).price *= 2;
as_mut_price_feed(&mut feed3).price *= 2;
let msg2 = create_accumulator_message(
&[feed1, feed2, feed3],
&[feed1, feed2, feed3],
&[&feed1, &feed2, &feed3],
&[&feed1, &feed2, &feed3],
false,
false,
);
Expand All @@ -1376,8 +1378,8 @@ mod test {
as_mut_price_feed(&mut feed2).publish_time -= 1;
as_mut_price_feed(&mut feed2).price *= 2;
let msg = create_accumulator_message(
&[feed1, feed2, feed3],
&[feed1, feed2, feed3],
&[&feed1, &feed2, &feed3],
&[&feed1, &feed2, &feed3],
false,
false,
);
Expand All @@ -1400,10 +1402,11 @@ mod test {
let feed3 = create_dummy_price_feed_message(300);
as_mut_price_feed(&mut feed2).publish_time -= 1;
as_mut_price_feed(&mut feed2).price *= 2;
let msg = create_accumulator_message(&[feed1, feed2, feed3], &[feed1, feed3], false, false);
let msg =
create_accumulator_message(&[&feed1, &feed2, &feed3], &[&feed1, &feed3], false, false);

let msg2 =
create_accumulator_message(&[feed1, feed2, feed3], &[feed2, feed3], false, false);
create_accumulator_message(&[&feed1, &feed2, &feed3], &[&feed2, &feed3], false, false);
let info = mock_info("123", &[]);
let result = update_price_feeds(deps.as_mut(), env, info, &[msg.into(), msg2.into()]);

Expand All @@ -1420,7 +1423,7 @@ mod test {
.unwrap();

let feed1 = create_dummy_price_feed_message(100);
let mut msg = create_accumulator_message(&[feed1], &[feed1], false, false);
let mut msg = create_accumulator_message(&[&feed1], &[&feed1], false, false);
msg[4] = 3; // major version
let info = mock_info("123", &[]);
let result = update_price_feeds(deps.as_mut(), env, info, &[msg.into()]);
Expand All @@ -1439,7 +1442,7 @@ mod test {
.unwrap();

let feed1 = create_dummy_price_feed_message(100);
let msg = create_accumulator_message(&[feed1], &[feed1], true, false);
let msg = create_accumulator_message(&[&feed1], &[&feed1], true, false);
let info = mock_info("123", &[]);
let result = update_price_feeds(deps.as_mut(), env, info, &[msg.into()]);
assert!(result.is_err());
Expand Down Expand Up @@ -1467,7 +1470,7 @@ mod test {
prev_publish_time: 0,
publish_slot: 0,
});
let msg = create_accumulator_message(&[feed1], &[feed1], false, false);
let msg = create_accumulator_message(&[&feed1], &[&feed1], false, false);
let info = mock_info("123", &[]);
let result = update_price_feeds(deps.as_mut(), env, info, &[msg.into()]);
assert!(result.is_err());
Expand Down
2 changes: 1 addition & 1 deletion target_chains/near/receiver/tests/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ async fn test_accumulator_updates() {
// Create a couple of test feeds.
let feed_1 = create_dummy_price_feed_message(100);
let feed_2 = create_dummy_price_feed_message(200);
let message = create_accumulator_message(&[feed_1, feed_2], &[feed_1], false, false);
let message = create_accumulator_message(&[&feed_1, &feed_2], &[&feed_1], false, false);
let message = hex::encode(message);

// Call the usual UpdatePriceFeed function.
Expand Down

0 comments on commit a9e93d9

Please sign in to comment.