-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathbroadcast.rs
88 lines (75 loc) · 2.38 KB
/
broadcast.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#![cfg(feature = "test-sbf")]
#![feature(type_changing_struct_update)]
use common::setup::OTHER_CHAIN;
use ntt_messages::chain_id::ChainId;
use ntt_messages::mode::Mode;
use ntt_messages::transceivers::wormhole::{
WormholeTransceiverInfo, WormholeTransceiverRegistration,
};
use solana_program_test::*;
use solana_sdk::{signature::Keypair, signer::Signer};
use wormhole_anchor_sdk::wormhole::PostedVaa;
use crate::common::query::GetAccountDataAnchor;
use crate::common::setup::{setup, OTHER_TRANSCEIVER};
use crate::sdk::accounts::{good_ntt, NTTAccounts};
use crate::sdk::transceivers::wormhole::instructions::broadcast_id::{broadcast_id, BroadcastId};
use crate::{
common::submit::Submittable,
sdk::transceivers::wormhole::instructions::broadcast_peer::{broadcast_peer, BroadcastPeer},
};
pub mod common;
pub mod sdk;
#[tokio::test]
async fn test_broadcast_peer() {
let (mut ctx, _test_data) = setup(Mode::Locking).await;
let wh_message = Keypair::new();
broadcast_peer(
&good_ntt,
BroadcastPeer {
payer: ctx.payer.pubkey(),
wormhole_message: wh_message.pubkey(),
chain_id: OTHER_CHAIN,
},
)
.submit_with_signers(&[&wh_message], &mut ctx)
.await
.unwrap();
let msg: PostedVaa<WormholeTransceiverRegistration> = ctx
.get_account_data_anchor_unchecked(wh_message.pubkey())
.await;
assert_eq!(
*msg.data(),
WormholeTransceiverRegistration {
chain_id: ChainId { id: OTHER_CHAIN },
transceiver_address: OTHER_TRANSCEIVER
}
);
}
#[tokio::test]
async fn test_broadcast_id() {
let (mut ctx, test_data) = setup(Mode::Locking).await;
let wh_message = Keypair::new();
broadcast_id(
&good_ntt,
BroadcastId {
payer: ctx.payer.pubkey(),
wormhole_message: wh_message.pubkey(),
mint: test_data.mint,
},
)
.submit_with_signers(&[&wh_message], &mut ctx)
.await
.unwrap();
let msg: PostedVaa<WormholeTransceiverInfo> = ctx
.get_account_data_anchor_unchecked(wh_message.pubkey())
.await;
assert_eq!(
*msg.data(),
WormholeTransceiverInfo {
manager_address: good_ntt.program().to_bytes(),
manager_mode: Mode::Locking,
token_address: test_data.mint.to_bytes(),
token_decimals: 9,
}
);
}