Transfer Governance action fails without correct emitter

Change-Id: I86ecbf57ae5b6e8cecd452c4f7a63a6177a460fe
This commit is contained in:
Reisen 2021-07-07 08:48:37 +00:00
parent b676339555
commit 2769fa2739
1 changed files with 50 additions and 0 deletions

View File

@ -146,6 +146,7 @@ fn run_integration_tests() {
test_set_fees_fails(&mut context);
test_free_fees(&mut context);
test_transfer_fees(&mut context);
test_transfer_fees_fails(&mut context);
}
fn test_initialize(context: &mut Context) {
@ -824,6 +825,55 @@ fn test_transfer_fees(context: &mut Context) {
.unwrap();
}
fn test_transfer_fees_fails(context: &mut Context) {
// Initialize a wormhole bridge on Solana to test with.
let (ref payer, ref client, ref program) = common::setup();
// Use an invalid emitter.
let emitter = Keypair::new();
let sequence = context.seq.next(emitter.pubkey().to_bytes());
let recipient = Keypair::new();
let nonce = rand::thread_rng().gen();
let message = GovernancePayloadTransferFees {
amount: 100.into(),
to: payer.pubkey().to_bytes(),
}
.try_to_vec()
.unwrap();
// Fetch accounts for chain state checking.
let fee_collector = FeeCollector::key(None, &program);
let account_balance = client.get_account(&fee_collector).unwrap().lamports;
let message_key = common::post_message(
client,
program,
payer,
&emitter,
nonce,
message.clone(),
10_000,
false,
)
.unwrap();
let (vaa, body, body_hash) = common::generate_vaa(&emitter, message.clone(), nonce, 1, 1);
common::verify_signatures(client, program, payer, body, body_hash, &context.secret, 1).unwrap();
common::post_vaa(client, program, payer, vaa).unwrap();
assert!(common::transfer_fees(
client,
program,
payer,
message_key,
emitter.pubkey(),
payer.pubkey(),
sequence,
)
.is_err());
}
fn test_foreign_bridge_messages(context: &mut Context) {
// Initialize a wormhole bridge on Solana to test with.
let (ref payer, ref client, ref program) = common::setup();