File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,40 @@ test('delivers old will in case of a crash', async (t) => {
117
117
t . assert . equal ( received . length , 1 , 'only one will has been delivered' )
118
118
} )
119
119
120
+ test ( 'delivers many old wills in case of a crash' , async ( t ) => {
121
+ t . plan ( 1 )
122
+
123
+ const numWills = 100
124
+ const persistence = await memorySetup ( { id : 'anotherBroker' } )
125
+ const will = {
126
+ topic : 'mywill' ,
127
+ payload : Buffer . from ( 'last will' ) ,
128
+ qos : 0 ,
129
+ retain : false
130
+ }
131
+
132
+ for ( let id = 0 ; id < numWills ; id ++ ) {
133
+ const cWill = structuredClone ( will )
134
+ cWill . topic = 'mywill'
135
+ await persistence . putWill ( { id : `myClientId${ id } ` } , cWill )
136
+ }
137
+
138
+ const interval = 10 // ms, so that the will check happens fast!
139
+ const broker = await Aedes . createBroker ( {
140
+ persistence,
141
+ heartbeatInterval : interval ,
142
+ authorizePublish : ( client , packet , callback ) => {
143
+ callback ( null )
144
+ }
145
+ } )
146
+
147
+ t . after ( ( ) => broker . close ( ) )
148
+
149
+ const received = await willsFromBroker ( broker )
150
+ await delay ( 100 ) // give Aedes some time to process to ensure that all wills are sent
151
+ t . assert . equal ( received . length , numWills , 'all wills have been delivered' )
152
+ } )
153
+
120
154
test ( 'deliver old will without authorization in case of a crash' , async ( t ) => {
121
155
t . plan ( 1 )
122
156
You can’t perform that action at this time.
0 commit comments