|
|
@@ -15,6 +15,8 @@ use {
|
|
|
sdk::{
|
|
|
deserialize_accumulator_update_data,
|
|
|
get_guardian_set_address,
|
|
|
+ DEFAULT_TREASURY_ID,
|
|
|
+ SECONDARY_TREASURY_ID,
|
|
|
},
|
|
|
state::price_update::{
|
|
|
PriceUpdateV1,
|
|
|
@@ -62,7 +64,7 @@ async fn test_post_updates_atomic() {
|
|
|
let poster = program_simulator.get_funded_keypair().await.unwrap();
|
|
|
let price_update_keypair = Keypair::new();
|
|
|
|
|
|
- assert_treasury_balance(&mut program_simulator, 0).await;
|
|
|
+ assert_treasury_balance(&mut program_simulator, 0, DEFAULT_TREASURY_ID).await;
|
|
|
|
|
|
// post one update atomically
|
|
|
program_simulator
|
|
|
@@ -74,6 +76,7 @@ async fn test_post_updates_atomic() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
vaa.clone(),
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID,
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|
|
|
@@ -81,7 +84,7 @@ async fn test_post_updates_atomic() {
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
|
- assert_treasury_balance(&mut program_simulator, 1).await;
|
|
|
+ assert_treasury_balance(&mut program_simulator, 1, DEFAULT_TREASURY_ID).await;
|
|
|
|
|
|
let mut price_update_account = program_simulator
|
|
|
.get_anchor_account_data::<PriceUpdateV1>(price_update_keypair.pubkey())
|
|
|
@@ -108,6 +111,7 @@ async fn test_post_updates_atomic() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
vaa.clone(),
|
|
|
merkle_price_updates[1].clone(),
|
|
|
+ DEFAULT_TREASURY_ID,
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|
|
|
@@ -115,7 +119,8 @@ async fn test_post_updates_atomic() {
|
|
|
.await
|
|
|
.unwrap();
|
|
|
|
|
|
- assert_treasury_balance(&mut program_simulator, 2).await;
|
|
|
+ assert_treasury_balance(&mut program_simulator, 2, DEFAULT_TREASURY_ID).await;
|
|
|
+ assert_treasury_balance(&mut program_simulator, 0, SECONDARY_TREASURY_ID).await;
|
|
|
|
|
|
price_update_account = program_simulator
|
|
|
.get_anchor_account_data::<PriceUpdateV1>(price_update_keypair.pubkey())
|
|
|
@@ -131,6 +136,41 @@ async fn test_post_updates_atomic() {
|
|
|
Message::PriceFeedMessage(price_update_account.price_message),
|
|
|
feed_2
|
|
|
);
|
|
|
+
|
|
|
+ // use another treasury account
|
|
|
+ program_simulator
|
|
|
+ .process_ix_with_default_compute_limit(
|
|
|
+ PostUpdatesAtomic::populate(
|
|
|
+ poster.pubkey(),
|
|
|
+ price_update_keypair.pubkey(),
|
|
|
+ BRIDGE_ID,
|
|
|
+ DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
+ vaa.clone(),
|
|
|
+ merkle_price_updates[0].clone(),
|
|
|
+ SECONDARY_TREASURY_ID,
|
|
|
+ ),
|
|
|
+ &vec![&poster, &price_update_keypair],
|
|
|
+ None,
|
|
|
+ )
|
|
|
+ .await
|
|
|
+ .unwrap();
|
|
|
+
|
|
|
+ assert_treasury_balance(&mut program_simulator, 2, DEFAULT_TREASURY_ID).await;
|
|
|
+ assert_treasury_balance(&mut program_simulator, 1, SECONDARY_TREASURY_ID).await;
|
|
|
+
|
|
|
+ price_update_account = program_simulator
|
|
|
+ .get_anchor_account_data::<PriceUpdateV1>(price_update_keypair.pubkey())
|
|
|
+ .await
|
|
|
+ .unwrap();
|
|
|
+ assert_eq!(price_update_account.write_authority, poster.pubkey());
|
|
|
+ assert_eq!(
|
|
|
+ price_update_account.verification_level,
|
|
|
+ VerificationLevel::Partial(5)
|
|
|
+ );
|
|
|
+ assert_eq!(
|
|
|
+ Message::PriceFeedMessage(price_update_account.price_message),
|
|
|
+ feed_1
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
#[tokio::test]
|
|
|
@@ -162,6 +202,7 @@ async fn test_post_updates_atomic_wrong_vaa() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
vaa_buffer_copy,
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|
|
|
@@ -187,6 +228,7 @@ async fn test_post_updates_atomic_wrong_vaa() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
vaa_wrong_num_signatures.clone(),
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|
|
|
@@ -211,6 +253,7 @@ async fn test_post_updates_atomic_wrong_vaa() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
serde_wormhole::to_vec(&vaa_copy).unwrap(),
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|
|
|
@@ -234,6 +277,7 @@ async fn test_post_updates_atomic_wrong_vaa() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
serde_wormhole::to_vec(&vaa_copy).unwrap(),
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|
|
|
@@ -257,6 +301,7 @@ async fn test_post_updates_atomic_wrong_vaa() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
serde_wormhole::to_vec(&vaa_copy).unwrap(),
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|
|
|
@@ -281,6 +326,7 @@ async fn test_post_updates_atomic_wrong_vaa() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
serde_wormhole::to_vec(&vaa_copy).unwrap(),
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|
|
|
@@ -304,6 +350,7 @@ async fn test_post_updates_atomic_wrong_vaa() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
serde_wormhole::to_vec(&vaa_copy).unwrap(),
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|
|
|
@@ -328,6 +375,7 @@ async fn test_post_updates_atomic_wrong_vaa() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
serde_wormhole::to_vec(&vaa_copy).unwrap(),
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|
|
|
@@ -345,6 +393,7 @@ async fn test_post_updates_atomic_wrong_vaa() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
vaa.clone(),
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID,
|
|
|
);
|
|
|
|
|
|
let wrong_guardian_set = get_guardian_set_address(BRIDGE_ID, 1);
|
|
|
@@ -388,6 +437,7 @@ async fn test_post_updates_atomic_wrong_setup() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
vaa.clone(),
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|
|
|
@@ -415,6 +465,7 @@ async fn test_post_updates_atomic_wrong_setup() {
|
|
|
DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
vaa.clone(),
|
|
|
merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID
|
|
|
),
|
|
|
&vec![&poster, &price_update_keypair],
|
|
|
None,
|