@@ -107,34 +107,57 @@ fn fatp_prio_watcher_ready_higher_evicts_lower() {
107107 block_on ( pool. submit_and_watch ( header01. hash ( ) , SOURCE , xt1. clone ( ) ) ) . unwrap ( ) ;
108108
109109 let xt0_status = futures:: executor:: block_on_stream ( xt0_watcher) . take ( 2 ) . collect :: < Vec < _ > > ( ) ;
110- assert_eq ! ( xt0_status, vec![ TransactionStatus :: Ready , TransactionStatus :: Dropped ] ) ;
110+ assert_eq ! (
111+ xt0_status,
112+ vec![ TransactionStatus :: Ready , TransactionStatus :: Usurped ( api. hash_and_length( & xt1) . 0 ) ]
113+ ) ;
111114 let xt1_status = futures:: executor:: block_on_stream ( xt1_watcher) . take ( 1 ) . collect :: < Vec < _ > > ( ) ;
112115 assert_eq ! ( xt1_status, vec![ TransactionStatus :: Ready ] ) ;
113116
114117 log:: info!( "len: {:?}" , pool. mempool_len( ) ) ;
115118 log:: info!( "len: {:?}" , pool. status_all( ) [ & header01. hash( ) ] ) ;
116119 assert_ready_iterator ! ( header01. hash( ) , pool, [ xt1] ) ;
117120 assert_pool_status ! ( header01. hash( ) , & pool, 1 , 0 ) ;
121+ }
118122
119- // let results = block_on(futures::future::join_all(submissions));
120- // assert!(results.iter().all(Result::is_ok));
121- // //charlie was not included into view:
122- // assert_pool_status!(header01.hash(), &pool, 2, 0);
123+ #[ test]
124+ fn fatp_prio_watcher_future_higher_evicts_lower ( ) {
125+ sp_tracing:: try_init_simple ( ) ;
123126
124- // //branch with alice transactions:
125- // let header02b = api.push_block(2, vec![xt1.clone(), xt2.clone()], true);
126- // let event = new_best_block_event(&pool, Some(header01.hash()), header02b.hash());
127- // block_on(pool.maintain(event));
128- // assert_eq!(pool.mempool_len().0, 2);
129- // assert_pool_status!(header02b.hash(), &pool, 0, 0);
130- // assert_ready_iterator!(header02b.hash(), pool, []);
131- //
132- // //branch with alice/charlie transactions shall also work:
133- // let header02a = api.push_block(2, vec![xt0.clone(), xt1.clone()], true);
134- // api.set_nonce(header02a.hash(), Alice.into(), 201);
135- // let event = new_best_block_event(&pool, Some(header02b.hash()), header02a.hash());
136- // block_on(pool.maintain(event));
137- // assert_eq!(pool.mempool_len().0, 2);
138- // // assert_pool_status!(header02a.hash(), &pool, 1, 0);
139- // assert_ready_iterator!(header02a.hash(), pool, [xt2]);
127+ let builder = TestPoolBuilder :: new ( ) ;
128+ let ( pool, api, _) = builder. with_mempool_count_limit ( 3 ) . with_ready_count ( 3 ) . build ( ) ;
129+
130+ let header01 = api. push_block ( 1 , vec ! [ ] , true ) ;
131+
132+ let event = new_best_block_event ( & pool, None , header01. hash ( ) ) ;
133+ block_on ( pool. maintain ( event) ) ;
134+
135+ let xt0 = uxt ( Alice , 201 ) ;
136+ let xt1 = uxt ( Alice , 201 ) ;
137+ let xt2 = uxt ( Alice , 200 ) ;
138+
139+ api. set_priority ( & xt0, 2 ) ;
140+ api. set_priority ( & xt1, 3 ) ;
141+
142+ let xt0_watcher =
143+ block_on ( pool. submit_and_watch ( header01. hash ( ) , SOURCE , xt0. clone ( ) ) ) . unwrap ( ) ;
144+ let xt1_watcher =
145+ block_on ( pool. submit_and_watch ( header01. hash ( ) , SOURCE , xt1. clone ( ) ) ) . unwrap ( ) ;
146+ let xt2_watcher =
147+ block_on ( pool. submit_and_watch ( header01. hash ( ) , SOURCE , xt2. clone ( ) ) ) . unwrap ( ) ;
148+
149+ let xt0_status = futures:: executor:: block_on_stream ( xt0_watcher) . take ( 2 ) . collect :: < Vec < _ > > ( ) ;
150+
151+ assert_eq ! (
152+ xt0_status,
153+ vec![ TransactionStatus :: Future , TransactionStatus :: Usurped ( api. hash_and_length( & xt2) . 0 ) ]
154+ ) ;
155+ let xt1_status = futures:: executor:: block_on_stream ( xt1_watcher) . take ( 2 ) . collect :: < Vec < _ > > ( ) ;
156+ assert_eq ! ( xt1_status, vec![ TransactionStatus :: Future , TransactionStatus :: Ready ] ) ;
157+ let xt2_status = futures:: executor:: block_on_stream ( xt2_watcher) . take ( 1 ) . collect :: < Vec < _ > > ( ) ;
158+ assert_eq ! ( xt2_status, vec![ TransactionStatus :: Ready ] ) ;
159+
160+ assert_eq ! ( pool. mempool_len( ) . 1 , 2 ) ;
161+ assert_ready_iterator ! ( header01. hash( ) , pool, [ xt2, xt1] ) ;
162+ assert_pool_status ! ( header01. hash( ) , & pool, 2 , 0 ) ;
140163}
0 commit comments