cojson 0.7.35-unique.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/.turbo/turbo-build.log +2 -7
  2. package/.turbo/turbo-lint.log +4 -0
  3. package/.turbo/turbo-test.log +321 -253
  4. package/CHANGELOG.md +10 -2
  5. package/dist/PeerState.js +66 -0
  6. package/dist/PeerState.js.map +1 -0
  7. package/dist/PriorityBasedMessageQueue.js +51 -0
  8. package/dist/PriorityBasedMessageQueue.js.map +1 -0
  9. package/dist/base64url.js.map +1 -1
  10. package/dist/coValue.js.map +1 -1
  11. package/dist/coValueCore.js +3 -6
  12. package/dist/coValueCore.js.map +1 -1
  13. package/dist/coValues/account.js +0 -1
  14. package/dist/coValues/account.js.map +1 -1
  15. package/dist/coValues/coList.js.map +1 -1
  16. package/dist/coValues/coMap.js.map +1 -1
  17. package/dist/coValues/coStream.js +14 -15
  18. package/dist/coValues/coStream.js.map +1 -1
  19. package/dist/coValues/group.js.map +1 -1
  20. package/dist/coreToCoValue.js.map +1 -1
  21. package/dist/crypto/PureJSCrypto.js.map +1 -1
  22. package/dist/crypto/WasmCrypto.js.map +1 -1
  23. package/dist/crypto/crypto.js +3 -0
  24. package/dist/crypto/crypto.js.map +1 -1
  25. package/dist/index.js +3 -2
  26. package/dist/index.js.map +1 -1
  27. package/dist/jsonStringify.js.map +1 -1
  28. package/dist/localNode.js +7 -7
  29. package/dist/localNode.js.map +1 -1
  30. package/dist/permissions.js.map +1 -1
  31. package/dist/priority.js +31 -0
  32. package/dist/priority.js.map +1 -0
  33. package/dist/storage/FileSystem.js.map +1 -1
  34. package/dist/storage/chunksAndKnownStates.js +2 -0
  35. package/dist/storage/chunksAndKnownStates.js.map +1 -1
  36. package/dist/storage/index.js.map +1 -1
  37. package/dist/streamUtils.js.map +1 -1
  38. package/dist/sync.js +7 -18
  39. package/dist/sync.js.map +1 -1
  40. package/dist/tests/PeerState.test.js +80 -0
  41. package/dist/tests/PeerState.test.js.map +1 -0
  42. package/dist/tests/PriorityBasedMessageQueue.test.js +97 -0
  43. package/dist/tests/PriorityBasedMessageQueue.test.js.map +1 -0
  44. package/dist/tests/account.test.js +1 -2
  45. package/dist/tests/account.test.js.map +1 -1
  46. package/dist/tests/coMap.test.js.map +1 -1
  47. package/dist/tests/coStream.test.js +34 -1
  48. package/dist/tests/coStream.test.js.map +1 -1
  49. package/dist/tests/permissions.test.js +41 -42
  50. package/dist/tests/permissions.test.js.map +1 -1
  51. package/dist/tests/priority.test.js +61 -0
  52. package/dist/tests/priority.test.js.map +1 -0
  53. package/dist/tests/sync.test.js +327 -17
  54. package/dist/tests/sync.test.js.map +1 -1
  55. package/dist/tests/testUtils.js +1 -2
  56. package/dist/tests/testUtils.js.map +1 -1
  57. package/dist/typeUtils/expectGroup.js.map +1 -1
  58. package/package.json +3 -3
  59. package/src/PeerState.ts +85 -0
  60. package/src/PriorityBasedMessageQueue.ts +77 -0
  61. package/src/coValueCore.ts +4 -9
  62. package/src/coValues/account.ts +0 -1
  63. package/src/coValues/coStream.ts +21 -18
  64. package/src/crypto/crypto.ts +5 -0
  65. package/src/index.ts +3 -3
  66. package/src/localNode.ts +6 -7
  67. package/src/priority.ts +39 -0
  68. package/src/storage/chunksAndKnownStates.ts +2 -0
  69. package/src/sync.ts +19 -34
  70. package/src/tests/PeerState.test.ts +92 -0
  71. package/src/tests/PriorityBasedMessageQueue.test.ts +111 -0
  72. package/src/tests/account.test.ts +1 -2
  73. package/src/tests/coStream.test.ts +58 -1
  74. package/src/tests/permissions.test.ts +41 -42
  75. package/src/tests/priority.test.ts +75 -0
  76. package/src/tests/sync.test.ts +488 -26
  77. package/src/tests/testUtils.ts +1 -2
@@ -1,5 +1,4 @@
1
1
  import { expect, test } from "vitest";
2
- import { newRandomSessionID } from "../coValueCore.js";
3
2
  import { expectMap } from "../coValue.js";
4
3
  import {
5
4
  newGroup,
@@ -27,7 +26,7 @@ test("Added admin can add a third admin to a group", () => {
27
26
  groupCore
28
27
  .testWithDifferentAccount(
29
28
  otherAdmin,
30
- newRandomSessionID(otherAdmin.id),
29
+ Crypto.newRandomSessionID(otherAdmin.id),
31
30
  )
32
31
  .getCurrentContent(),
33
32
  );
@@ -47,7 +46,7 @@ test("Added adming can add a third admin to a group (high level)", () => {
47
46
  group.core
48
47
  .testWithDifferentAccount(
49
48
  otherAdmin,
50
- newRandomSessionID(otherAdmin.id),
49
+ Crypto.newRandomSessionID(otherAdmin.id),
51
50
  )
52
51
  .getCurrentContent(),
53
52
  );
@@ -73,7 +72,7 @@ test("Admins can't demote other admins in a group", () => {
73
72
  groupCore
74
73
  .testWithDifferentAccount(
75
74
  otherAdmin,
76
- newRandomSessionID(otherAdmin.id),
75
+ Crypto.newRandomSessionID(otherAdmin.id),
77
76
  )
78
77
  .getCurrentContent(),
79
78
  );
@@ -89,7 +88,7 @@ test("Admins can't demote other admins in a group (high level)", () => {
89
88
  group.core
90
89
  .testWithDifferentAccount(
91
90
  otherAdmin,
92
- newRandomSessionID(otherAdmin.id),
91
+ Crypto.newRandomSessionID(otherAdmin.id),
93
92
  )
94
93
  .getCurrentContent(),
95
94
  );
@@ -114,7 +113,7 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
114
113
 
115
114
  const groupAsWriter = expectGroup(
116
115
  groupCore
117
- .testWithDifferentAccount(writer, newRandomSessionID(writer.id))
116
+ .testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
118
117
  .getCurrentContent(),
119
118
  );
120
119
 
@@ -142,7 +141,7 @@ test("Admins an add writers to a group, who can't add admins, writers, or reader
142
141
 
143
142
  const groupAsWriter = expectGroup(
144
143
  group.core
145
- .testWithDifferentAccount(writer, newRandomSessionID(writer.id))
144
+ .testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
146
145
  .getCurrentContent(),
147
146
  );
148
147
 
@@ -174,7 +173,7 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
174
173
 
175
174
  const groupAsReader = expectGroup(
176
175
  groupCore
177
- .testWithDifferentAccount(reader, newRandomSessionID(reader.id))
176
+ .testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
178
177
  .getCurrentContent(),
179
178
  );
180
179
 
@@ -203,7 +202,7 @@ test("Admins can add readers to a group, who can't add admins, writers, or reade
203
202
 
204
203
  const groupAsReader = expectGroup(
205
204
  group.core
206
- .testWithDifferentAccount(reader, newRandomSessionID(reader.id))
205
+ .testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
207
206
  .getCurrentContent(),
208
207
  );
209
208
 
@@ -267,7 +266,7 @@ test("Writers can write to an object that is owned by their group", () => {
267
266
 
268
267
  const childObjectAsWriter = childObject.testWithDifferentAccount(
269
268
  writer,
270
- newRandomSessionID(writer.id),
269
+ Crypto.newRandomSessionID(writer.id),
271
270
  );
272
271
 
273
272
  const childContentAsWriter = expectMap(
@@ -289,7 +288,7 @@ test("Writers can write to an object that is owned by their group (high level)",
289
288
 
290
289
  const childObjectAsWriter = expectMap(
291
290
  childObject.core
292
- .testWithDifferentAccount(writer, newRandomSessionID(writer.id))
291
+ .testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
293
292
  .getCurrentContent(),
294
293
  );
295
294
 
@@ -315,7 +314,7 @@ test("Readers can not write to an object that is owned by their group", () => {
315
314
 
316
315
  const childObjectAsReader = childObject.testWithDifferentAccount(
317
316
  reader,
318
- newRandomSessionID(reader.id),
317
+ Crypto.newRandomSessionID(reader.id),
319
318
  );
320
319
 
321
320
  const childContentAsReader = expectMap(
@@ -337,7 +336,7 @@ test("Readers can not write to an object that is owned by their group (high leve
337
336
 
338
337
  const childObjectAsReader = expectMap(
339
338
  childObject.core
340
- .testWithDifferentAccount(reader, newRandomSessionID(reader.id))
339
+ .testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
341
340
  .getCurrentContent(),
342
341
  );
343
342
 
@@ -442,7 +441,7 @@ test("Admins can set group read key and then writers can use it to create and re
442
441
 
443
442
  const childObjectAsWriter = childObject.testWithDifferentAccount(
444
443
  writer,
445
- newRandomSessionID(writer.id),
444
+ Crypto.newRandomSessionID(writer.id),
446
445
  );
447
446
 
448
447
  expect(childObject.getCurrentReadKey().secret).toEqual(readKey);
@@ -466,7 +465,7 @@ test("Admins can set group read key and then writers can use it to create and re
466
465
 
467
466
  const childObjectAsWriter = expectMap(
468
467
  childObject.core
469
- .testWithDifferentAccount(writer, newRandomSessionID(writer.id))
468
+ .testWithDifferentAccount(writer, Crypto.newRandomSessionID(writer.id))
470
469
  .getCurrentContent(),
471
470
  );
472
471
 
@@ -526,7 +525,7 @@ test("Admins can set group read key and then use it to create private transactio
526
525
 
527
526
  const childObjectAsReader = childObject.testWithDifferentAccount(
528
527
  reader,
529
- newRandomSessionID(reader.id),
528
+ Crypto.newRandomSessionID(reader.id),
530
529
  );
531
530
 
532
531
  expect(childObjectAsReader.getCurrentReadKey().secret).toEqual(readKey);
@@ -552,7 +551,7 @@ test("Admins can set group read key and then use it to create private transactio
552
551
 
553
552
  const childContentAsReader = expectMap(
554
553
  childObject.core
555
- .testWithDifferentAccount(reader, newRandomSessionID(reader.id))
554
+ .testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
556
555
  .getCurrentContent(),
557
556
  );
558
557
 
@@ -613,7 +612,7 @@ test("Admins can set group read key and then use it to create private transactio
613
612
 
614
613
  const childObjectAsReader1 = childObject.testWithDifferentAccount(
615
614
  reader1,
616
- newRandomSessionID(reader1.id),
615
+ Crypto.newRandomSessionID(reader1.id),
617
616
  );
618
617
 
619
618
  expect(childObjectAsReader1.getCurrentReadKey().secret).toEqual(readKey);
@@ -638,7 +637,7 @@ test("Admins can set group read key and then use it to create private transactio
638
637
 
639
638
  const childObjectAsReader2 = childObject.testWithDifferentAccount(
640
639
  reader2,
641
- newRandomSessionID(reader2.id),
640
+ Crypto.newRandomSessionID(reader2.id),
642
641
  );
643
642
 
644
643
  expect(childObjectAsReader2.getCurrentReadKey().secret).toEqual(readKey);
@@ -666,7 +665,7 @@ test("Admins can set group read key and then use it to create private transactio
666
665
 
667
666
  const childContentAsReader1 = expectMap(
668
667
  childObject.core
669
- .testWithDifferentAccount(reader1, newRandomSessionID(reader1.id))
668
+ .testWithDifferentAccount(reader1, Crypto.newRandomSessionID(reader1.id))
670
669
  .getCurrentContent(),
671
670
  );
672
671
 
@@ -676,7 +675,7 @@ test("Admins can set group read key and then use it to create private transactio
676
675
 
677
676
  const childContentAsReader2 = expectMap(
678
677
  childObject.core
679
- .testWithDifferentAccount(reader2, newRandomSessionID(reader2.id))
678
+ .testWithDifferentAccount(reader2, Crypto.newRandomSessionID(reader2.id))
680
679
  .getCurrentContent(),
681
680
  );
682
681
 
@@ -845,7 +844,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
845
844
 
846
845
  const childObjectAsReader = childObject.testWithDifferentAccount(
847
846
  reader,
848
- newRandomSessionID(reader.id),
847
+ Crypto.newRandomSessionID(reader.id),
849
848
  );
850
849
 
851
850
  expect(childObjectAsReader.getCurrentReadKey().secret).toEqual(readKey2);
@@ -883,7 +882,7 @@ test("Admins can set group read key, make a private transaction in an owned obje
883
882
 
884
883
  const childContentAsReader = expectMap(
885
884
  childObject.core
886
- .testWithDifferentAccount(reader, newRandomSessionID(reader.id))
885
+ .testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
887
886
  .getCurrentContent(),
888
887
  );
889
888
 
@@ -959,7 +958,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
959
958
 
960
959
  let childObjectAsReader = childObject.testWithDifferentAccount(
961
960
  reader,
962
- newRandomSessionID(reader.id),
961
+ Crypto.newRandomSessionID(reader.id),
963
962
  );
964
963
 
965
964
  expect(
@@ -968,7 +967,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
968
967
 
969
968
  let childObjectAsReader2 = childObject.testWithDifferentAccount(
970
969
  reader,
971
- newRandomSessionID(reader.id),
970
+ Crypto.newRandomSessionID(reader.id),
972
971
  );
973
972
 
974
973
  expect(
@@ -1024,11 +1023,11 @@ test("Admins can set group read rey, make a private transaction in an owned obje
1024
1023
  // TODO: make sure these instances of coValues sync between each other so this isn't necessary?
1025
1024
  childObjectAsReader = childObject.testWithDifferentAccount(
1026
1025
  reader,
1027
- newRandomSessionID(reader.id),
1026
+ Crypto.newRandomSessionID(reader.id),
1028
1027
  );
1029
1028
  childObjectAsReader2 = childObject.testWithDifferentAccount(
1030
1029
  reader2,
1031
- newRandomSessionID(reader2.id),
1030
+ Crypto.newRandomSessionID(reader2.id),
1032
1031
  );
1033
1032
 
1034
1033
  expect(
@@ -1072,7 +1071,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
1072
1071
 
1073
1072
  const childContentAsReader2 = expectMap(
1074
1073
  childObject.core
1075
- .testWithDifferentAccount(reader2, newRandomSessionID(reader2.id))
1074
+ .testWithDifferentAccount(reader2, Crypto.newRandomSessionID(reader2.id))
1076
1075
  .getCurrentContent(),
1077
1076
  );
1078
1077
 
@@ -1083,7 +1082,7 @@ test("Admins can set group read rey, make a private transaction in an owned obje
1083
1082
  expect(
1084
1083
  expectMap(
1085
1084
  childObject.core
1086
- .testWithDifferentAccount(reader, newRandomSessionID(reader.id))
1085
+ .testWithDifferentAccount(reader, Crypto.newRandomSessionID(reader.id))
1087
1086
  .getCurrentContent(),
1088
1087
  ).get("foo3"),
1089
1088
  ).toBeUndefined();
@@ -1151,7 +1150,7 @@ test("Admins can create an adminInvite, which can add an admin", () => {
1151
1150
  groupCore
1152
1151
  .testWithDifferentAccount(
1153
1152
  new ControlledAgent(inviteSecret, Crypto),
1154
- newRandomSessionID(inviteID),
1153
+ Crypto.newRandomSessionID(inviteID),
1155
1154
  )
1156
1155
  .getCurrentContent(),
1157
1156
  );
@@ -1198,7 +1197,7 @@ test("Admins can create an adminInvite, which can add an admin (high-level)", as
1198
1197
 
1199
1198
  const nodeAsInvitedAdmin = node.testWithDifferentAccount(
1200
1199
  new ControlledAgent(invitedAdminSecret, Crypto),
1201
- newRandomSessionID(invitedAdminID),
1200
+ Crypto.newRandomSessionID(invitedAdminID),
1202
1201
  );
1203
1202
 
1204
1203
  await nodeAsInvitedAdmin.acceptInvite(group.id, inviteSecret);
@@ -1261,7 +1260,7 @@ test("Admins can create a writerInvite, which can add a writer", () => {
1261
1260
  groupCore
1262
1261
  .testWithDifferentAccount(
1263
1262
  new ControlledAgent(inviteSecret, Crypto),
1264
- newRandomSessionID(inviteID),
1263
+ Crypto.newRandomSessionID(inviteID),
1265
1264
  )
1266
1265
  .getCurrentContent(),
1267
1266
  );
@@ -1308,7 +1307,7 @@ test("Admins can create a writerInvite, which can add a writer (high-level)", as
1308
1307
 
1309
1308
  const nodeAsInvitedWriter = node.testWithDifferentAccount(
1310
1309
  new ControlledAgent(invitedWriterSecret, Crypto),
1311
- newRandomSessionID(invitedWriterID),
1310
+ Crypto.newRandomSessionID(invitedWriterID),
1312
1311
  );
1313
1312
 
1314
1313
  await nodeAsInvitedWriter.acceptInvite(group.id, inviteSecret);
@@ -1364,7 +1363,7 @@ test("Admins can create a readerInvite, which can add a reader", () => {
1364
1363
  groupCore
1365
1364
  .testWithDifferentAccount(
1366
1365
  new ControlledAgent(inviteSecret, Crypto),
1367
- newRandomSessionID(inviteID),
1366
+ Crypto.newRandomSessionID(inviteID),
1368
1367
  )
1369
1368
  .getCurrentContent(),
1370
1369
  );
@@ -1401,7 +1400,7 @@ test("Admins can create a readerInvite, which can add a reader (high-level)", as
1401
1400
 
1402
1401
  const nodeAsInvitedReader = node.testWithDifferentAccount(
1403
1402
  new ControlledAgent(invitedReaderSecret, Crypto),
1404
- newRandomSessionID(invitedReaderID),
1403
+ Crypto.newRandomSessionID(invitedReaderID),
1405
1404
  );
1406
1405
 
1407
1406
  await nodeAsInvitedReader.acceptInvite(group.id, inviteSecret);
@@ -1457,7 +1456,7 @@ test("WriterInvites can not invite admins", () => {
1457
1456
  groupCore
1458
1457
  .testWithDifferentAccount(
1459
1458
  new ControlledAgent(inviteSecret, Crypto),
1460
- newRandomSessionID(inviteID),
1459
+ Crypto.newRandomSessionID(inviteID),
1461
1460
  )
1462
1461
  .getCurrentContent(),
1463
1462
  );
@@ -1511,7 +1510,7 @@ test("ReaderInvites can not invite admins", () => {
1511
1510
  groupCore
1512
1511
  .testWithDifferentAccount(
1513
1512
  new ControlledAgent(inviteSecret, Crypto),
1514
- newRandomSessionID(inviteID),
1513
+ Crypto.newRandomSessionID(inviteID),
1515
1514
  )
1516
1515
  .getCurrentContent(),
1517
1516
  );
@@ -1565,7 +1564,7 @@ test("ReaderInvites can not invite writers", () => {
1565
1564
  groupCore
1566
1565
  .testWithDifferentAccount(
1567
1566
  new ControlledAgent(inviteSecret, Crypto),
1568
- newRandomSessionID(inviteID),
1567
+ Crypto.newRandomSessionID(inviteID),
1569
1568
  )
1570
1569
  .getCurrentContent(),
1571
1570
  );
@@ -1610,7 +1609,7 @@ test("Can give read permission to 'everyone'", () => {
1610
1609
  childObject
1611
1610
  .testWithDifferentAccount(
1612
1611
  newAccount,
1613
- newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
1612
+ Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
1614
1613
  )
1615
1614
  .getCurrentContent(),
1616
1615
  );
@@ -1639,7 +1638,7 @@ test("Can give read permissions to 'everyone' (high-level)", async () => {
1639
1638
  childObject.core
1640
1639
  .testWithDifferentAccount(
1641
1640
  new ControlledAgent(Crypto.newRandomAgentSecret(), Crypto),
1642
- newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
1641
+ Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
1643
1642
  )
1644
1643
  .getCurrentContent(),
1645
1644
  );
@@ -1680,7 +1679,7 @@ test("Can give write permission to 'everyone'", async () => {
1680
1679
  childObject
1681
1680
  .testWithDifferentAccount(
1682
1681
  newAccount,
1683
- newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
1682
+ Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
1684
1683
  )
1685
1684
  .getCurrentContent(),
1686
1685
  );
@@ -1715,7 +1714,7 @@ test("Can give write permissions to 'everyone' (high-level)", async () => {
1715
1714
  childObject.core
1716
1715
  .testWithDifferentAccount(
1717
1716
  newAccount,
1718
- newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
1717
+ Crypto.newRandomSessionID(newAccount.currentAgentID()._unsafeUnwrap()),
1719
1718
  )
1720
1719
  .getCurrentContent(),
1721
1720
  );
@@ -0,0 +1,75 @@
1
+ import { expect, test, describe } from "vitest";
2
+ import { WasmCrypto } from "../index.js";
3
+ import { LocalNode } from "../localNode.js";
4
+ import { randomAnonymousAccountAndSessionID } from "./testUtils.js";
5
+ import { getPriorityFromHeader, CO_VALUE_PRIORITY } from "../priority.js";
6
+
7
+ const Crypto = await WasmCrypto.create();
8
+
9
+ describe("getPriorityFromHeader", () => {
10
+ test("returns MEDIUM priority for boolean or undefined headers", () => {
11
+ expect(getPriorityFromHeader(true)).toEqual(CO_VALUE_PRIORITY.MEDIUM);
12
+ expect(getPriorityFromHeader(false)).toEqual(CO_VALUE_PRIORITY.MEDIUM);
13
+ expect(getPriorityFromHeader(undefined)).toEqual(CO_VALUE_PRIORITY.MEDIUM);
14
+ });
15
+
16
+ test("returns MEDIUM priority for costream type", () => {
17
+ const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
18
+ const costream = node.createCoValue({
19
+ type: "costream",
20
+ ruleset: { type: "unsafeAllowAll" },
21
+ meta: null,
22
+ ...Crypto.createdNowUnique(),
23
+ });
24
+
25
+ expect(getPriorityFromHeader(costream.header)).toEqual(CO_VALUE_PRIORITY.MEDIUM);
26
+ });
27
+
28
+ test("returns LOW priority for binary costream type", () => {
29
+ const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
30
+ const costream = node.createCoValue({
31
+ type: "costream",
32
+ ruleset: { type: "unsafeAllowAll" },
33
+ meta: { type: "binary" },
34
+ ...Crypto.createdNowUnique(),
35
+ });
36
+
37
+ expect(getPriorityFromHeader(costream.header)).toEqual(CO_VALUE_PRIORITY.LOW);
38
+ });
39
+
40
+ test("returns HIGH priority for account type", async () => {
41
+ const node =new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
42
+
43
+ const account = node.createAccount(node.crypto.newRandomAgentSecret());
44
+
45
+ expect(getPriorityFromHeader(account.core.header)).toEqual(CO_VALUE_PRIORITY.HIGH);
46
+ });
47
+
48
+ test("returns HIGH priority for group type", () => {
49
+ const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
50
+ const group = node.createGroup();
51
+
52
+ expect(getPriorityFromHeader(group.core.header)).toEqual(CO_VALUE_PRIORITY.HIGH);
53
+ });
54
+
55
+ test("returns MEDIUM priority for other types", () => {
56
+ const node = new LocalNode(...randomAnonymousAccountAndSessionID(), Crypto);
57
+
58
+ const comap = node.createCoValue({
59
+ type: "comap",
60
+ ruleset: { type: "unsafeAllowAll" },
61
+ meta: null,
62
+ ...Crypto.createdNowUnique(),
63
+ });
64
+
65
+ const colist = node.createCoValue({
66
+ type: "colist",
67
+ ruleset: { type: "unsafeAllowAll" },
68
+ meta: null,
69
+ ...Crypto.createdNowUnique(),
70
+ });
71
+
72
+ expect(getPriorityFromHeader(comap.header)).toEqual(CO_VALUE_PRIORITY.MEDIUM);
73
+ expect(getPriorityFromHeader(colist.header)).toEqual(CO_VALUE_PRIORITY.MEDIUM);
74
+ });
75
+ });