Skip to content

Commit

Permalink
Remove activated from update_view in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tdimitrov committed Nov 15, 2024
1 parent 9607e1c commit 02ed2ae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ fn collator_reporting_works() {
let head = Hash::from_low_u64_be(128);
let head_num: u32 = 0;

update_view(&mut virtual_overseer, &test_state, vec![(head, head_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head, head_num)]).await;

let peer_b = PeerId::random();
let peer_c = PeerId::random();
Expand Down Expand Up @@ -625,7 +625,6 @@ fn fetch_one_collation_at_a_time_for_v1_advertisement() {
&mut virtual_overseer,
&test_state,
vec![(test_state.relay_parent, 0), (second, 1)],
2,
)
.await;

Expand Down Expand Up @@ -717,7 +716,6 @@ fn fetches_next_collation() {
&mut virtual_overseer,
&test_state,
vec![(test_state.relay_parent, 0), (second, 1)],
2,
)
.await;

Expand Down Expand Up @@ -834,8 +832,7 @@ fn reject_connection_to_next_group() {
test_harness(ReputationAggregator::new(|_| true), |test_harness| async move {
let TestHarness { mut virtual_overseer, .. } = test_harness;

update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)], 1)
.await;
update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)]).await;

let peer_b = PeerId::random();

Expand Down Expand Up @@ -879,7 +876,6 @@ fn fetch_next_collation_on_invalid_collation() {
&mut virtual_overseer,
&test_state,
vec![(test_state.relay_parent, 0), (second, 1)],
2,
)
.await;

Expand Down Expand Up @@ -980,8 +976,7 @@ fn inactive_disconnected() {

let pair = CollatorPair::generate().0;

update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)], 1)
.await;
update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)]).await;

let peer_b = PeerId::random();

Expand Down Expand Up @@ -1027,7 +1022,6 @@ fn activity_extends_life() {
&mut virtual_overseer,
&test_state,
vec![(hash_a, 0), (hash_b, 1), (hash_c, 2)],
3,
)
.await;

Expand Down Expand Up @@ -1093,8 +1087,7 @@ fn disconnect_if_no_declare() {
test_harness(ReputationAggregator::new(|_| true), |test_harness| async move {
let TestHarness { mut virtual_overseer, .. } = test_harness;

update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)], 1)
.await;
update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)]).await;

let peer_b = PeerId::random();

Expand Down Expand Up @@ -1124,8 +1117,7 @@ fn disconnect_if_wrong_declare() {
let pair = CollatorPair::generate().0;
let peer_b = PeerId::random();

update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)], 1)
.await;
update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)]).await;

overseer_send(
&mut virtual_overseer,
Expand Down Expand Up @@ -1176,8 +1168,7 @@ fn delay_reputation_change() {
let pair = CollatorPair::generate().0;
let peer_b = PeerId::random();

update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)], 1)
.await;
update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)]).await;

overseer_send(
&mut virtual_overseer,
Expand Down Expand Up @@ -1254,8 +1245,7 @@ fn view_change_clears_old_collators() {

let peer = PeerId::random();

update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)], 1)
.await;
update_view(&mut virtual_overseer, &test_state, vec![(test_state.relay_parent, 0)]).await;

connect_and_declare_collator(
&mut virtual_overseer,
Expand All @@ -1268,7 +1258,7 @@ fn view_change_clears_old_collators() {

test_state.group_rotation_info = test_state.group_rotation_info.bump_rotation();

update_view(&mut virtual_overseer, &test_state, vec![], 0).await;
update_view(&mut virtual_overseer, &test_state, vec![]).await;

assert_collator_disconnect(&mut virtual_overseer, peer).await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ pub(super) async fn update_view(
virtual_overseer: &mut VirtualOverseer,
test_state: &TestState,
new_view: Vec<(Hash, u32)>, // Hash and block number.
activated: u8, // How many new heads does this update contain?
) -> Option<AllMessages> {
let new_view: HashMap<Hash, u32> = HashMap::from_iter(new_view);

Expand All @@ -91,7 +90,7 @@ pub(super) async fn update_view(
.await;

let mut next_overseer_message = None;
for _ in 0..activated {
for _ in 0..new_view.len() {
let msg = match next_overseer_message.take() {
Some(msg) => msg,
None => overseer_recv(virtual_overseer).await,
Expand Down Expand Up @@ -474,7 +473,7 @@ fn v1_advertisement_accepted_and_seconded() {
let head_b = Hash::from_low_u64_be(128);
let head_b_num: u32 = 0;

update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)]).await;

let peer_a = PeerId::random();

Expand Down Expand Up @@ -553,7 +552,7 @@ fn v1_advertisement_rejected_on_non_active_leaf() {
let head_b = Hash::from_low_u64_be(128);
let head_b_num: u32 = 5;

update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)]).await;

let peer_a = PeerId::random();

Expand Down Expand Up @@ -603,7 +602,7 @@ fn accept_advertisements_from_implicit_view() {
let head_d = get_parent_hash(head_c);

// Activated leaf is `b`, but the collation will be based on `c`.
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)]).await;

let peer_a = PeerId::random();
let peer_b = PeerId::random();
Expand Down Expand Up @@ -706,7 +705,6 @@ fn second_multiple_candidates_per_relay_parent() {
&mut virtual_overseer,
&test_state,
vec![(head_a, head_a_num), (head_b, head_b_num)],
2,
)
.await;

Expand Down Expand Up @@ -796,7 +794,7 @@ fn fetched_collation_sanity_check() {
let head_c = Hash::from_low_u64_be(130);

// Activated leaf is `b`, but the collation will be based on `c`.
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)]).await;

let peer_a = PeerId::random();

Expand Down Expand Up @@ -900,7 +898,7 @@ fn sanity_check_invalid_parent_head_data() {
let head_c = Hash::from_low_u64_be(130);
let head_c_num = 3;

update_view(&mut virtual_overseer, &test_state, vec![(head_c, head_c_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head_c, head_c_num)]).await;

let peer_a = PeerId::random();

Expand Down Expand Up @@ -1023,7 +1021,7 @@ fn advertisement_spam_protection() {
let head_c = get_parent_hash(head_b);

// Activated leaf is `b`, but the collation will be based on `c`.
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)]).await;

let peer_a = PeerId::random();
connect_and_declare_collator(
Expand Down Expand Up @@ -1101,7 +1099,7 @@ fn child_blocked_from_seconding_by_parent(#[case] valid_parent: bool) {
let head_c = Hash::from_low_u64_be(130);

// Activated leaf is `b`, but the collation will be based on `c`.
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)]).await;

let peer_a = PeerId::random();

Expand Down Expand Up @@ -1402,7 +1400,7 @@ fn v2_descriptor(#[case] v2_feature_enabled: bool) {
let head_b = Hash::from_low_u64_be(128);
let head_b_num: u32 = 0;

update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)]).await;

let peer_a = PeerId::random();

Expand Down Expand Up @@ -1510,7 +1508,7 @@ fn invalid_v2_descriptor() {
let head_b = Hash::from_low_u64_be(128);
let head_b_num: u32 = 0;

update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)]).await;

let peer_a = PeerId::random();

Expand Down Expand Up @@ -1614,7 +1612,7 @@ fn fair_collation_fetches() {
let head_b = Hash::from_low_u64_be(128);
let head_b_num: u32 = 2;

update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head_b, head_b_num)]).await;

let peer_a = PeerId::random();
let pair_a = CollatorPair::generate().0;
Expand Down Expand Up @@ -1724,7 +1722,7 @@ fn collation_fetching_prefer_entries_earlier_in_claim_queue() {
let head = Hash::from_low_u64_be(128);
let head_num: u32 = 2;

update_view(&mut virtual_overseer, &test_state, vec![(head, head_num)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(head, head_num)]).await;

connect_and_declare_collator(
&mut virtual_overseer,
Expand Down Expand Up @@ -1898,7 +1896,7 @@ fn collation_fetching_considers_advertisements_from_the_whole_view() {

let relay_parent_2 = Hash::from_low_u64_be(test_state.relay_parent.to_low_u64_be() - 1);

update_view(&mut virtual_overseer, &test_state, vec![(relay_parent_2, 2)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(relay_parent_2, 2)]).await;

connect_and_declare_collator(
&mut virtual_overseer,
Expand Down Expand Up @@ -1944,7 +1942,7 @@ fn collation_fetching_considers_advertisements_from_the_whole_view() {
// them fall in the same view.
let relay_parent_4 = Hash::from_low_u64_be(relay_parent_2.to_low_u64_be() - 2);

update_view(&mut virtual_overseer, &test_state, vec![(relay_parent_4, 4)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(relay_parent_4, 4)]).await;

// One advertisement for `para_id_b` at `relay_parent_4`
submit_second_and_assert(
Expand Down Expand Up @@ -1996,7 +1994,7 @@ fn collation_fetching_considers_advertisements_from_the_whole_view() {
// At `relay_parent_6` the advertisement for `para_id_b` falls out of the view so a new one
// can be accepted
let relay_parent_6 = Hash::from_low_u64_be(relay_parent_4.to_low_u64_be() - 2);
update_view(&mut virtual_overseer, &test_state, vec![(relay_parent_6, 6)], 1).await;
update_view(&mut virtual_overseer, &test_state, vec![(relay_parent_6, 6)]).await;

submit_second_and_assert(
&mut virtual_overseer,
Expand Down Expand Up @@ -2044,7 +2042,6 @@ fn claim_queue_spot_claimed_at_next_relay_parent() {
&mut virtual_overseer,
&test_state,
vec![(hash_a, 0), (hash_b, 1), (hash_c, 2)],
3,
)
.await;

Expand Down

0 comments on commit 02ed2ae

Please sign in to comment.