|
|
@@ -81,6 +81,7 @@ async fn test_invalid_wormhole_message() {
|
|
|
program_simulator
|
|
|
.process_ix_with_default_compute_limit(
|
|
|
PostUpdateAtomic::populate(
|
|
|
+ poster.pubkey(),
|
|
|
poster.pubkey(),
|
|
|
price_update_keypair.pubkey(),
|
|
|
BRIDGE_ID,
|
|
|
@@ -126,6 +127,7 @@ async fn test_invalid_update_message() {
|
|
|
program_simulator
|
|
|
.process_ix_with_default_compute_limit(
|
|
|
PostUpdateAtomic::populate(
|
|
|
+ poster.pubkey(),
|
|
|
poster.pubkey(),
|
|
|
price_update_keypair.pubkey(),
|
|
|
BRIDGE_ID,
|
|
|
@@ -177,6 +179,9 @@ async fn test_post_price_update_from_vaa() {
|
|
|
assert_treasury_balance(&mut program_simulator, 0, DEFAULT_TREASURY_ID).await;
|
|
|
|
|
|
let poster = program_simulator.get_funded_keypair().await.unwrap();
|
|
|
+ // poster_2 can't write to this price update account
|
|
|
+ let poster_2 = program_simulator.get_funded_keypair().await.unwrap();
|
|
|
+
|
|
|
let price_update_keypair = Keypair::new();
|
|
|
|
|
|
// this update is not in the proof
|
|
|
@@ -184,6 +189,7 @@ async fn test_post_price_update_from_vaa() {
|
|
|
program_simulator
|
|
|
.process_ix_with_default_compute_limit(
|
|
|
PostUpdateAtomic::populate(
|
|
|
+ poster.pubkey(),
|
|
|
poster.pubkey(),
|
|
|
price_update_keypair.pubkey(),
|
|
|
BRIDGE_ID,
|
|
|
@@ -206,6 +212,7 @@ async fn test_post_price_update_from_vaa() {
|
|
|
program_simulator
|
|
|
.process_ix_with_default_compute_limit(
|
|
|
PostUpdateAtomic::populate(
|
|
|
+ poster.pubkey(),
|
|
|
poster.pubkey(),
|
|
|
price_update_keypair.pubkey(),
|
|
|
BRIDGE_ID,
|
|
|
@@ -245,6 +252,7 @@ async fn test_post_price_update_from_vaa() {
|
|
|
program_simulator
|
|
|
.process_ix_with_default_compute_limit(
|
|
|
PostUpdateAtomic::populate(
|
|
|
+ poster.pubkey(),
|
|
|
poster.pubkey(),
|
|
|
price_update_keypair.pubkey(),
|
|
|
BRIDGE_ID,
|
|
|
@@ -283,6 +291,7 @@ async fn test_post_price_update_from_vaa() {
|
|
|
program_simulator
|
|
|
.process_ix_with_default_compute_limit(
|
|
|
PostUpdateAtomic::populate(
|
|
|
+ poster.pubkey(),
|
|
|
poster.pubkey(),
|
|
|
price_update_keypair.pubkey(),
|
|
|
BRIDGE_ID,
|
|
|
@@ -320,6 +329,7 @@ async fn test_post_price_update_from_vaa() {
|
|
|
program_simulator
|
|
|
.process_ix_with_default_compute_limit(
|
|
|
PostUpdateAtomic::populate(
|
|
|
+ poster.pubkey(),
|
|
|
poster.pubkey(),
|
|
|
price_update_keypair.pubkey(),
|
|
|
BRIDGE_ID,
|
|
|
@@ -356,6 +366,47 @@ async fn test_post_price_update_from_vaa() {
|
|
|
feed_1
|
|
|
);
|
|
|
|
|
|
+ // Now poster_2 will pay
|
|
|
+ program_simulator
|
|
|
+ .process_ix_with_default_compute_limit(
|
|
|
+ PostUpdateAtomic::populate(
|
|
|
+ poster_2.pubkey(),
|
|
|
+ poster.pubkey(),
|
|
|
+ price_update_keypair.pubkey(),
|
|
|
+ BRIDGE_ID,
|
|
|
+ DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
+ vaa.clone(),
|
|
|
+ merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID,
|
|
|
+ ),
|
|
|
+ &vec![&poster, &poster_2, &price_update_keypair],
|
|
|
+ None,
|
|
|
+ )
|
|
|
+ .await
|
|
|
+ .unwrap();
|
|
|
+
|
|
|
+ assert_treasury_balance(
|
|
|
+ &mut program_simulator,
|
|
|
+ Rent::default().minimum_balance(0) + 1,
|
|
|
+ DEFAULT_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::Full
|
|
|
+ );
|
|
|
+ assert_eq!(
|
|
|
+ Message::PriceFeedMessage(price_update_account.price_message),
|
|
|
+ feed_1
|
|
|
+ );
|
|
|
+
|
|
|
|
|
|
// Now change the fee!
|
|
|
program_simulator
|
|
|
@@ -378,6 +429,7 @@ async fn test_post_price_update_from_vaa() {
|
|
|
program_simulator
|
|
|
.process_ix_with_default_compute_limit(
|
|
|
PostUpdateAtomic::populate(
|
|
|
+ poster.pubkey(),
|
|
|
poster.pubkey(),
|
|
|
price_update_keypair.pubkey(),
|
|
|
BRIDGE_ID,
|
|
|
@@ -397,7 +449,7 @@ async fn test_post_price_update_from_vaa() {
|
|
|
|
|
|
assert_treasury_balance(
|
|
|
&mut program_simulator,
|
|
|
- Rent::default().minimum_balance(0),
|
|
|
+ Rent::default().minimum_balance(0) + 1,
|
|
|
DEFAULT_TREASURY_ID,
|
|
|
)
|
|
|
.await;
|
|
|
@@ -435,6 +487,7 @@ async fn test_post_price_update_from_vaa() {
|
|
|
program_simulator
|
|
|
.process_ix_with_default_compute_limit(
|
|
|
PostUpdateAtomic::populate(
|
|
|
+ poster.pubkey(),
|
|
|
poster.pubkey(),
|
|
|
price_update_keypair.pubkey(),
|
|
|
BRIDGE_ID,
|
|
|
@@ -451,7 +504,7 @@ async fn test_post_price_update_from_vaa() {
|
|
|
|
|
|
assert_treasury_balance(
|
|
|
&mut program_simulator,
|
|
|
- Rent::default().minimum_balance(0) + LAMPORTS_PER_SOL,
|
|
|
+ Rent::default().minimum_balance(0) + 1 + LAMPORTS_PER_SOL,
|
|
|
DEFAULT_TREASURY_ID,
|
|
|
)
|
|
|
.await;
|
|
|
@@ -470,14 +523,11 @@ async fn test_post_price_update_from_vaa() {
|
|
|
feed_2
|
|
|
);
|
|
|
|
|
|
-
|
|
|
- // poster_2 can't write to this price update account
|
|
|
- let poster_2 = program_simulator.get_funded_keypair().await.unwrap();
|
|
|
-
|
|
|
assert_eq!(
|
|
|
program_simulator
|
|
|
.process_ix_with_default_compute_limit(
|
|
|
PostUpdateAtomic::populate(
|
|
|
+ poster_2.pubkey(),
|
|
|
poster_2.pubkey(),
|
|
|
price_update_keypair.pubkey(),
|
|
|
BRIDGE_ID,
|
|
|
@@ -494,4 +544,27 @@ async fn test_post_price_update_from_vaa() {
|
|
|
.unwrap(),
|
|
|
into_transaction_error(ReceiverError::WrongWriteAuthority)
|
|
|
);
|
|
|
+
|
|
|
+ // poster_2 can't write to this price update account not even if poster pays
|
|
|
+ assert_eq!(
|
|
|
+ program_simulator
|
|
|
+ .process_ix_with_default_compute_limit(
|
|
|
+ PostUpdateAtomic::populate(
|
|
|
+ poster.pubkey(),
|
|
|
+ poster_2.pubkey(),
|
|
|
+ price_update_keypair.pubkey(),
|
|
|
+ BRIDGE_ID,
|
|
|
+ DEFAULT_GUARDIAN_SET_INDEX,
|
|
|
+ vaa.clone(),
|
|
|
+ merkle_price_updates[0].clone(),
|
|
|
+ DEFAULT_TREASURY_ID
|
|
|
+ ),
|
|
|
+ &vec![&poster, &poster_2, &price_update_keypair],
|
|
|
+ None,
|
|
|
+ )
|
|
|
+ .await
|
|
|
+ .unwrap_err()
|
|
|
+ .unwrap(),
|
|
|
+ into_transaction_error(ReceiverError::WrongWriteAuthority)
|
|
|
+ );
|
|
|
}
|