@@ -21,6 +21,8 @@ use std::cell::RefCell;
2121use std:: pin:: Pin ;
2222use std:: sync:: Arc ;
2323
24+ const SLOT_DURATION_MILLIS : u64 = 5000 ;
25+
2426#[ derive( Default ) ]
2527struct 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 ) ]
102104pub ( 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]
130156fn 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]
136173fn 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]
141188fn loads_blocks_back_to_finality_or_stored ( ) {
142189
0 commit comments