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

Approval voting full subsystem tests#3391

Merged
Lldenaurois merged 18 commits intoparitytech:masterfrom
Lldenaurois:approval-voting-full-subsystem-tests
Jul 8, 2021
Merged

Approval voting full subsystem tests#3391
Lldenaurois merged 18 commits intoparitytech:masterfrom
Lldenaurois:approval-voting-full-subsystem-tests

Conversation

@Lldenaurois
Copy link
Copy Markdown
Contributor

@Lldenaurois Lldenaurois commented Jul 1, 2021

This PR adds a first set of subsystem tests for the approval-voting subsystem. Not all paths are tested in this PR, meaning that the unit tests are still providing more coverage, but this gap will be bridged shortly.

Note: This PR is rebased on top of #3366, so we will need to merge that PR before this one can be merged. In the meantime, I will add tests to this PR in anticipation of the framework here not being too far from what is expected.

This commit introduces a Backend trait and attempts to move away
from the Action model via an OverlayBackend as in the ChainSelection
subsystem.
This commit modifies all tests to ensure tests are passing.
This commit addresses some oversights in the prior commit.

1. Inner errors in backend.write were swallowed
2. One-off write functions removed to avoid useless abstraction
3. Touch-ups in general
This commit removes the TestDB from tests.rs and replaces it with
an in-memory kvdb.
@Lldenaurois Lldenaurois force-pushed the approval-voting-full-subsystem-tests branch from 8f71209 to ed06999 Compare July 1, 2021 07:49
@@ -1,3 +1,4 @@
#![allow(dead_code)]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

NOTE: Not all tests have been written and therefore some of the functions on the mock clock are considered dead_code. Pushing the PR up just to make sure the first steps are correct.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is this going to be resolved in a follow up? what about old_tests?


assert_eq!(rx.await, Ok(AssignmentCheckResult::Accepted));

// TODO(ladi): fix
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Having some trouble getting the wakeups scheduled. Needs a little more "thinking through" on my part.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This needs an issue filed

Copy link
Copy Markdown
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, mostly about repetitions and other minuscule things, other than that: LGTM

DbBackend::new(db_writer.clone(), TEST_CONFIG)
}

fn overlay_txn<T, F>(db: &mut T, mut f: F)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

f -> apply_txn?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yessir, this is from the previous PR. Should be more descriptive... great point.

let state = State {
clock: Box::new(MockClock::new(tick)),
..single_session_state(session_index, SessionInfo {
validators: validators.iter().map(|v| v.public().into()).collect(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let validators = validators.iter() ... collect(); deserves an intermediate var.

),
};

let tick = 9;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In this test are quite a few 🧙‍♂️ magic numbers, it would be nice to add a rationale why these are as they are.

Comment on lines +1307 to +1330
let block_hash = Hash::repeat_byte(0x01);
let maximum_broadcast = 10;

let candidate_entry: CandidateEntry = {
let approval_entry = approval_db::v1::ApprovalEntry {
tranches: Vec::new(),
backing_group: GroupIndex(0),
our_assignment: Some(approval_db::v1::OurAssignment {
cert: garbage_assignment_cert(
AssignmentCertKind::RelayVRFModulo { sample: 0 }
),
tranche: maximum_broadcast,
validator_index: ValidatorIndex(4),
triggered: false,
}),
our_approval_sig: None,
assignments: bitvec::bitvec![BitOrderLsb0, u8; 0; 4],
approved: false,
};

approval_db::v1::CandidateEntry {
candidate: Default::default(),
session: 1,
block_assignments: vec![(block_hash, approval_entry)].into_iter().collect(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems to be rather repetitive and could be parameterize by a few variables - something worth to consider.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Awesome feedback... exactly what I needed! Thank you!

@Lldenaurois Lldenaurois added 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. A0-please_review Pull request needs code review. labels Jul 1, 2021
@Lldenaurois Lldenaurois force-pushed the approval-voting-full-subsystem-tests branch from 34490a7 to 0bacddb Compare July 8, 2021 14:05
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.

4 participants