Transferring larger than balance does nothing
Change-Id: I51d4954357e90a65ba09dc76bc3cf1bd1623606a
This commit is contained in:
parent
2769fa2739
commit
95decec044
|
@ -147,6 +147,7 @@ fn run_integration_tests() {
|
||||||
test_free_fees(&mut context);
|
test_free_fees(&mut context);
|
||||||
test_transfer_fees(&mut context);
|
test_transfer_fees(&mut context);
|
||||||
test_transfer_fees_fails(&mut context);
|
test_transfer_fees_fails(&mut context);
|
||||||
|
test_transfer_too_much(&mut context);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_initialize(context: &mut Context) {
|
fn test_initialize(context: &mut Context) {
|
||||||
|
@ -874,6 +875,53 @@ fn test_transfer_fees_fails(context: &mut Context) {
|
||||||
.is_err());
|
.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_transfer_too_much(context: &mut Context) {
|
||||||
|
// Initialize a wormhole bridge on Solana to test with.
|
||||||
|
let (ref payer, ref client, ref program) = common::setup();
|
||||||
|
let emitter = Keypair::from_bytes(&GOVERNANCE_KEY).unwrap();
|
||||||
|
let sequence = context.seq.next(emitter.pubkey().to_bytes());
|
||||||
|
|
||||||
|
let recipient = Keypair::new();
|
||||||
|
let nonce = rand::thread_rng().gen();
|
||||||
|
let message = GovernancePayloadTransferFees {
|
||||||
|
amount: 100_000_000_000u64.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();
|
||||||
|
|
||||||
|
// Should fail to transfer.
|
||||||
|
assert!(common::transfer_fees(
|
||||||
|
client,
|
||||||
|
program,
|
||||||
|
payer,
|
||||||
|
message_key,
|
||||||
|
emitter.pubkey(),
|
||||||
|
payer.pubkey(),
|
||||||
|
sequence,
|
||||||
|
).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
fn test_foreign_bridge_messages(context: &mut Context) {
|
fn test_foreign_bridge_messages(context: &mut Context) {
|
||||||
// Initialize a wormhole bridge on Solana to test with.
|
// Initialize a wormhole bridge on Solana to test with.
|
||||||
let (ref payer, ref client, ref program) = common::setup();
|
let (ref payer, ref client, ref program) = common::setup();
|
||||||
|
|
Loading…
Reference in New Issue