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

Commit 88a2702

Browse files
committed
test harness beginnings
1 parent c251c97 commit 88a2702

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

node/core/approval-voting/src/tests.rs

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use std::cell::RefCell;
2121
use std::pin::Pin;
2222
use std::sync::Arc;
2323

24+
const SLOT_DURATION_MILLIS: u64 = 5000;
25+
2426
#[derive(Default)]
2527
struct MockClock {
2628
inner: Arc<Mutex<MockClockInner>>,
@@ -96,7 +98,7 @@ impl MockClockInner {
9698
}
9799
}
98100

99-
// TODO [now]: mock `AssignmentCriteria` implementation.
101+
struct MockAssignmentCriteria;
100102

101103
#[derive(Default)]
102104
pub(crate) struct TestStore {
@@ -126,17 +128,62 @@ impl AuxStore for TestStore {
126128
}
127129
}
128130

131+
fn blank_state() -> (State<TestStore>, mpsc::Receiver<BackgroundRequest>) {
132+
let (tx, rx) = mpsc::channel(1024);
133+
State {
134+
earliest_session: None,
135+
session_info: Vec::new(),
136+
keystore: LocalKeystore::in_memory(),
137+
wakeups: Wakeups::default(),
138+
slot_duration_millis: SLOT_DURATION_MILLIS,
139+
db: Arc::new(TestStore::default()),
140+
background_tx: tx,
141+
clock: Box::new(MockClock::default()),
142+
assignment_criteria: unimplemented!(),
143+
}
144+
}
145+
146+
fn single_session_state(index: SessionIndex, info: SessionInfo)
147+
-> (State<TestStore>, mpsc::Receiver<BackgroundRequest>)
148+
{
149+
let (mut s, rx) = blank_state();
150+
s.earliest_session = Some(index);
151+
s.session_info = vec![info];
152+
(s, rx)
153+
}
154+
129155
#[test]
130156
fn rejects_bad_assignment() {
157+
let state = single_session_state(1, unimplemented!());
158+
let assignment = unimplemented!();
159+
let candidate_index = unimplemented!();
131160

132-
}
161+
// TODO [now]: instantiate test store with block data.
133162

163+
check_and_import_assignment(
164+
state,
165+
assignment,
166+
candidate_index,
167+
).unwrap();
168+
169+
// Check that the assignment's been imported.
170+
}
134171

135172
#[test]
136173
fn rejects_assignment_in_future() {
137174

138175
}
139176

177+
#[test]
178+
fn rejects_assignment_with_unknown_candidate() {
179+
180+
}
181+
182+
#[test]
183+
fn wakeup_scheduled_after_assignment_import() {
184+
185+
}
186+
140187
#[test]
141188
fn loads_blocks_back_to_finality_or_stored() {
142189

0 commit comments

Comments
 (0)