Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

node/approval-voting: Continue to migrate tests to subsystem tests #3471

Merged

Conversation

Lldenaurois
Copy link
Contributor

This PR addresses the current gap between tests.rs and old_tests.rs

The goal is to provide the same amount of coverage using full subsystem tests.

@Lldenaurois Lldenaurois added I5-tests Tests need fixing, improving or augmenting. A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Jul 15, 2021
@@ -394,7 +448,7 @@ fn test_harness<T: Future<Output = VirtualOverseer>>(
ApprovalVotingSubsystem::with_config(
Config{
col_data: test_constants::TEST_CONFIG.col_data,
slot_duration_millis: 100u64,
slot_duration_millis: 5000u64,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this need to change? Time should be totally programmatic in the tests. Also recommend extracting to a constant TEST_SLOT_DURATION or something.

@@ -332,6 +333,60 @@ impl Backend for TestStore {
}
}

#[derive(Clone)]
pub(super) struct SharedTestStore<T: Backend> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this needs to be generic. After all, in test code every type should be known. Or is this used with multiple different kinds of backends?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you feel this should still be a specific type, I can address that as well.

@Lldenaurois Lldenaurois marked this pull request as ready for review July 22, 2021 18:38
@Lldenaurois Lldenaurois force-pushed the approval-voting-subsystem-tests branch from eea91f9 to 34143d0 Compare July 22, 2021 18:43
@@ -32,6 +32,7 @@ sp-application-crypto = { git = "https://github.com/paritytech/substrate", branc
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

[dev-dependencies]
async-std = "1.6.5"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems it's only used for async_std::task::sleep which is an overkill, we can use futures_timer::Delay instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I forgot to remove async-std. Great catch, thank you!

@@ -86,9 +86,6 @@ use crate::backend::{Backend, OverlayedBackend};
#[cfg(test)]
mod tests;

#[cfg(test)]
mod old_tests;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Comment on lines 663 to 664
let (oracle, _handle) = make_sync_oracle(false);
let (mock_clock, assignment_criteria) = make_harness_input();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is rather repetitive, a builder pattern with replacable defaults comes to mind that would reduce this a bit, but hey, it's a test, so feel free to ignore.

@@ -616,11 +827,15 @@ fn ss_rejects_assignment_in_future() {

// Add block hash 00.
ChainBuilder::new()
.add_block(block_hash, ChainBuilder::GENESIS_HASH, Slot::from(1), 1)
.add_block(block_hash, ChainBuilder::GENESIS_HASH, 1, BlockConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

assert!(clock.inner.lock().has_wakeup(slot_to_tick(slot) + tranche_offset));
clock.inner.lock().wakeup_all(slot_to_tick(slot) + tranche_offset);

async_std::task::sleep(std::time::Duration::from_millis(200)).await;
Copy link
Contributor

@drahnr drahnr Jul 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to craft explicit dependecies ,i.e. a oneshot with a timeout to assure synchronization if possible.

Comment on lines +2487 to +2488
13, // Alice wakeup
20, // Check no shows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +2176 to +2180
n_cores: validators.len() as _,
zeroth_delay_tranche_width: 5,
relay_vrf_modulo_samples: 3,
n_delay_tranches: 50,
no_show_slots: 2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: A few comments on the intent why they were chosen as they would be nice

Copy link
Contributor

@drahnr drahnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits, generally looks good to me on initial review pass.

Copy link
Member

@ordian ordian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go once you cargo +nightly fmt 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. I5-tests Tests need fixing, improving or augmenting.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants