Skip to content

Commit

Permalink
[test_loop] Change ClientQueries trait requirements in TestLoop util (#…
Browse files Browse the repository at this point in the history
…11520)

Part 2

Change in interface of ClientQueries to not depend on
`AsRef<AccountId>`. Note that we can get the account_id from Client
using the validator signer module.

### Other PRs

[Part 1](#11521): [test_loop]
Introduce TestLoopV2
[Part 2](#11520): [test_loop]
Change ClientQueries trait requirements in TestLoop util
[Part 3](#11522): [test_loop]
test_loop_sync_actor_maker implementation in TestLoopV2
[Part 4](#11523): [test_loop]
Introduce TestLoopPeerManagerActor for handling network messages across
clients
[Part 5](#11524): [test_loop]
Convert current tests to use TestLoopV2
[Part 6](#11525): [test_loop]
Cleanup old test loop code
[Part 7](#11528): [test_loop]
Better visualizer support for TestLoopV2
  • Loading branch information
Shreyan Gupta authored Jun 11, 2024
1 parent 07c2ec4 commit 71e5352
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions chain/client/src/test_utils/test_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ pub trait ClientQueries {
fn tracked_shards_for_each_client(&self) -> Vec<Vec<ShardId>>;
}

impl<Data: AsRef<Client> + AsRef<AccountId>> ClientQueries for Vec<Data> {
impl<Data> ClientQueries for Vec<Data>
where
Data: AsRef<Client>,
{
fn client_index_tracking_account(&self, account_id: &AccountId) -> usize {
let client: &Client = self[0].as_ref();
let head = client.chain.head().unwrap();
Expand All @@ -232,13 +235,11 @@ impl<Data: AsRef<Client> + AsRef<AccountId>> ClientQueries for Vec<Data> {

for i in 0..self.len() {
let client: &Client = self[i].as_ref();
let validator_signer = client.validator_signer.get().unwrap();
let account_id = validator_signer.validator_id();
let tracks_shard = client
.epoch_manager
.cares_about_shard_from_prev_block(
&head.prev_block_hash,
&self[i].as_ref(),
shard_id,
)
.cares_about_shard_from_prev_block(&head.prev_block_hash, account_id, shard_id)
.unwrap();
if tracks_shard {
return i;
Expand Down Expand Up @@ -314,15 +315,13 @@ impl<Data: AsRef<Client> + AsRef<AccountId>> ClientQueries for Vec<Data> {
let mut ret = Vec::new();
for i in 0..self.len() {
let client: &Client = self[i].as_ref();
let validator_signer = client.validator_signer.get().unwrap();
let account_id = validator_signer.validator_id();
let mut tracked_shards = Vec::new();
for shard_id in &all_shard_ids {
let tracks_shard = client
.epoch_manager
.cares_about_shard_from_prev_block(
&head.prev_block_hash,
&self[i].as_ref(),
*shard_id,
)
.cares_about_shard_from_prev_block(&head.prev_block_hash, account_id, *shard_id)
.unwrap();
if tracks_shard {
tracked_shards.push(*shard_id);
Expand Down

0 comments on commit 71e5352

Please sign in to comment.