Skip to content

Commit c44aa40

Browse files
committed
more fixes
1 parent 85724e6 commit c44aa40

File tree

6 files changed

+55
-85
lines changed

6 files changed

+55
-85
lines changed

backend/instance.ts

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export type Options = {
1919
type SendUpdateMessage = {
2020
type: "sendUpdate";
2121
update: ReceivedStatusUpdate<any>;
22-
descr: string;
2322
};
2423

2524
type SetUpdateListenerMessage = {

backend/message.test.ts

+40-62
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createProcessor, UpdateDescr } from "./message";
1+
import { createProcessor } from "./message";
22
import type { Message } from "../types/message";
33

44
// a little helper to let us track messages for testing purposes
@@ -29,7 +29,7 @@ test("distribute to self", () => {
2929
client0.sendUpdate({ payload: "Hello" }, "") ;
3030

3131
expect(client0Heard).toMatchObject([
32-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
32+
{ payload: "Hello", serial: 1, max_serial: 1 },
3333
]);
3434

3535
expect(prepare(getMessages())).toEqual([
@@ -43,13 +43,11 @@ test("distribute to self", () => {
4343
serial: 1,
4444
max_serial: 1,
4545
},
46-
descr: "",
4746
},
4847
{
4948
type: "received",
5049
update: { payload: "Hello", serial: 1, max_serial: 1 },
5150
instanceId: "3001",
52-
descr: "",
5351
},
5452
]);
5553
});
@@ -76,12 +74,12 @@ test("distribute to self and other", () => {
7674
client0.sendUpdate({ payload: "Hello" }, "");
7775
client1.sendUpdate({ payload: "Bye" }, "");
7876
expect(client0Heard).toMatchObject([
79-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
80-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
77+
{ payload: "Hello", serial: 1, max_serial: 1 },
78+
{ payload: "Bye", serial: 2, max_serial: 2 },
8179
]);
8280
expect(client1Heard).toMatchObject([
83-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
84-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
81+
{ payload: "Hello", serial: 1, max_serial: 1 },
82+
{ payload: "Bye", serial: 2, max_serial: 2 }
8583
]);
8684

8785
expect(prepare(getMessages())).toEqual([
@@ -93,37 +91,31 @@ test("distribute to self and other", () => {
9391
type: "sent",
9492
instanceId: "3001",
9593
update: { payload: "Hello", serial: 1, max_serial: 1 },
96-
descr: "",
9794
},
9895
{
9996
type: "received",
10097
update: { payload: "Hello", serial: 1, max_serial: 1 },
10198
instanceId: "3001",
102-
descr: "",
10399
},
104100
{
105101
type: "received",
106102
update: { payload: "Hello", serial: 1, max_serial: 1 },
107103
instanceId: "3002",
108-
descr: "",
109104
},
110105
{
111106
type: "sent",
112107
instanceId: "3002",
113108
update: { payload: "Bye", serial: 2, max_serial: 2 },
114-
descr: "",
115109
},
116110
{
117111
type: "received",
118112
update: { payload: "Bye", serial: 2, max_serial: 2 },
119113
instanceId: "3001",
120-
descr: "",
121114
},
122115
{
123116
type: "received",
124117
update: { payload: "Bye", serial: 2, max_serial: 2 },
125118
instanceId: "3002",
126-
descr: "",
127119
},
128120
]);
129121
});
@@ -149,11 +141,11 @@ test("setUpdateListener serial should skip older", () => {
149141
client0.sendUpdate({ payload: "Hello" }, "");
150142
client0.sendUpdate({ payload: "Bye" }, "");
151143
expect(client0Heard).toMatchObject([
152-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
153-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
144+
{ payload: "Hello", serial: 1, max_serial: 1 },
145+
{ payload: "Bye", serial: 2, max_serial: 2 },
154146
]);
155147
expect(client1Heard).toMatchObject([
156-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
148+
{ payload: "Bye", serial: 2, max_serial: 2 },
157149
]);
158150
});
159151

@@ -175,8 +167,8 @@ test("other starts listening later", () => {
175167
client0.sendUpdate({ payload: "Bye" }, "");
176168

177169
expect(client0Heard).toMatchObject([
178-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
179-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
170+
{ payload: "Hello", serial: 1, max_serial: 1 },
171+
{ payload: "Bye", serial: 2, max_serial: 2 },
180172
]);
181173
// we only join later, so we haven't heard a thing yet
182174
expect(client1Heard).toMatchObject([]);
@@ -187,12 +179,12 @@ test("other starts listening later", () => {
187179
}, 0);
188180

189181
expect(client0Heard).toMatchObject([
190-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
191-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
182+
{ payload: "Hello", serial: 1, max_serial: 1 },
183+
{ payload: "Bye", serial: 2, max_serial: 2 },
192184
]);
193185
expect(client1Heard).toMatchObject([
194-
[{ payload: "Hello", serial: 1, max_serial: 2 }, ""],
195-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
186+
{ payload: "Hello", serial: 1, max_serial: 2 },
187+
{ payload: "Bye", serial: 2, max_serial: 2 },
196188
]);
197189

198190
expect(prepare(getMessages())).toEqual([
@@ -202,39 +194,33 @@ test("other starts listening later", () => {
202194
type: "sent",
203195
instanceId: "3001",
204196
update: { payload: "Hello", serial: 1, max_serial: 1 },
205-
descr: "",
206197
},
207198
{
208199
type: "received",
209200
update: { payload: "Hello", serial: 1, max_serial: 1 },
210201
instanceId: "3001",
211-
descr: "",
212202
},
213203
{
214204
type: "sent",
215205
instanceId: "3001",
216206
update: { payload: "Bye", serial: 2, max_serial: 2 },
217-
descr: "",
218207
},
219208
{
220209
type: "received",
221210
update: { payload: "Bye", serial: 2, max_serial: 2 },
222211
instanceId: "3001",
223-
descr: "",
224212
},
225213
{ type: "connect", instanceId: "3002" },
226214
{ type: "clear", instanceId: "3002" },
227215
{
228216
type: "received",
229217
update: { payload: "Hello", serial: 1, max_serial: 2 },
230218
instanceId: "3002",
231-
descr: "",
232219
},
233220
{
234221
type: "received",
235222
update: { payload: "Bye", serial: 2, max_serial: 2 },
236223
instanceId: "3002",
237-
descr: "",
238224
},
239225
]);
240226
});
@@ -255,8 +241,8 @@ test("client is created later and needs to catch up", () => {
255241
client0.sendUpdate({ payload: "Bye" }, "");
256242

257243
expect(client0Heard).toMatchObject([
258-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
259-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
244+
{ payload: "Hello", serial: 1, max_serial: 1 },
245+
{ payload: "Bye", serial: 2, max_serial: 2 },
260246
]);
261247

262248
// we only join later, so we haven't heard a thing yet
@@ -269,12 +255,12 @@ test("client is created later and needs to catch up", () => {
269255
}, 0);
270256

271257
expect(client0Heard).toMatchObject([
272-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
273-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
258+
{ payload: "Hello", serial: 1, max_serial: 1 },
259+
{ payload: "Bye", serial: 2, max_serial: 2 },
274260
]);
275261
expect(client1Heard).toMatchObject([
276-
[{ payload: "Hello", serial: 1, max_serial: 2 }, ""],
277-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
262+
{ payload: "Hello", serial: 1, max_serial: 2 },
263+
{ payload: "Bye", serial: 2, max_serial: 2 },
278264
]);
279265
});
280266

@@ -294,8 +280,8 @@ test("other starts listening later but is partially caught up", () => {
294280
client0.sendUpdate({ payload: "Hello" }, "");
295281
client0.sendUpdate({ payload: "Bye" }, "");
296282
expect(client0Heard).toMatchObject([
297-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
298-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
283+
{ payload: "Hello", serial: 1, max_serial: 1 },
284+
{ payload: "Bye", serial: 2, max_serial: 2 },
299285
]);
300286
// we only join later, so we haven't heard a thing yet
301287
expect(client1Heard).toMatchObject([]);
@@ -307,11 +293,11 @@ test("other starts listening later but is partially caught up", () => {
307293
}, 1);
308294

309295
expect(client0Heard).toMatchObject([
310-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
311-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
296+
{ payload: "Hello", serial: 1, max_serial: 1 },
297+
{ payload: "Bye", serial: 2, max_serial: 2 },
312298
]);
313299
expect(client1Heard).toMatchObject([
314-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
300+
{ payload: "Bye", serial: 2, max_serial: 2 },
315301
]);
316302
});
317303

@@ -493,8 +479,8 @@ test("connect with clear means we get no catchup if no new updates", () => {
493479

494480
expect(client0Heard).toMatchObject([
495481
"cleared",
496-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
497-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
482+
{ payload: "Hello", serial: 1, max_serial: 1 },
483+
{ payload: "Bye", serial: 2, max_serial: 2 },
498484
"cleared",
499485
]);
500486

@@ -516,8 +502,8 @@ test("connect with clear means we get no catchup if no new updates", () => {
516502

517503
expect(client0Heard).toMatchObject([
518504
"cleared",
519-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
520-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
505+
{ payload: "Hello", serial: 1, max_serial: 1 },
506+
{ payload: "Bye", serial: 2, max_serial: 2 },
521507
"cleared",
522508
]);
523509
expect(client1Heard).toMatchObject(["cleared"]);
@@ -549,14 +535,14 @@ test("connect with clear means catchup only with updates after clear", () => {
549535
processor.clear();
550536

551537
// the aftermath update, which the newly connecting client should get
552-
client0.sendUpdate({ payload: "Aftermath" }, "update 3");
538+
client0.sendUpdate({ payload: "Aftermath" }, "");
553539

554540
expect(client0Heard).toMatchObject([
555541
"cleared",
556-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
557-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
542+
{ payload: "Hello", serial: 1, max_serial: 1 },
543+
{ payload: "Bye", serial: 2, max_serial: 2 },
558544
"cleared",
559-
[{ payload: "Aftermath", serial: 1, max_serial: 1 }, "update 3"],
545+
{ payload: "Aftermath", serial: 1, max_serial: 1 },
560546
]);
561547

562548
// we only join later, so we haven't heard a thing yet
@@ -577,14 +563,14 @@ test("connect with clear means catchup only with updates after clear", () => {
577563

578564
expect(client0Heard).toMatchObject([
579565
"cleared",
580-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
581-
[{ payload: "Bye", serial: 2, max_serial: 2 }, ""],
566+
{ payload: "Hello", serial: 1, max_serial: 1 },
567+
{ payload: "Bye", serial: 2, max_serial: 2 },
582568
"cleared",
583-
[{ payload: "Aftermath", serial: 1, max_serial: 1 }, "update 3"],
569+
{ payload: "Aftermath", serial: 1, max_serial: 1 },
584570
]);
585571
expect(client1Heard).toMatchObject([
586572
"cleared",
587-
[{ payload: "Aftermath", serial: 1, max_serial: 1 }, "update 3"],
573+
{ payload: "Aftermath", serial: 1, max_serial: 1 },
588574
]);
589575

590576
expect(getMessages()).toMatchObject([
@@ -594,46 +580,39 @@ test("connect with clear means catchup only with updates after clear", () => {
594580
type: "sent",
595581
instanceId: "3001",
596582
update: { payload: "Hello", serial: 1, max_serial: 1 },
597-
descr: "",
598583
},
599584
{
600585
type: "received",
601586
update: { payload: "Hello", serial: 1, max_serial: 1 },
602587
instanceId: "3001",
603-
descr: "",
604588
},
605589
{
606590
type: "sent",
607591
instanceId: "3001",
608592
update: { payload: "Bye", serial: 2, max_serial: 2 },
609-
descr: "",
610593
},
611594
{
612595
type: "received",
613596
update: { payload: "Bye", serial: 2, max_serial: 2 },
614597
instanceId: "3001",
615-
descr: "",
616598
},
617599
{ type: "clear", instanceId: "3001" },
618600
{
619601
type: "sent",
620602
instanceId: "3001",
621603
update: { payload: "Aftermath", serial: 1, max_serial: 1 },
622-
descr: "update 3",
623604
},
624605
{
625606
type: "received",
626607
update: { payload: "Aftermath", serial: 1, max_serial: 1 },
627608
instanceId: "3001",
628-
descr: "update 3",
629609
},
630610
{ type: "connect", instanceId: "3002" },
631611
{ type: "clear", instanceId: "3002" },
632612
{
633613
type: "received",
634614
instanceId: "3002",
635615
update: { payload: "Aftermath", serial: 1, max_serial: 1 },
636-
descr: "update 3",
637616
},
638617
]);
639618
});
@@ -659,7 +638,7 @@ test("distribute to self and other, but other was disconnected", () => {
659638

660639
client0.sendUpdate({ payload: "Hello" }, "");
661640
expect(client0Heard).toMatchObject([
662-
[{ payload: "Hello", serial: 1, max_serial: 1 }, ""],
641+
{ payload: "Hello", serial: 1, max_serial: 1 },
663642
]);
664643
expect(client1Heard).toMatchObject([]);
665644

@@ -672,13 +651,12 @@ test("distribute to self and other, but other was disconnected", () => {
672651
type: "sent",
673652
instanceId: "3001",
674653
update: { payload: "Hello", serial: 1, max_serial: 1 },
675-
descr: "",
654+
676655
},
677656
{
678657
type: "received",
679658
update: { payload: "Hello", serial: 1, max_serial: 1 },
680659
instanceId: "3001",
681-
descr: "",
682660
},
683661
]);
684662
});

0 commit comments

Comments
 (0)