From fd7b53a2a5103179ea15a473acef638adeb1f6de Mon Sep 17 00:00:00 2001 From: Reisen Date: Mon, 5 Jul 2021 10:44:14 +0000 Subject: [PATCH] Add method to inspect account data in tests Change-Id: I23ee5b351bcd1cb6fb998384ff87f7bfaf61b885 --- solana/bridge/program/tests/common.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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) {