mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-05-19 07:29:32 +00:00
fix(mock_oracle): claim initialized price accounts
This commit is contained in:
parent
40348d5acd
commit
fe8207c0cc
@ -1,7 +1,7 @@
|
|||||||
use mock_oracle_core::PriceUpdate;
|
use mock_oracle_core::PriceUpdate;
|
||||||
use nssa_core::{
|
use nssa_core::{
|
||||||
account::{Account, AccountWithMetadata, Data},
|
account::{Account, AccountWithMetadata, Data},
|
||||||
program::{AccountPostState, ProgramId},
|
program::{AccountPostState, Claim, ProgramId},
|
||||||
};
|
};
|
||||||
use oracle_core::OraclePriceAccount;
|
use oracle_core::OraclePriceAccount;
|
||||||
|
|
||||||
@ -37,8 +37,10 @@ pub fn set_price(
|
|||||||
);
|
);
|
||||||
|
|
||||||
let mut price_post = price_account.account;
|
let mut price_post = price_account.account;
|
||||||
price_post.program_owner = mock_oracle_program_id;
|
|
||||||
price_post.data = Data::from(&OraclePriceAccount::from(update));
|
price_post.data = Data::from(&OraclePriceAccount::from(update));
|
||||||
|
|
||||||
vec![AccountPostState::new(price_post)]
|
vec![AccountPostState::new_claimed_if_default(
|
||||||
|
price_post,
|
||||||
|
Claim::Authorized,
|
||||||
|
)]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
use mock_oracle_core::{PriceUpdate, MOCK_ORACLE_SOURCE_IDENTIFIER};
|
use mock_oracle_core::{PriceUpdate, MOCK_ORACLE_SOURCE_IDENTIFIER};
|
||||||
use nssa_core::{
|
use nssa_core::{
|
||||||
account::{Account, AccountId, AccountWithMetadata, Data, Nonce},
|
account::{Account, AccountId, AccountWithMetadata, Data, Nonce},
|
||||||
program::ProgramId,
|
program::{Claim, ProgramId},
|
||||||
};
|
};
|
||||||
use oracle_core::OraclePriceAccount;
|
use oracle_core::OraclePriceAccount;
|
||||||
|
|
||||||
@ -69,8 +69,8 @@ fn set_price_initializes_authorized_price_account() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(post_states.len(), 1);
|
assert_eq!(post_states.len(), 1);
|
||||||
|
assert_eq!(post_states[0].required_claim(), Some(Claim::Authorized));
|
||||||
let post_account = post_states[0].account();
|
let post_account = post_states[0].account();
|
||||||
assert_eq!(post_account.program_owner, MOCK_ORACLE_PROGRAM_ID);
|
|
||||||
|
|
||||||
let price_account =
|
let price_account =
|
||||||
OraclePriceAccount::try_from(&post_account.data).expect("valid oracle price account");
|
OraclePriceAccount::try_from(&post_account.data).expect("valid oracle price account");
|
||||||
@ -87,6 +87,11 @@ fn set_price_updates_existing_mock_oracle_account() {
|
|||||||
&price_update,
|
&price_update,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert_eq!(post_states[0].required_claim(), None);
|
||||||
|
assert_eq!(
|
||||||
|
post_states[0].account().program_owner,
|
||||||
|
MOCK_ORACLE_PROGRAM_ID
|
||||||
|
);
|
||||||
let price_account = OraclePriceAccount::try_from(&post_states[0].account().data)
|
let price_account = OraclePriceAccount::try_from(&post_states[0].account().data)
|
||||||
.expect("valid oracle price account");
|
.expect("valid oracle price account");
|
||||||
assert_eq!(price_account.price, 1_100_000);
|
assert_eq!(price_account.price, 1_100_000);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user