cojson 0.7.35-guest-auth.5 → 0.7.35

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