Skip to content

Commit

Permalink
add run to all blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseAbram committed Oct 28, 2024
1 parent 047cdf8 commit 91b3d0c
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async fn integration_test_register_sign_reshare_sign() {
);

// Do a reshare
do_reshare(&api, &rpc).await;
do_reshare(&api, &rpc, &other_rpcs).await;

// Sign a message again
let recoverable_signature = test_client::sign(
Expand Down Expand Up @@ -148,7 +148,11 @@ async fn integration_test_register_sign_reshare_sign() {
);
}

async fn do_reshare(api: &OnlineClient<EntropyConfig>, rpc: &LegacyRpcMethods<EntropyConfig>) {
async fn do_reshare(
api: &OnlineClient<EntropyConfig>,
rpc: &LegacyRpcMethods<EntropyConfig>,
rpcs: &[LegacyRpcMethods<EntropyConfig>],
) {
// Get current signers
let signer_query = entropy::storage().staking_extension().signers();
let signer_stash_accounts = query_chain(&api, &rpc, signer_query, None).await.unwrap().unwrap();
Expand All @@ -167,13 +171,12 @@ async fn do_reshare(api: &OnlineClient<EntropyConfig>, rpc: &LegacyRpcMethods<En
new_signers: reshare_data.new_signers.into_iter().map(|s| s.to_vec()).collect(),
block_number: block_number - 1,
};

run_to_block(&rpc, block_number).await;
let ips = vec![3002, 3003, 3004];
run_to_all_blocks(rpcs, block_number).await;
// Send the OCW message to all TS servers who don't have a chain node
let client = reqwest::Client::new();
let response_results = join_all(
[3002, 3003, 3004]
.iter()
ips.iter()
.map(|port| {
client
.post(format!("http://127.0.0.1:{}/validator/reshare", port))
Expand All @@ -183,7 +186,8 @@ async fn do_reshare(api: &OnlineClient<EntropyConfig>, rpc: &LegacyRpcMethods<En
.collect::<Vec<_>>(),
)
.await;
for response_result in response_results {
for (i, response_result) in response_results.into_iter().enumerate() {
dbg!(ips[i]);
assert_eq!(response_result.unwrap().text().await.unwrap(), "");
}

Expand Down Expand Up @@ -221,3 +225,12 @@ async fn do_reshare(api: &OnlineClient<EntropyConfig>, rpc: &LegacyRpcMethods<En
let new: HashSet<[u8; 32]> = new_signer_stash_accounts.iter().map(|s| s.0).collect();
assert_ne!(old, new);
}

pub async fn run_to_all_blocks(rpcs: &[LegacyRpcMethods<EntropyConfig>], block_run: u32) {
let mut current_block = 0;
for rpc in rpcs {
while current_block < block_run {
current_block = rpc.chain_get_header(None).await.unwrap().unwrap().number;
}
}
}

0 comments on commit 91b3d0c

Please sign in to comment.