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.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +3 -8
- package/dist/PeerState.js +58 -0
- package/dist/PeerState.js.map +1 -0
- package/dist/PriorityBasedMessageQueue.js +51 -0
- package/dist/PriorityBasedMessageQueue.js.map +1 -0
- package/dist/base64url.js.map +1 -1
- package/dist/coValue.js.map +1 -1
- package/dist/coValueCore.js +9 -0
- package/dist/coValueCore.js.map +1 -1
- package/dist/coValues/account.js +3 -2
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +14 -15
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/group.js +8 -8
- package/dist/coValues/group.js.map +1 -1
- package/dist/coreToCoValue.js.map +1 -1
- package/dist/crypto/PureJSCrypto.js.map +1 -1
- package/dist/crypto/WasmCrypto.js.map +1 -1
- package/dist/crypto/crypto.js +0 -3
- package/dist/crypto/crypto.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/jsonStringify.js.map +1 -1
- package/dist/localNode.js +9 -9
- package/dist/localNode.js.map +1 -1
- package/dist/permissions.js.map +1 -1
- package/dist/priority.js +31 -0
- package/dist/priority.js.map +1 -0
- package/dist/storage/FileSystem.js.map +1 -1
- package/dist/storage/chunksAndKnownStates.js +2 -0
- package/dist/storage/chunksAndKnownStates.js.map +1 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/streamUtils.js.map +1 -1
- package/dist/sync.js +7 -18
- package/dist/sync.js.map +1 -1
- package/dist/tests/PeerState.test.js +80 -0
- package/dist/tests/PeerState.test.js.map +1 -0
- package/dist/tests/PriorityBasedMessageQueue.test.js +97 -0
- package/dist/tests/PriorityBasedMessageQueue.test.js.map +1 -0
- package/dist/tests/account.test.js +2 -1
- package/dist/tests/account.test.js.map +1 -1
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coStream.test.js +34 -1
- package/dist/tests/coStream.test.js.map +1 -1
- package/dist/tests/permissions.test.js +42 -41
- package/dist/tests/permissions.test.js.map +1 -1
- package/dist/tests/priority.test.js +61 -0
- package/dist/tests/priority.test.js.map +1 -0
- package/dist/tests/sync.test.js +328 -16
- package/dist/tests/sync.test.js.map +1 -1
- package/dist/tests/testUtils.js +2 -1
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/typeUtils/accountOrAgentIDfromSessionID.js.map +1 -1
- package/dist/typeUtils/expectGroup.js.map +1 -1
- package/dist/typeUtils/isAccountID.js.map +1 -1
- package/package.json +3 -3
- package/src/PeerState.ts +74 -0
- package/src/PriorityBasedMessageQueue.ts +77 -0
- package/src/coValueCore.ts +18 -7
- package/src/coValues/account.ts +6 -5
- package/src/coValues/coList.ts +4 -4
- package/src/coValues/coMap.ts +3 -3
- package/src/coValues/coStream.ts +29 -26
- package/src/coValues/group.ts +11 -15
- package/src/crypto/crypto.ts +0 -5
- package/src/ids.ts +2 -2
- package/src/index.ts +7 -5
- package/src/localNode.ts +18 -18
- package/src/permissions.ts +5 -5
- package/src/priority.ts +39 -0
- package/src/storage/chunksAndKnownStates.ts +2 -0
- package/src/sync.ts +19 -34
- package/src/tests/PeerState.test.ts +92 -0
- package/src/tests/PriorityBasedMessageQueue.test.ts +111 -0
- package/src/tests/account.test.ts +2 -1
- package/src/tests/coStream.test.ts +58 -1
- package/src/tests/permissions.test.ts +42 -41
- package/src/tests/priority.test.ts +75 -0
- package/src/tests/sync.test.ts +491 -28
- package/src/tests/testUtils.ts +2 -1
- package/src/typeUtils/accountOrAgentIDfromSessionID.ts +3 -3
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1027
|
+
newRandomSessionID(reader.id),
|
|
1027
1028
|
);
|
|
1028
1029
|
childObjectAsReader2 = childObject.testWithDifferentAccount(
|
|
1029
1030
|
reader2,
|
|
1030
|
-
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
});
|