@rootintf/protocol-2phw 1.2.4-api.1 → 2.0.3-api.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/dev.txt +16 -0
- package/dist/ajv-gen-validate.d.cts +1 -0
- package/dist/twoPhW.cjs.js +546 -303
- package/dist/twoPhW.d.ts +22 -22
- package/dist/twoPhW.es.mjs +546 -303
- package/package.json +13 -13
- package/schema/schema_2PhW.json +1 -1
- package/src/twoPhW.ts +84 -114
- package/src/validate-esm.mjs +1 -1
- package/tests/twoPhW-new.spec.mjs +26 -26
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
t_ttl_rtt,
|
|
8
8
|
TwoPhW, JSON_MsgOptions, JSON_MsgWarp, JSON_MsgEngage, JSON_MsgAckWarp, JSON_MsgAckEngage, l as l_twoPhW_,
|
|
9
9
|
} from '../dist/twoPhW.es.mjs';
|
|
10
|
-
import { JSON_Msg,
|
|
10
|
+
import { JSON_Msg, JSON_MsgEffect, JSON_MsgAck } from '@rootintf/json-msg'
|
|
11
11
|
|
|
12
|
-
const k_VERSION= "
|
|
12
|
+
const k_VERSION= "2";
|
|
13
13
|
|
|
14
14
|
const kstr_REFERER_ = 'twoPhW-new.spec';
|
|
15
15
|
const karr_referer_src = [kstr_REFERER_, uuidv4()];
|
|
@@ -37,12 +37,12 @@ describe("Initialization", function () {
|
|
|
37
37
|
it("json_msgWarp", function () {
|
|
38
38
|
const json_msgWarp= JSON_MsgWarp.create_with_id_user_hyperport(uuidv4(), '', '', TTL_MSEC_1500);
|
|
39
39
|
|
|
40
|
-
const json_msgAckWarp_obj= JSON_MsgAckWarp.
|
|
41
|
-
const json_msgAckWarp_str= JSON_MsgAckWarp.
|
|
40
|
+
const json_msgAckWarp_obj= JSON_MsgAckWarp.create_with_Warp_Ok(json_msgWarp, true);
|
|
41
|
+
const json_msgAckWarp_str= JSON_MsgAckWarp.create_with_Warp_Ok( JSON.stringify(json_msgWarp), true);
|
|
42
42
|
|
|
43
|
-
expect(typeof json_msgAckWarp_obj.
|
|
43
|
+
expect(typeof json_msgAckWarp_obj._cause.warp.id === 'string').toBe(true);
|
|
44
44
|
expect(() => {
|
|
45
|
-
json_msgAckWarp_str.
|
|
45
|
+
json_msgAckWarp_str._cause.warp.id;
|
|
46
46
|
}).toThrowError(TypeError, "Cannot read properties of undefined (reading 'id')");
|
|
47
47
|
|
|
48
48
|
expect(() => {
|
|
@@ -78,7 +78,7 @@ describe("Validation", function () {
|
|
|
78
78
|
"ok" : true,
|
|
79
79
|
"rtt_msec" : 6000
|
|
80
80
|
},
|
|
81
|
-
"
|
|
81
|
+
"_cause" : json_msgWarp_,
|
|
82
82
|
"2PhW": k_VERSION
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -89,7 +89,7 @@ describe("Validation", function () {
|
|
|
89
89
|
ack: {
|
|
90
90
|
"ok" : true,
|
|
91
91
|
},
|
|
92
|
-
"
|
|
92
|
+
"_cause" : JSON.stringify( json_msgWarp_ ),
|
|
93
93
|
"2PhW": k_VERSION
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -100,7 +100,7 @@ describe("Validation", function () {
|
|
|
100
100
|
ack: {
|
|
101
101
|
"ok" : true,
|
|
102
102
|
},
|
|
103
|
-
"
|
|
103
|
+
"_cause" : json_msgWarp_,
|
|
104
104
|
"2PhW": k_VERSION
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -111,7 +111,7 @@ describe("Validation", function () {
|
|
|
111
111
|
ack: {
|
|
112
112
|
"ok" : false,
|
|
113
113
|
},
|
|
114
|
-
"
|
|
114
|
+
"_cause" : json_msgEngage_,
|
|
115
115
|
"2PhW": k_VERSION
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -124,7 +124,7 @@ describe("Validation", function () {
|
|
|
124
124
|
ttl_msec_incr : [ 20000, 4000 ],
|
|
125
125
|
reason : "it is taking too long"
|
|
126
126
|
},
|
|
127
|
-
"
|
|
127
|
+
"_cause" : json_msgWarp_,
|
|
128
128
|
"2PhW": k_VERSION
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -181,10 +181,10 @@ describe('2PhW protocol', () => {
|
|
|
181
181
|
const json_msgWarp= JSON_MsgWarp.create_with_id_user_hyperport(uuidv4(), '', '', TTL_MSEC_1500);
|
|
182
182
|
json_msgWarp.referer= karr_referer_src;
|
|
183
183
|
|
|
184
|
-
const json_msgEngage= JSON_MsgEngage.
|
|
184
|
+
const json_msgEngage= JSON_MsgEngage.create_with_Warp(json_msgWarp);
|
|
185
185
|
json_msgEngage.referer= karr_referer_src;
|
|
186
186
|
|
|
187
|
-
const json_msgNackWarp= JSON_MsgAckWarp.
|
|
187
|
+
const json_msgNackWarp= JSON_MsgAckWarp.create_with_Warp_Ok(json_msgWarp, false);
|
|
188
188
|
json_msgNackWarp.referer= karr_referer_dst;
|
|
189
189
|
const str_msgNackWarp = JSON.stringify(json_msgNackWarp);
|
|
190
190
|
twoPhW.eventLog._addEvent(str_msgNackWarp, json_msgNackWarp)
|
|
@@ -287,7 +287,7 @@ describe('2PhW protocol', () => {
|
|
|
287
287
|
});
|
|
288
288
|
|
|
289
289
|
it('receive premature JSON_MsgEngage', () => {
|
|
290
|
-
const json_msgEngage_recvd= JSON_MsgEngage.
|
|
290
|
+
const json_msgEngage_recvd= JSON_MsgEngage.create_with_Warp(json_msgWarp_src);
|
|
291
291
|
json_msgEngage_recvd.referer= karr_referer_src;
|
|
292
292
|
|
|
293
293
|
twoPhW.handler_json(json_msgEngage_recvd, json_msgEngage_recvd);
|
|
@@ -319,11 +319,11 @@ describe('2PhW protocol', () => {
|
|
|
319
319
|
let str_msgNackWarp_dst;
|
|
320
320
|
|
|
321
321
|
beforeEach(() => {
|
|
322
|
-
json_msgAckWarp_dst= JSON_MsgAckWarp.
|
|
322
|
+
json_msgAckWarp_dst= JSON_MsgAckWarp.create_with_Warp_Ok(json_msgWarp_src, true);
|
|
323
323
|
json_msgAckWarp_dst.referer= karr_referer_dst;
|
|
324
324
|
str_msgAckWarp_dst = JSON.stringify(json_msgAckWarp_dst);
|
|
325
325
|
|
|
326
|
-
json_msgNackWarp_dst= JSON_MsgAckWarp.
|
|
326
|
+
json_msgNackWarp_dst= JSON_MsgAckWarp.create_with_Warp_Ok(json_msgWarp_src, false);
|
|
327
327
|
json_msgNackWarp_dst.referer= karr_referer_dst;
|
|
328
328
|
str_msgNackWarp_dst = JSON.stringify(str_msgNackWarp_dst);
|
|
329
329
|
|
|
@@ -359,7 +359,7 @@ describe('2PhW protocol', () => {
|
|
|
359
359
|
expect(eventLog.arr_events[1].data).toEqual({ msg: str_msgAckWarp_dst, json_msg : json_msgAckWarp_dst });
|
|
360
360
|
expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
|
|
361
361
|
|
|
362
|
-
const json_msgEngage_src= JSON_MsgEngage.
|
|
362
|
+
const json_msgEngage_src= JSON_MsgEngage.create_with_Warp(json_msgWarp_src);
|
|
363
363
|
json_msgEngage_src.referer= karr_referer_src;
|
|
364
364
|
|
|
365
365
|
twoPhW.handler_json(json_msgEngage_src, json_msgEngage_src);
|
|
@@ -373,7 +373,7 @@ describe('2PhW protocol', () => {
|
|
|
373
373
|
expect(eventLog.arr_events[1].data).toEqual({ msg : str_msgNackWarp_dst, json_msg : json_msgNackWarp_dst });
|
|
374
374
|
|
|
375
375
|
jasmine.clock().tick(STT_MSEC_1000); // 2000, STT_MSEC_1000 *2= RTT
|
|
376
|
-
const json_msgEngage_src= JSON_MsgEngage.
|
|
376
|
+
const json_msgEngage_src= JSON_MsgEngage.create_with_Warp(json_msgWarp_src);
|
|
377
377
|
json_msgEngage_src.referer= karr_referer_src;
|
|
378
378
|
|
|
379
379
|
jasmine.clock().tick(STT_MSEC_1000); // 3000, STT_MSEC_1000 *3
|
|
@@ -404,7 +404,7 @@ describe('2PhW protocol', () => {
|
|
|
404
404
|
expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
|
|
405
405
|
|
|
406
406
|
jasmine.clock().tick(STT_MSEC_1000); // STT_MSEC_1000 *2= RTT
|
|
407
|
-
json_msgEngage_src= JSON_MsgEngage.
|
|
407
|
+
json_msgEngage_src= JSON_MsgEngage.create_with_Warp(json_msgWarp_src);
|
|
408
408
|
json_msgEngage_src.referer= karr_referer_src;
|
|
409
409
|
str_msgEngage_src = JSON.stringify(json_msgEngage_src);
|
|
410
410
|
|
|
@@ -438,7 +438,7 @@ describe('2PhW protocol', () => {
|
|
|
438
438
|
expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
|
|
439
439
|
|
|
440
440
|
jasmine.clock().tick(STT_MSEC_1000); // 4000, STT_MSEC_1000 *4
|
|
441
|
-
const json_msgNackEngage_dst= JSON_MsgAckEngage.
|
|
441
|
+
const json_msgNackEngage_dst= JSON_MsgAckEngage.create_with_Engage_Ok(json_msgEngage_src, false);
|
|
442
442
|
json_msgNackEngage_dst.referer= karr_referer_dst;
|
|
443
443
|
twoPhW.register_msgAckEngage(JSON.stringify(json_msgNackEngage_dst), json_msgNackEngage_dst)
|
|
444
444
|
expect(eventLog.arr_events.length).toBe(2);
|
|
@@ -466,7 +466,7 @@ describe('2PhW protocol', () => {
|
|
|
466
466
|
expect(eventLog.arr_events[2].data).toEqual({ msg: str_msgEngage_src, json_msg : json_msgEngage_src });
|
|
467
467
|
expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
|
|
468
468
|
|
|
469
|
-
json_msgNackEngage_dst= JSON_MsgAckEngage.
|
|
469
|
+
json_msgNackEngage_dst= JSON_MsgAckEngage.create_with_Engage_Ok(json_msgEngage_src, false);
|
|
470
470
|
json_msgNackEngage_dst.referer= karr_referer_dst;
|
|
471
471
|
str_msgNackEngage_dst = JSON.stringify(json_msgNackEngage_dst);
|
|
472
472
|
|
|
@@ -645,17 +645,17 @@ describe('2PhW protocol', () => {
|
|
|
645
645
|
expect(Date.now()-T0).toBe(0);
|
|
646
646
|
|
|
647
647
|
jasmine.clock().tick(STT_MSEC_1000); // 1000
|
|
648
|
-
json_msgAckWarp_dst= JSON_MsgAckWarp.
|
|
648
|
+
json_msgAckWarp_dst= JSON_MsgAckWarp.create_with_Warp_Ok(json_msgWarp_src, true);
|
|
649
649
|
json_msgAckWarp_dst.referer= karr_referer_dst;
|
|
650
650
|
str_msgAckWarp_dst = JSON.stringify(json_msgAckWarp_dst);
|
|
651
651
|
|
|
652
|
-
json_msgNackWarp_dst= JSON_MsgAckWarp.
|
|
652
|
+
json_msgNackWarp_dst= JSON_MsgAckWarp.create_with_Warp_Ok(json_msgWarp_src, false);
|
|
653
653
|
json_msgNackWarp_dst.referer= karr_referer_dst;
|
|
654
654
|
str_msgNackWarp_dst = JSON.stringify(json_msgNackWarp_dst);
|
|
655
655
|
|
|
656
656
|
jasmine.clock().tick(STT_MSEC_1000); // 2000
|
|
657
657
|
|
|
658
|
-
json_msgEngage_src= JSON_MsgEngage.
|
|
658
|
+
json_msgEngage_src= JSON_MsgEngage.create_with_Warp(json_msgWarp_src);
|
|
659
659
|
json_msgEngage_src.referer= karr_referer_src;
|
|
660
660
|
str_msgEngage_src = JSON.stringify(json_msgEngage_src);
|
|
661
661
|
|
|
@@ -694,7 +694,7 @@ describe('2PhW protocol', () => {
|
|
|
694
694
|
expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
|
|
695
695
|
|
|
696
696
|
jasmine.clock().tick(STT_MSEC_1000); // 3000
|
|
697
|
-
const json_msgAckEngage_recv= JSON_MsgAckEngage.
|
|
697
|
+
const json_msgAckEngage_recv= JSON_MsgAckEngage.create_with_Engage_Ok(json_msgEngage_src, true);
|
|
698
698
|
json_msgAckEngage_recv.referer= karr_referer_dst;
|
|
699
699
|
|
|
700
700
|
jasmine.clock().tick(STT_MSEC_1000); // 4000
|
|
@@ -772,7 +772,7 @@ describe('2PhW protocol', () => {
|
|
|
772
772
|
expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
|
|
773
773
|
|
|
774
774
|
jasmine.clock().tick(STT_MSEC_1000); // 3000
|
|
775
|
-
json_msgAckEngage_dst= JSON_MsgAckEngage.
|
|
775
|
+
json_msgAckEngage_dst= JSON_MsgAckEngage.create_with_Engage_Ok(json_msgEngage_src, true);
|
|
776
776
|
json_msgAckEngage_dst.referer= karr_referer_dst;
|
|
777
777
|
str_msgAckEngage_dst = JSON.stringify(json_msgAckEngage_dst);
|
|
778
778
|
|