|
|
@@ -69,9 +69,11 @@ use bridge::{
|
|
|
types::{
|
|
|
BridgeConfig,
|
|
|
BridgeData,
|
|
|
+ ConsistencyLevel,
|
|
|
GovernancePayloadGuardianSetChange,
|
|
|
GovernancePayloadSetMessageFee,
|
|
|
GovernancePayloadTransferFees,
|
|
|
+ GovernancePayloadUpgrade,
|
|
|
GuardianSetData,
|
|
|
PostedMessage,
|
|
|
PostedMessageData,
|
|
|
@@ -140,6 +142,7 @@ fn run_integration_tests() {
|
|
|
test_persistent_bridge_messages(&mut context);
|
|
|
test_invalid_emitter(&mut context);
|
|
|
test_duplicate_messages_fail(&mut context);
|
|
|
+ test_upgrade_contract(&mut context);
|
|
|
test_guardian_set_change(&mut context);
|
|
|
test_guardian_set_change_fails(&mut context);
|
|
|
test_set_fees(&mut context);
|
|
|
@@ -444,6 +447,7 @@ fn test_invalid_emitter(context: &mut Context) {
|
|
|
nonce,
|
|
|
message,
|
|
|
false,
|
|
|
+ ConsistencyLevel::Confirmed,
|
|
|
)
|
|
|
.unwrap();
|
|
|
|
|
|
@@ -1255,3 +1259,47 @@ fn test_transfer_total_fails(context: &mut Context) {
|
|
|
account_balance + 10_000
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+fn test_upgrade_contract(context: &mut Context) {
|
|
|
+ // Initialize a wormhole bridge on Solana to test with.
|
|
|
+ let (ref payer, ref client, ref program) = common::setup();
|
|
|
+
|
|
|
+ // Upgrade the guardian set with a new set of guardians.
|
|
|
+ let (new_public_keys, new_secret_keys) = common::generate_keys(1);
|
|
|
+
|
|
|
+ let nonce = rand::thread_rng().gen();
|
|
|
+ let emitter = Keypair::from_bytes(&GOVERNANCE_KEY).unwrap();
|
|
|
+ let sequence = context.seq.next(emitter.pubkey().to_bytes());
|
|
|
+ let message = GovernancePayloadUpgrade {
|
|
|
+ new_contract: Pubkey::new_unique(),
|
|
|
+ }
|
|
|
+ .try_to_vec()
|
|
|
+ .unwrap();
|
|
|
+
|
|
|
+ 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, 0, 1);
|
|
|
+ common::verify_signatures(client, program, payer, body, body_hash, &context.secret, 0).unwrap();
|
|
|
+ common::post_vaa(client, program, payer, vaa).unwrap();
|
|
|
+ common::upgrade_contract(
|
|
|
+ client,
|
|
|
+ program,
|
|
|
+ payer,
|
|
|
+ message_key,
|
|
|
+ emitter.pubkey(),
|
|
|
+ Pubkey::new_unique(),
|
|
|
+ sequence,
|
|
|
+ )
|
|
|
+ .unwrap();
|
|
|
+ common::sync(client, payer);
|
|
|
+}
|