@@ -72,8 +72,6 @@ describe("load", function () {
7272 } ) ;
7373
7474 it ( "load after prune" , async ( ) => {
75- // TODO fix test flakiness
76-
7775 session = await TestSession . connected ( 2 , [
7876 {
7977 directory : "./tmp/shared-log/load-after-prune/" + uuid ( ) ,
@@ -110,12 +108,12 @@ describe("load", function () {
110108 replicate : { offset : 0 , factor : 0.5 } ,
111109 replicas : {
112110 min : 1 ,
113- } /*
114- timeUntilRoleMaturity: 0 */ ,
111+ } ,
112+ timeUntilRoleMaturity : 0 ,
115113 } ,
116114 } ) ;
117115
118- let count = 100 ;
116+ let count = 64 ;
119117
120118 for ( let i = 0 ; i < count ; i ++ ) {
121119 await db1 . add ( "hello" + i , { meta : { next : [ ] } } ) ;
@@ -129,17 +127,28 @@ describe("load", function () {
129127 replicate : { offset : 0.3 , factor : 0.5 } ,
130128 replicas : {
131129 min : 1 ,
132- } /*
133- timeUntilRoleMaturity: 0 */ ,
130+ } ,
131+ timeUntilRoleMaturity : 0 ,
134132 } ,
135133 } ,
136134 ) ;
137135
136+ await Promise . all ( [
137+ db1 . log . waitForReplicator ( session . peers [ 1 ] . identity . publicKey , {
138+ timeout : 15_000 ,
139+ roleAge : 0 ,
140+ } ) ,
141+ db2 . log . waitForReplicator ( session . peers [ 0 ] . identity . publicKey , {
142+ timeout : 15_000 ,
143+ roleAge : 0 ,
144+ } ) ,
145+ ] ) ;
146+
138147 await waitForResolved ( ( ) => expect ( db1 . log . log . length ) . lessThan ( count ) ) ; // pruning started
139148
140149 await waitForConverged ( ( ) => db1 . log . log . length ) ; // pruning done
141150
142- await waitForConverged ( ( ) => db2 . log . log . length ) ;
151+ await waitForResolved ( ( ) => expect ( db2 . log . log . length ) . greaterThan ( 0 ) ) ;
143152 await session . peers [ 1 ] . stop ( ) ;
144153 await waitForConverged ( ( ) => db1 . log . log . length ) ;
145154 const lengthBeforeClose = db1 . log . log . length ;
0 commit comments