@ibgib/ts-gib 0.5.0 → 0.5.2
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/CHANGELOG.md +8 -0
- package/README.md +22 -3
- package/dist/V1/transforms/index.d.mts +1 -1
- package/dist/V1/transforms/index.d.mts.map +1 -1
- package/dist/V1/transforms/index.mjs +1 -1
- package/dist/V1/transforms/index.mjs.map +1 -1
- package/dist/respec-gib.node.d.mts +2 -0
- package/dist/respec-gib.node.d.mts.map +1 -0
- package/dist/respec-gib.node.mjs +211 -0
- package/dist/respec-gib.node.mjs.map +1 -0
- package/package.json +10 -13
- package/src/V1/{factory.spec.mts → factory.respec.mts} +30 -28
- package/src/V1/{sha256v1.spec.mts → sha256v1.respec.mts} +23 -13
- package/src/V1/transforms/fork.spec.mts +126 -126
- package/src/V1/transforms/index.mts +1 -1
- package/src/V1/transforms/mut8.spec.mts +174 -174
- package/src/V1/transforms/rel8.spec.mts +109 -109
- package/src/V1/transforms/transform-helper.spec.mts +5 -5
- package/src/helper.respec.mts +62 -0
- package/src/respec-gib.node.mts +199 -0
- package/tsconfig.json +3 -1
- package/tsconfig.test.json +4 -2
- package/jasmine-browser.json +0 -18
- package/jasmine.json +0 -6
- package/src/helper.spec.mts +0 -59
|
@@ -73,10 +73,10 @@ function buildRel8nsToAddOrRemoveFromPrimitives(rel8nNames: string[]): IbGibRel8
|
|
|
73
73
|
return result;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
await respecfully(sir, `can't rel8 primitives to others`, async () => {
|
|
77
77
|
for (const src of PRIMITIVE_IBGIBS) {
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
await ifWe(sir, `should fail to add rel8ns`, async () => {
|
|
80
80
|
let errored = false;
|
|
81
81
|
try {
|
|
82
82
|
const rel8nsToAddByAddr = buildRel8nsToAddOrRemoveFromPrimitives(SIMPLE_REL8N_NAMES);
|
|
@@ -84,10 +84,10 @@ describe(`can't rel8 primitives to others`, () => {
|
|
|
84
84
|
} catch (error) {
|
|
85
85
|
errored = true;
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
iReckon(sir, errored).toBeTrue()
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
await ifWe(sir, `should fail to remove rel8ns`, async () => {
|
|
91
91
|
let errored = false;
|
|
92
92
|
try {
|
|
93
93
|
const rel8nsToRemoveByAddr = buildRel8nsToAddOrRemoveFromPrimitives(SIMPLE_REL8N_NAMES);
|
|
@@ -95,10 +95,10 @@ describe(`can't rel8 primitives to others`, () => {
|
|
|
95
95
|
} catch (error) {
|
|
96
96
|
errored = true;
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
iReckon(sir, errored).toBeTrue()
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
await ifWe(sir, `should fail to add and remove rel8ns`, async () => {
|
|
102
102
|
let errored = false;
|
|
103
103
|
try {
|
|
104
104
|
const rel8nsToAddByAddr =
|
|
@@ -109,18 +109,18 @@ describe(`can't rel8 primitives to others`, () => {
|
|
|
109
109
|
} catch (error) {
|
|
110
110
|
errored = true;
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
iReckon(sir, errored).toBeTrue()
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
await respecfully(sir, `when rel8ing a regular ibgib`, async () => {
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
await respecfully(sir, `simple rel8ns to 1st gens (from primitives)`, async () => {
|
|
121
121
|
for (const primitive of PRIMITIVE_IBGIBS) {
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
await ifWe(sir, `should add/remove simple rel8ns`, async () => {
|
|
124
124
|
|
|
125
125
|
let { newIbGib: src } = await fork({ src: primitive, noTimestamp: true });
|
|
126
126
|
|
|
@@ -133,18 +133,18 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
133
133
|
|
|
134
134
|
const { newIbGib: rel8nsAddedIbGib } =
|
|
135
135
|
await rel8({ src, rel8nsToAddByAddr, noTimestamp: true });
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
iReckon(sir, rel8nsAddedIbGib).isGonnaBeTruthy();
|
|
137
|
+
iReckon(sir, rel8nsAddedIbGib.rel8ns).isGonnaBeTruthy();
|
|
138
|
+
iReckon(sir, rel8nsAddedIbGib.rel8ns).isGonnaBeTruthy();
|
|
139
139
|
const rel8nNames_AddedIbGib = Object.keys(rel8nsAddedIbGib.rel8ns!);
|
|
140
140
|
SIMPLE_REL8N_NAMES.forEach(simpleRel8nName => {
|
|
141
|
-
|
|
141
|
+
iReckon(sir, rel8nNames_AddedIbGib).toContain(simpleRel8nName);
|
|
142
142
|
const simpleRel8nAddrs = rel8nsAddedIbGib.rel8ns![simpleRel8nName]!;
|
|
143
143
|
// expect(simpleRel8nAddrs).not.toHaveSize(0);
|
|
144
|
-
|
|
144
|
+
iReckon(sir, simpleRel8nAddrs).not.toHaveSize(0);
|
|
145
145
|
const expectedRel8nAddrs = rel8nsToAddByAddr[simpleRel8nName];
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
iReckon(sir, expectedRel8nAddrs).not.toHaveSize(0);
|
|
147
|
+
iReckon(sir, simpleRel8nAddrs).isGonnaBe(expectedRel8nAddrs!);
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
// #endregion
|
|
@@ -158,9 +158,9 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
158
158
|
|
|
159
159
|
const { newIbGib: rel8nsRemovedIbGib } =
|
|
160
160
|
await rel8({ src: rel8nsAddedIbGib, rel8nsToRemoveByAddr, noTimestamp: true });
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
iReckon(sir, rel8nsRemovedIbGib).isGonnaBeTruthy();
|
|
162
|
+
iReckon(sir, rel8nsRemovedIbGib.rel8ns).isGonnaBeTruthy();
|
|
163
|
+
iReckon(sir, rel8nsRemovedIbGib.rel8ns).isGonnaBeTruthy();
|
|
164
164
|
|
|
165
165
|
SIMPLE_REL8N_NAMES.forEach(simpleRel8nName => {
|
|
166
166
|
const rel8dAddrs = rel8nsRemovedIbGib.rel8ns![simpleRel8nName]!;
|
|
@@ -189,7 +189,7 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
189
189
|
* then for src2, we'll make the call from the dna generated from the src1 transforms.
|
|
190
190
|
* both should make the same transformations with regards to the rel8ns added/removed.
|
|
191
191
|
*/
|
|
192
|
-
|
|
192
|
+
await ifWe(sir, `should create pure, reproducible dna`, async () => {
|
|
193
193
|
|
|
194
194
|
const ib1 = 'ib 1 yo';
|
|
195
195
|
let { newIbGib: src1 } = await fork({ src: primitive, noTimestamp: true, destIb: ib1 });
|
|
@@ -206,19 +206,19 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
206
206
|
|
|
207
207
|
const { newIbGib: rel8nsAddedIbGib, intermediateIbGibs, dnas: dnasRel8Add } =
|
|
208
208
|
await rel8({ src: src1, rel8nsToAddByAddr, noTimestamp: true, dna: true });
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
iReckon(sir, dnasRel8Add).isGonnaBeTruthy();
|
|
210
|
+
iReckon(sir, dnasRel8Add).isGonnaBeTruthy();
|
|
211
211
|
// ATOW dna only produces 1
|
|
212
212
|
const rel8DnaAdd = dnasRel8Add![0];
|
|
213
213
|
const rel8DnaDataAdd: TransformOpts_Rel8<IbGib_V1> = clone(rel8DnaAdd.data!);
|
|
214
214
|
const rel8nNames_AddedIbGib = Object.keys(rel8nsAddedIbGib.rel8ns!);
|
|
215
215
|
SIMPLE_REL8N_NAMES.forEach(simpleRel8nName => {
|
|
216
|
-
|
|
216
|
+
iReckon(sir, rel8nNames_AddedIbGib).toContain(simpleRel8nName);
|
|
217
217
|
const simpleRel8nAddrs = rel8nsAddedIbGib.rel8ns![simpleRel8nName]!;
|
|
218
|
-
|
|
218
|
+
iReckon(sir, simpleRel8nAddrs).not.toHaveSize(0);
|
|
219
219
|
const expectedRel8nAddrs = rel8nsToAddByAddr[simpleRel8nName];
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
iReckon(sir, expectedRel8nAddrs).not.toHaveSize(0);
|
|
221
|
+
iReckon(sir, simpleRel8nAddrs).isGonnaBe(expectedRel8nAddrs!);
|
|
222
222
|
});
|
|
223
223
|
|
|
224
224
|
// rerun the same rel8 call, but get the args from the dna of the
|
|
@@ -230,12 +230,12 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
230
230
|
await rel8(rel8DnaDataAdd);
|
|
231
231
|
const rel8nNames_AddedIbGib2 = Object.keys(rel8nsAddedIbGib2.rel8ns!);
|
|
232
232
|
SIMPLE_REL8N_NAMES.forEach(simpleRel8nName => {
|
|
233
|
-
|
|
233
|
+
iReckon(sir, rel8nNames_AddedIbGib2).toContain(simpleRel8nName);
|
|
234
234
|
const simpleRel8nAddrs = rel8nsAddedIbGib2.rel8ns![simpleRel8nName]!;
|
|
235
|
-
|
|
235
|
+
iReckon(sir, simpleRel8nAddrs).not.toHaveSize(0);
|
|
236
236
|
const expectedRel8nAddrs = rel8nsToAddByAddr[simpleRel8nName];
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
iReckon(sir, expectedRel8nAddrs).not.toHaveSize(0);
|
|
238
|
+
iReckon(sir, simpleRel8nAddrs).isGonnaBe(expectedRel8nAddrs!);
|
|
239
239
|
});
|
|
240
240
|
|
|
241
241
|
// #endregion
|
|
@@ -298,15 +298,15 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
298
298
|
//#endregion
|
|
299
299
|
});
|
|
300
300
|
|
|
301
|
-
|
|
301
|
+
await ifWe(sir, `should rel8 linked rel8ns to make only one rel8n`, async () => {
|
|
302
302
|
// linkedRel8ns should produce a rel8n that only has one target
|
|
303
303
|
let testRel8nName = 'test';
|
|
304
304
|
let { newIbGib: src1 } =
|
|
305
305
|
await fork({ src: primitive, linkedRel8ns: ['past', 'ancestor'] });
|
|
306
306
|
let src1Addr = getIbGibAddr({ ibGib: src1 });
|
|
307
|
-
|
|
307
|
+
iReckon(sir, (src1?.rel8ns?.past || []).length).asTo('src1.rel8ns.past.length').isGonnaBe(0);
|
|
308
308
|
if (primitive.ib !== 'ib') {
|
|
309
|
-
|
|
309
|
+
iReckon(sir, (src1?.rel8ns?.ancestor || []).length).asTo('src1.rel8ns.ancestor.length').isGonnaBe(1);
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
let { newIbGib: src2 } =
|
|
@@ -315,12 +315,12 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
315
315
|
rel8nsToAddByAddr: { [testRel8nName]: ['a^gib'] },
|
|
316
316
|
linkedRel8ns: ['past', 'ancestor', testRel8nName],
|
|
317
317
|
});
|
|
318
|
-
|
|
318
|
+
iReckon(sir, (src2?.rel8ns?.past || []).length).asTo('src2.rel8ns.past.length').isGonnaBe(1);
|
|
319
319
|
if (primitive.ib !== 'ib') {
|
|
320
|
-
|
|
320
|
+
iReckon(sir, (src2?.rel8ns?.ancestor || []).length).asTo('src2.rel8ns.ancestor.length').isGonnaBe(1);
|
|
321
321
|
}
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
iReckon(sir, (src2?.rel8ns![testRel8nName] || []).length).asTo(`src2.rel8ns.${testRel8nName}.length`).isGonnaBe(1);
|
|
323
|
+
iReckon(sir, src2?.rel8ns![testRel8nName]![0]).asTo(`src2.rel8ns.${testRel8nName}[0]`).isGonnaBe('a^gib');
|
|
324
324
|
|
|
325
325
|
let { newIbGib: src3 } =
|
|
326
326
|
await rel8({
|
|
@@ -328,16 +328,16 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
328
328
|
rel8nsToAddByAddr: { [testRel8nName]: ['b^gib'] },
|
|
329
329
|
linkedRel8ns: ['past', 'ancestor', testRel8nName],
|
|
330
330
|
});
|
|
331
|
-
|
|
331
|
+
iReckon(sir, (src3?.rel8ns?.past || []).length).asTo('src3.rel8ns.past.length').isGonnaBe(1);
|
|
332
332
|
if (primitive.ib !== 'ib') {
|
|
333
|
-
|
|
333
|
+
iReckon(sir, (src3?.rel8ns?.ancestor || []).length).asTo('src3.rel8ns.ancestor.length').isGonnaBe(1);
|
|
334
334
|
}
|
|
335
|
-
|
|
336
|
-
|
|
335
|
+
iReckon(sir, (src3?.rel8ns![testRel8nName] || []).length).asTo(`src3.rel8ns.${testRel8nName}.length`).isGonnaBe(1);
|
|
336
|
+
iReckon(sir, src3?.rel8ns![testRel8nName]![0]).asTo(`src3.rel8ns.${testRel8nName}[0]`).isGonnaBe('b^gib');
|
|
337
337
|
|
|
338
338
|
});
|
|
339
339
|
|
|
340
|
-
|
|
340
|
+
await ifWe(sir, `should rel8 tjp ASAP, i.e. first rel8 after fork, also shoehorned tjpGib testing`, async () => {
|
|
341
341
|
// the tjp rel8n should be set ASAP because it's very important.
|
|
342
342
|
// so if the first transform after fork is a rel8, then do it there.
|
|
343
343
|
const testRel8ns = { irrelevant: ['ib^gib'] };
|
|
@@ -345,30 +345,30 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
345
345
|
await fork({ src: primitive, tjp: { uuid: true, timestamp: true } });
|
|
346
346
|
const tjpAddr = getIbGibAddr({ ibGib: tjpIbGib });
|
|
347
347
|
const tjpAddrGib = getIbAndGib({ ibGibAddr: tjpAddr }).gib;
|
|
348
|
-
|
|
349
|
-
|
|
348
|
+
iReckon(sir, tjpIbGib?.data?.isTjp).asTo('src1.data.isTjp').isGonnaBeTruthy();
|
|
349
|
+
iReckon(sir, tjpIbGib?.rel8ns?.tjp).asTo('src1.rel8ns.tjp').toBeUndefined();
|
|
350
350
|
const { newIbGib: hasRel8dTjp } =
|
|
351
351
|
await rel8({ src: tjpIbGib, rel8nsToAddByAddr: testRel8ns });
|
|
352
352
|
const hasRel8dTjpAddr = getIbGibAddr({ ibGib: hasRel8dTjp });
|
|
353
353
|
const hasRel8dTjpAddrGib = getIbAndGib({ ibGibAddr: hasRel8dTjpAddr }).gib;
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
354
|
+
iReckon(sir, hasRel8dTjp?.data?.isTjp).asTo('src2.data.isTjp').toBeUndefined();
|
|
355
|
+
iReckon(sir, hasRel8dTjp?.rel8ns?.tjp).asTo('src2.rel8ns.tjp').isGonnaBeTruthy();
|
|
356
|
+
iReckon(sir, hasRel8dTjp!.rel8ns!.tjp!.length).asTo('src2.rel8ns.tjp.length').isGonnaBe(1);
|
|
357
|
+
iReckon(sir, hasRel8dTjp!.rel8ns!.tjp!).toContain(tjpAddr);
|
|
358
358
|
|
|
359
359
|
// the gib should not just be the hash, since it has a tjp timeline
|
|
360
|
-
|
|
360
|
+
iReckon(sir, hasRel8dTjpAddrGib).toContain(tjpAddrGib);
|
|
361
361
|
|
|
362
362
|
// shoe-horning in here some getGibInfo testing...eesh
|
|
363
363
|
const hasRel8dTjpGibInfo = getGibInfo({ ibGibAddr: hasRel8dTjpAddr }); // via addr
|
|
364
|
-
|
|
365
|
-
|
|
364
|
+
iReckon(sir, hasRel8dTjpGibInfo.isPrimitive).toBeUndefined();
|
|
365
|
+
iReckon(sir, hasRel8dTjpGibInfo.piecesCount).isGonnaBe(2, 'pieces count');
|
|
366
366
|
const hasRel8dTjpHash = await sha256v1(hasRel8dTjp, '');
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
iReckon(sir, hasRel8dTjpGibInfo.punctiliarHash).isGonnaBe(hasRel8dTjpHash, 'punctiliarHash');
|
|
368
|
+
iReckon(sir, hasRel8dTjpGibInfo.tjpGib).isGonnaBe(tjpAddrGib);
|
|
369
369
|
// the info should be the same if we get it straight from the gib
|
|
370
370
|
const hasRel8dTjpGibInfo_viaGib = getGibInfo({ gib: hasRel8dTjpAddrGib }); // via gib
|
|
371
|
-
|
|
371
|
+
iReckon(sir, hasRel8dTjpGibInfo_viaGib).isGonnaBe(hasRel8dTjpGibInfo, 'infos via addr and gib should be equal');
|
|
372
372
|
|
|
373
373
|
// ok, yes my testing is out of control, but I'm going to shoehorn in here
|
|
374
374
|
// another rel8 and make sure that the punctiliar hash is correct and the gib only has two pieces.
|
|
@@ -378,22 +378,22 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
378
378
|
const thirdGenAddr = getIbGibAddr({ ibGib: thirdGenIbGib });
|
|
379
379
|
const thirdGenGibInfo = getGibInfo({ ibGibAddr: thirdGenAddr });
|
|
380
380
|
const thirdGenHash = await sha256v1(thirdGenIbGib, '');
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
iReckon(sir, thirdGenGibInfo.punctiliarHash).isGonnaBe(thirdGenHash);
|
|
382
|
+
iReckon(sir, thirdGenGibInfo.tjpGib).isGonnaBe(tjpAddrGib, 'third gen match tjpAddrGib');
|
|
383
|
+
iReckon(sir, thirdGenGibInfo.piecesCount).isGonnaBe(2, 'third gen pieces');
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
386
|
});
|
|
387
387
|
|
|
388
|
-
|
|
389
|
-
|
|
388
|
+
await respecfully(sir, `nCounter`, async () => {
|
|
389
|
+
await ifWe(sir, `should increment existing n counter`, async () => {
|
|
390
390
|
for (const primitive of PRIMITIVE_IBGIBS) {
|
|
391
391
|
let { newIbGib: src_0 } =
|
|
392
392
|
await fork({ src: primitive, nCounter: true });
|
|
393
393
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
iReckon(sir, src_0.data).isGonnaBeTruthy();
|
|
395
|
+
iReckon(sir, src_0.data!.n).isGonnaBe(0);
|
|
396
|
+
iReckon(sir, src_0!.data?.isTjp).asTo("isTjp").toBeUndefined();
|
|
397
397
|
|
|
398
398
|
const rel8nsToAddByAddr = buildRel8nsToAddOrRemoveFromPrimitives(SIMPLE_REL8N_NAMES);
|
|
399
399
|
|
|
@@ -407,35 +407,35 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
407
407
|
noTimestamp: true,
|
|
408
408
|
nCounter: true
|
|
409
409
|
});
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
410
|
+
iReckon(sir, src_1).isGonnaBeTruthy();
|
|
411
|
+
iReckon(sir, src_1.rel8ns).isGonnaBeTruthy();
|
|
412
|
+
iReckon(sir, src_1.rel8ns).isGonnaBeTruthy();
|
|
413
413
|
const rel8nNames_AddedIbGib = Object.keys(src_1.rel8ns!);
|
|
414
414
|
SIMPLE_REL8N_NAMES.forEach(simpleRel8nName => {
|
|
415
|
-
|
|
415
|
+
iReckon(sir, rel8nNames_AddedIbGib).toContain(simpleRel8nName);
|
|
416
416
|
const simpleRel8nAddrs = src_1.rel8ns![simpleRel8nName]!;
|
|
417
|
-
|
|
417
|
+
iReckon(sir, simpleRel8nAddrs).not.toHaveSize(0);
|
|
418
418
|
const expectedRel8nAddrs = rel8nsToAddByAddr[simpleRel8nName];
|
|
419
|
-
|
|
420
|
-
|
|
419
|
+
iReckon(sir, expectedRel8nAddrs).not.toHaveSize(0);
|
|
420
|
+
iReckon(sir, simpleRel8nAddrs).isGonnaBe(expectedRel8nAddrs!);
|
|
421
421
|
});
|
|
422
422
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
423
|
+
iReckon(sir, src_1.data).isGonnaBeTruthy();
|
|
424
|
+
iReckon(sir, src_1.data).isGonnaBeTruthy();
|
|
425
|
+
iReckon(sir, src_1.data!.n).isGonnaBeTruthy();
|
|
426
|
+
iReckon(sir, src_1.data!.n).isGonnaBeTruthy();
|
|
427
|
+
iReckon(sir, src_1.data!.n).isGonnaBe(1);
|
|
428
|
+
iReckon(sir, src_1!.data?.isTjp).asTo("isTjp").toBeUndefined();
|
|
429
429
|
}
|
|
430
430
|
});
|
|
431
|
-
|
|
431
|
+
await ifWe(sir, `should start new n counter, implicit nCounter falsy`, async () => {
|
|
432
432
|
for (const primitive of PRIMITIVE_IBGIBS) {
|
|
433
433
|
let { newIbGib: src_0 } =
|
|
434
434
|
await fork({ src: primitive });
|
|
435
435
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
436
|
+
iReckon(sir, src_0.data).isGonnaBeTruthy();
|
|
437
|
+
iReckon(sir, src_0.data).isGonnaBeTruthy();
|
|
438
|
+
iReckon(sir, src_0.data!.n).toBeUndefined();
|
|
439
439
|
|
|
440
440
|
const rel8nsToAddByAddr = buildRel8nsToAddOrRemoveFromPrimitives(SIMPLE_REL8N_NAMES);
|
|
441
441
|
|
|
@@ -449,32 +449,32 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
449
449
|
noTimestamp: true,
|
|
450
450
|
nCounter: true
|
|
451
451
|
});
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
452
|
+
iReckon(sir, src_1).isGonnaBeTruthy();
|
|
453
|
+
iReckon(sir, src_1.rel8ns).isGonnaBeTruthy();
|
|
454
|
+
iReckon(sir, src_1.rel8ns).isGonnaBeTruthy();
|
|
455
455
|
const rel8nNames_AddedIbGib = Object.keys(src_1.rel8ns!);
|
|
456
456
|
SIMPLE_REL8N_NAMES.forEach(simpleRel8nName => {
|
|
457
|
-
|
|
457
|
+
iReckon(sir, rel8nNames_AddedIbGib).toContain(simpleRel8nName);
|
|
458
458
|
const simpleRel8nAddrs = src_1.rel8ns![simpleRel8nName]!;
|
|
459
|
-
|
|
459
|
+
iReckon(sir, simpleRel8nAddrs).not.toHaveSize(0);
|
|
460
460
|
const expectedRel8nAddrs = rel8nsToAddByAddr[simpleRel8nName];
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
iReckon(sir, expectedRel8nAddrs).not.toHaveSize(0);
|
|
462
|
+
iReckon(sir, simpleRel8nAddrs).isGonnaBe(expectedRel8nAddrs!);
|
|
463
463
|
});
|
|
464
464
|
|
|
465
|
-
|
|
466
|
-
|
|
465
|
+
iReckon(sir, src_1.data).isGonnaBeTruthy();
|
|
466
|
+
iReckon(sir, src_1.data!.n).isGonnaBe(0);
|
|
467
467
|
}
|
|
468
468
|
});
|
|
469
|
-
|
|
469
|
+
await ifWe(sir, `should start new n counter, explicit nCounter falsy`, async () => {
|
|
470
470
|
for (const primitive of PRIMITIVE_IBGIBS) {
|
|
471
471
|
let { newIbGib: src_0 } =
|
|
472
472
|
await fork({ src: primitive, nCounter: false });
|
|
473
473
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
474
|
+
iReckon(sir, src_0.data).isGonnaBeTruthy();
|
|
475
|
+
iReckon(sir, src_0.data).isGonnaBeTruthy();
|
|
476
|
+
iReckon(sir, src_0.data!.n).toBeUndefined();
|
|
477
|
+
iReckon(sir, src_0!.data!.isTjp).asTo("isTjp").toBeUndefined();
|
|
478
478
|
|
|
479
479
|
const rel8nsToAddByAddr = buildRel8nsToAddOrRemoveFromPrimitives(SIMPLE_REL8N_NAMES);
|
|
480
480
|
|
|
@@ -488,22 +488,22 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
488
488
|
noTimestamp: true,
|
|
489
489
|
nCounter: true
|
|
490
490
|
});
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
491
|
+
iReckon(sir, src_1).isGonnaBeTruthy();
|
|
492
|
+
iReckon(sir, src_1.rel8ns).isGonnaBeTruthy();
|
|
493
|
+
iReckon(sir, src_1.rel8ns).isGonnaBeTruthy();
|
|
494
494
|
const rel8nNames_AddedIbGib = Object.keys(src_1.rel8ns!);
|
|
495
495
|
SIMPLE_REL8N_NAMES.forEach(simpleRel8nName => {
|
|
496
|
-
|
|
496
|
+
iReckon(sir, rel8nNames_AddedIbGib).toContain(simpleRel8nName);
|
|
497
497
|
const simpleRel8nAddrs = src_1.rel8ns![simpleRel8nName]!;
|
|
498
|
-
|
|
498
|
+
iReckon(sir, simpleRel8nAddrs).not.toHaveSize(0);
|
|
499
499
|
const expectedRel8nAddrs = rel8nsToAddByAddr[simpleRel8nName];
|
|
500
|
-
|
|
501
|
-
|
|
500
|
+
iReckon(sir, expectedRel8nAddrs).not.toHaveSize(0);
|
|
501
|
+
iReckon(sir, simpleRel8nAddrs).isGonnaBe(expectedRel8nAddrs!);
|
|
502
502
|
});
|
|
503
503
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
504
|
+
iReckon(sir, src_1.data).isGonnaBeTruthy();
|
|
505
|
+
iReckon(sir, src_1.data!.n).isGonnaBe(0);
|
|
506
|
+
iReckon(sir, src_1!.data!.isTjp).asTo("isTjp").toBeUndefined();
|
|
507
507
|
}
|
|
508
508
|
});
|
|
509
509
|
// for (const primitive of PRIMITIVE_IBGIBS) {
|
|
@@ -518,15 +518,15 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
518
518
|
// dataToAddOrPatch: DATA_SIMPLE_XY,
|
|
519
519
|
// nCounter: true
|
|
520
520
|
// });
|
|
521
|
-
// expect(src_1.data).
|
|
522
|
-
// expect(src_1.data!.n).
|
|
521
|
+
// expect(src_1.data).isGonnaBeTruthy();
|
|
522
|
+
// expect(src_1.data!.n).isGonnaBe(0);
|
|
523
523
|
// }
|
|
524
524
|
// });
|
|
525
525
|
|
|
526
526
|
});
|
|
527
527
|
|
|
528
|
-
|
|
529
|
-
|
|
528
|
+
await respecfully(sir, `when rel8 with dna`, async () => {
|
|
529
|
+
await ifWe(sir, `should have gibs that is corroborated with getGib`, async () => {
|
|
530
530
|
for (const primitive of PRIMITIVE_IBGIBS) {
|
|
531
531
|
let { newIbGib: src_0 } =
|
|
532
532
|
await fork({ src: primitive, nCounter: false, dna: true });
|
|
@@ -549,7 +549,7 @@ describe(`when rel8ing a regular ibgib`, () => {
|
|
|
549
549
|
for (let i = 0; i < ibGibs.length; i++) {
|
|
550
550
|
const ibGib = ibGibs[i];
|
|
551
551
|
const gottenGib = await getGib({ ibGib });
|
|
552
|
-
|
|
552
|
+
iReckon(sir, ibGib.gib).isGonnaBe(gottenGib);
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
});
|
|
@@ -25,21 +25,21 @@ const PRIMITIVE_IBGIBS = [
|
|
|
25
25
|
}),
|
|
26
26
|
];
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
await respecfully(sir, `isDna`, async () => {
|
|
29
29
|
for (const src of PRIMITIVE_IBGIBS) {
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
await ifWe(sir, `should return true for dna ibgibs`, async () => {
|
|
32
32
|
const resFork = await fork({ src, dna: true });
|
|
33
33
|
resFork.dnas?.every(x => {
|
|
34
34
|
const resIsDna = isDna({ ibGib: x });
|
|
35
|
-
|
|
35
|
+
iReckon(sir, resIsDna).toBeTrue()
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
await ifWe(sir, `should return false for non-dna ibgibs`, async () => {
|
|
40
40
|
const resFork = await fork({ src, dna: true });
|
|
41
41
|
const resIsDna = isDna({ ibGib: resFork.newIbGib });
|
|
42
|
-
|
|
42
|
+
iReckon(sir, resIsDna).toBeFalse();
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ifWe, ifWeMight, iReckon, respecfully } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
2
|
+
const maam = `[${import.meta.url}]`, sir = maam;
|
|
3
|
+
|
|
4
|
+
import { getIbAndGib, getIbGibAddr } from './helper.mjs';
|
|
5
|
+
import { Ib, IbGib } from './types.mjs';
|
|
6
|
+
import { ROOT, ROOT_ADDR } from './V1/constants.mjs';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
await respecfully(sir, `getIbGibAddr`, async () => {
|
|
10
|
+
// unsure if these would change when not in V1...(these tests are outside V1 atow)
|
|
11
|
+
|
|
12
|
+
await ifWe(sir, `should get the right addr for ROOT`, async () => {
|
|
13
|
+
let ibGib = ROOT;
|
|
14
|
+
let gotten = getIbGibAddr({ ibGib });
|
|
15
|
+
iReckon(sir, gotten).isGonnaBeTruthy();
|
|
16
|
+
iReckon(sir, gotten).isGonnaBe(ROOT_ADDR);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
await ifWe(sir, `should get the right addr for primitives`, async () => {
|
|
20
|
+
let ibs: Ib[] = ['7', 'foo', 'ibgib', 'wakka doodle'];
|
|
21
|
+
for (let i = 0; i < ibs.length; i++) {
|
|
22
|
+
const ib = ibs[i];
|
|
23
|
+
let ibGib: IbGib = { ib, gib: 'gib' };
|
|
24
|
+
let gotten = getIbGibAddr({ ibGib });
|
|
25
|
+
iReckon(sir, gotten).isGonnaBeTruthy();
|
|
26
|
+
iReckon(sir, gotten).isGonnaBe(`${ib}^gib`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
await respecfully(sir, `getIbAndGib`, async () => {
|
|
33
|
+
// unsure if these would change when not in V1...(these tests are outside V1 atow)
|
|
34
|
+
|
|
35
|
+
await ifWe(sir, `should get the right ib & gib for ROOT, with ibGib param`, async () => {
|
|
36
|
+
let ibGib = ROOT;
|
|
37
|
+
let gotten = getIbAndGib({ ibGib });
|
|
38
|
+
iReckon(sir, gotten).isGonnaBeTruthy();
|
|
39
|
+
iReckon(sir, gotten.ib).isGonnaBe('ib');
|
|
40
|
+
iReckon(sir, gotten.gib).isGonnaBe('gib');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await ifWe(sir, `should get the right ib & gib for ROOT_ADDR, with ibGibAddr param`, async () => {
|
|
44
|
+
let gotten = getIbAndGib({ ibGibAddr: ROOT_ADDR });
|
|
45
|
+
iReckon(sir, gotten).isGonnaBeTruthy();
|
|
46
|
+
iReckon(sir, gotten.ib).isGonnaBe('ib');
|
|
47
|
+
iReckon(sir, gotten.gib).isGonnaBe('gib');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await ifWe(sir, `should get the right ib & gib for primitives`, async () => {
|
|
51
|
+
let ibs: Ib[] = ['7', 'foo', 'ibgib', 'wakka doodle'];
|
|
52
|
+
for (let i = 0; i < ibs.length; i++) {
|
|
53
|
+
const ib = ibs[i];
|
|
54
|
+
let ibGib: IbGib = { ib, gib: 'gib' };
|
|
55
|
+
let gotten = getIbAndGib({ ibGib });
|
|
56
|
+
iReckon(sir, gotten).isGonnaBeTruthy();
|
|
57
|
+
iReckon(sir, gotten.ib).isGonnaBe(ib);
|
|
58
|
+
iReckon(sir, gotten.gib).isGonnaBe('gib');
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
});
|