diff --git a/solana/bridge/program/tests/integration.rs b/solana/bridge/program/tests/integration.rs index 30d291e9..73bf81ab 100644 --- a/solana/bridge/program/tests/integration.rs +++ b/solana/bridge/program/tests/integration.rs @@ -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();