diff --git a/solana/bridge/program/tests/common.rs b/solana/bridge/program/tests/common.rs index 407600b1..38906ca2 100644 --- a/solana/bridge/program/tests/common.rs +++ b/solana/bridge/program/tests/common.rs @@ -1,6 +1,9 @@ #![allow(warnings)] -use borsh::BorshSerialize; +use borsh::{ + BorshDeserialize, + BorshSerialize, +}; use byteorder::{ BigEndian, WriteBytesExt, @@ -63,6 +66,8 @@ use bridge::{ GuardianSet, GuardianSetDerivationData, MessageDerivationData, + Sequence, + SequenceDerivationData, SignatureSet, SignatureSetDerivationData, }, @@ -127,6 +132,17 @@ mod helpers { (payer, rpc, program) } + /// Fetch account data, the loop is there to re-attempt until data is available. + pub fn get_account_data(client: &RpcClient, account: &Pubkey) -> Option { + for _ in 0..5 { + if let Ok(account) = client.get_account(account) { + return Some(T::try_from_slice(&account.data).unwrap()); + } + std::thread::sleep(std::time::Duration::from_millis(2000)); + } + None + } + /// Generate `count` secp256k1 private keys, along with their ethereum-styled public key /// encoding: 0x0123456789ABCDEF01234 pub fn generate_keys(count: u8) -> (Vec<[u8; 20]>, Vec) {