@rootintf/protocol-2phw 1.0.36-api.1 → 1.2.1-api.1

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.
@@ -1 +1 @@
1
- "use strict";export const definitions_2PhW = validate18;const schema21 = {"$id":"https://root-interface.se/protocols/2PhW/definitions_2PhW","$schema":"https://json-schema.org/draft/2019-09/schema","definitions":{"2PhW":{"const":"1"},"warp_id":{"type":"string"}}};function validate18(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/definitions_2PhW" */;validate18.errors = null;return true;}validate18.evaluated = {"dynamicProps":false,"dynamicItems":false};export const schema_MsgWarp = validate19;const schema22 = {"$id":"https://root-interface.se/protocols/2PhW/schema_MsgWarp","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["warp"],"properties":{"warp":{"type":"object","required":["id","user","hyperport","ttl_msec"],"properties":{"id":{"$ref":"definitions_2PhW#/definitions/warp_id"},"ttl_msec":{"type":"integer"},"instantaneous":{"type":"boolean"}}},"2PhW":{"$ref":"definitions_2PhW#/definitions/2PhW"}}};const schema23 = {"type":"string"};const schema24 = {"const":"1"};function validate19(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/schema_MsgWarp" */;let vErrors = null;let errors = 0;const evaluated0 = validate19.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.warp === undefined) && (missing0 = "warp")){validate19.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.warp !== undefined){let data0 = data.warp;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((((data0.id === undefined) && (missing1 = "id")) || ((data0.user === undefined) && (missing1 = "user"))) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))) || ((data0.ttl_msec === undefined) && (missing1 = "ttl_msec"))){validate19.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.id !== undefined){const _errs3 = errors;if(typeof data0.id !== "string"){validate19.errors = [{instancePath:instancePath+"/warp/id",schemaPath:"definitions_2PhW#/definitions/warp_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.ttl_msec !== undefined){let data2 = data0.ttl_msec;const _errs6 = errors;if(!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))){validate19.errors = [{instancePath:instancePath+"/warp/ttl_msec",schemaPath:"#/properties/warp/properties/ttl_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs6 === errors;}else {var valid1 = true;}if(valid1){if(data0.instantaneous !== undefined){const _errs8 = errors;if(typeof data0.instantaneous !== "boolean"){validate19.errors = [{instancePath:instancePath+"/warp/instantaneous",schemaPath:"#/properties/warp/properties/instantaneous/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid1 = _errs8 === errors;}else {var valid1 = true;}}}}}else {validate19.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data["2PhW"] !== undefined){const _errs10 = errors;if("1" !== data["2PhW"]){validate19.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"definitions_2PhW#/definitions/2PhW/const",keyword:"const",params:{allowedValue: "1"},message:"must be equal to constant"}];return false;}var valid0 = _errs10 === errors;}else {var valid0 = true;}}}}else {validate19.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate19.errors = vErrors;return errors === 0;}validate19.evaluated = {"props":{"warp":true,"2PhW":true},"dynamicProps":false,"dynamicItems":false};export const schema_MsgEngage = validate20;const schema25 = {"$id":"https://root-interface.se/protocols/2PhW/schema_MsgEngage","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["engage"],"properties":{"engage":{"type":"object","required":["ok","rtt_msec"],"properties":{"ok":{"type":"boolean"},"rtt_msec":{"type":"integer"}}},"2PhW":{"$ref":"definitions_2PhW#/definitions/2PhW"}}};function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/schema_MsgEngage" */;let vErrors = null;let errors = 0;const evaluated0 = validate20.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.engage === undefined) && (missing0 = "engage")){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.engage !== undefined){let data0 = data.engage;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.ok === undefined) && (missing1 = "ok")) || ((data0.rtt_msec === undefined) && (missing1 = "rtt_msec"))){validate20.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ok !== undefined){const _errs3 = errors;if(typeof data0.ok !== "boolean"){validate20.errors = [{instancePath:instancePath+"/engage/ok",schemaPath:"#/properties/engage/properties/ok/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.rtt_msec !== undefined){let data2 = data0.rtt_msec;const _errs5 = errors;if(!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))){validate20.errors = [{instancePath:instancePath+"/engage/rtt_msec",schemaPath:"#/properties/engage/properties/rtt_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs5 === errors;}else {var valid1 = true;}}}}else {validate20.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data["2PhW"] !== undefined){const _errs7 = errors;if("1" !== data["2PhW"]){validate20.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"definitions_2PhW#/definitions/2PhW/const",keyword:"const",params:{allowedValue: "1"},message:"must be equal to constant"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}validate20.evaluated = {"props":{"engage":true,"2PhW":true},"dynamicProps":false,"dynamicItems":false};export const schema_MsgOptions = validate21;const schema27 = {"$id":"https://root-interface.se/protocols/2PhW/schema_MsgOptions","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["options"],"properties":{"options":{"type":"object"},"2PhW":{"$ref":"definitions_2PhW#/definitions/2PhW"}}};function validate21(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/schema_MsgOptions" */;let vErrors = null;let errors = 0;const evaluated0 = validate21.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.options === undefined) && (missing0 = "options")){validate21.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.options !== undefined){let data0 = data.options;const _errs1 = errors;if(!(data0 && typeof data0 == "object" && !Array.isArray(data0))){validate21.errors = [{instancePath:instancePath+"/options",schemaPath:"#/properties/options/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data["2PhW"] !== undefined){const _errs3 = errors;if("1" !== data["2PhW"]){validate21.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"definitions_2PhW#/definitions/2PhW/const",keyword:"const",params:{allowedValue: "1"},message:"must be equal to constant"}];return false;}var valid0 = _errs3 === errors;}else {var valid0 = true;}}}}else {validate21.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate21.errors = vErrors;return errors === 0;}validate21.evaluated = {"props":{"options":true,"2PhW":true},"dynamicProps":false,"dynamicItems":false};export const schema_Options_delay = validate22;const schema29 = {"$id":"https://root-interface.se/protocols/2PhW/schema_Options_delay","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["ttl_msec_incr"],"properties":{"ttl_msec_incr":{"type":"array","items":{"type":"integer"}},"reason":{"type":"string"}}};function validate22(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/schema_Options_delay" */;let vErrors = null;let errors = 0;const evaluated0 = validate22.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.ttl_msec_incr === undefined) && (missing0 = "ttl_msec_incr")){validate22.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.ttl_msec_incr !== undefined){let data0 = data.ttl_msec_incr;const _errs1 = errors;if(errors === _errs1){if(Array.isArray(data0)){var valid1 = true;const len0 = data0.length;for(let i0=0; i0<len0; i0++){let data1 = data0[i0];const _errs3 = errors;if(!(((typeof data1 == "number") && (!(data1 % 1) && !isNaN(data1))) && (isFinite(data1)))){validate22.errors = [{instancePath:instancePath+"/ttl_msec_incr/" + i0,schemaPath:"#/properties/ttl_msec_incr/items/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs3 === errors;if(!valid1){break;}}}else {validate22.errors = [{instancePath:instancePath+"/ttl_msec_incr",schemaPath:"#/properties/ttl_msec_incr/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data.reason !== undefined){const _errs5 = errors;if(typeof data.reason !== "string"){validate22.errors = [{instancePath:instancePath+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid0 = _errs5 === errors;}else {var valid0 = true;}}}}else {validate22.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate22.errors = vErrors;return errors === 0;}validate22.evaluated = {"props":{"ttl_msec_incr":true,"reason":true},"dynamicProps":false,"dynamicItems":false};
1
+ "use strict";export const definitions_2PhW = validate18;const schema21 = {"$id":"https://root-interface.se/protocols/2PhW/definitions","$schema":"https://json-schema.org/draft/2019-09/schema","definitions":{"2PhW":{"const":"1"},"warp_id":{"type":"string"}}};function validate18(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/definitions" */;validate18.errors = null;return true;}validate18.evaluated = {"dynamicProps":false,"dynamicItems":false};export const schema_MsgWarp = validate19;const schema22 = {"$id":"https://root-interface.se/protocols/2PhW/MsgWarp","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["warp"],"properties":{"warp":{"type":"object","required":["id","user","hyperport","ttl_msec"],"properties":{"id":{"$ref":"definitions#/definitions/warp_id"},"ttl_msec":{"type":"integer"},"instantaneous":{"type":"boolean"}}},"2PhW":{"$ref":"definitions#/definitions/2PhW"}}};const schema23 = {"type":"string"};const schema24 = {"const":"1"};function validate19(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/MsgWarp" */;let vErrors = null;let errors = 0;const evaluated0 = validate19.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.warp === undefined) && (missing0 = "warp")){validate19.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.warp !== undefined){let data0 = data.warp;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((((data0.id === undefined) && (missing1 = "id")) || ((data0.user === undefined) && (missing1 = "user"))) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))) || ((data0.ttl_msec === undefined) && (missing1 = "ttl_msec"))){validate19.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.id !== undefined){const _errs3 = errors;if(typeof data0.id !== "string"){validate19.errors = [{instancePath:instancePath+"/warp/id",schemaPath:"definitions#/definitions/warp_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.ttl_msec !== undefined){let data2 = data0.ttl_msec;const _errs6 = errors;if(!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))){validate19.errors = [{instancePath:instancePath+"/warp/ttl_msec",schemaPath:"#/properties/warp/properties/ttl_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs6 === errors;}else {var valid1 = true;}if(valid1){if(data0.instantaneous !== undefined){const _errs8 = errors;if(typeof data0.instantaneous !== "boolean"){validate19.errors = [{instancePath:instancePath+"/warp/instantaneous",schemaPath:"#/properties/warp/properties/instantaneous/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid1 = _errs8 === errors;}else {var valid1 = true;}}}}}else {validate19.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data["2PhW"] !== undefined){const _errs10 = errors;if("1" !== data["2PhW"]){validate19.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"definitions#/definitions/2PhW/const",keyword:"const",params:{allowedValue: "1"},message:"must be equal to constant"}];return false;}var valid0 = _errs10 === errors;}else {var valid0 = true;}}}}else {validate19.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate19.errors = vErrors;return errors === 0;}validate19.evaluated = {"props":{"warp":true,"2PhW":true},"dynamicProps":false,"dynamicItems":false};export const schema_MsgEngage = validate20;const schema25 = {"$id":"https://root-interface.se/protocols/2PhW/MsgEngage","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["engage"],"properties":{"engage":{"type":"object","required":["ok","rtt_msec"],"properties":{"ok":{"type":"boolean"},"rtt_msec":{"type":"integer"}}},"2PhW":{"$ref":"definitions#/definitions/2PhW"}}};function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/MsgEngage" */;let vErrors = null;let errors = 0;const evaluated0 = validate20.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.engage === undefined) && (missing0 = "engage")){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.engage !== undefined){let data0 = data.engage;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.ok === undefined) && (missing1 = "ok")) || ((data0.rtt_msec === undefined) && (missing1 = "rtt_msec"))){validate20.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ok !== undefined){const _errs3 = errors;if(typeof data0.ok !== "boolean"){validate20.errors = [{instancePath:instancePath+"/engage/ok",schemaPath:"#/properties/engage/properties/ok/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.rtt_msec !== undefined){let data2 = data0.rtt_msec;const _errs5 = errors;if(!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))){validate20.errors = [{instancePath:instancePath+"/engage/rtt_msec",schemaPath:"#/properties/engage/properties/rtt_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs5 === errors;}else {var valid1 = true;}}}}else {validate20.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data["2PhW"] !== undefined){const _errs7 = errors;if("1" !== data["2PhW"]){validate20.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"definitions#/definitions/2PhW/const",keyword:"const",params:{allowedValue: "1"},message:"must be equal to constant"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}validate20.evaluated = {"props":{"engage":true,"2PhW":true},"dynamicProps":false,"dynamicItems":false};
@@ -85,7 +85,7 @@ describe('EventLog', () => {
85
85
  expect(arr_evts[0].evt.dt).toBe(1001000); // Newest (and only) match
86
86
  expect(arr_evts[0].evt.data).toEqual({ data: 2 });
87
87
 
88
- arr_evts = eventLog.getEventById('msg1', 1500);
88
+ arr_evts = eventLog.getEventsById('msg1', 1500);
89
89
  expect(arr_evts.length).toBe(1); // Only one event within 1500 ms
90
90
  expect(arr_evts[0].evt.dt).toBe(1001000); // Newest (and only) match
91
91
  expect(arr_evts[0].evt.data).toEqual({ data: 2 });
@@ -6,7 +6,7 @@ import {
6
6
  EventLog,
7
7
  t_ttl_rtt,
8
8
  TwoPhW, JSON_MsgOptions, JSON_MsgWarp, JSON_MsgEngage, JSON_MsgAckWarp, JSON_MsgAckEngage, l as l_twoPhW_,
9
- } from '../src/TwoPhW.mjs';
9
+ } from '../dist/twoPhW.es.mjs';
10
10
  import { JSON_Msg, JSON_Msg_msg, JSON_MsgAck_msg } from '@rootintf/json-msg'
11
11
 
12
12
  const k_VERSION= "1";
@@ -186,10 +186,11 @@ describe('2PhW protocol', () => {
186
186
 
187
187
  const json_msgNackWarp= JSON_MsgAckWarp.create_with_msgOk(json_msgWarp, false);
188
188
  json_msgNackWarp.referer= karr_referer_dst;
189
- twoPhW.eventLog._addEvent(json_msgNackWarp)
189
+ const str_msgNackWarp = JSON.stringify(json_msgNackWarp);
190
+ twoPhW.eventLog._addEvent(str_msgNackWarp, json_msgNackWarp)
190
191
  expect(eventLog.arr_events.length).toBe(1);
191
192
  expect(eventLog.arr_events[0].type).toBe('2PhW[JSON_MsgAckWarp]');
192
- expect(eventLog.arr_events[0].data).toBe(json_msgNackWarp);
193
+ expect(eventLog.arr_events[0].data).toEqual({ msg: str_msgNackWarp, json_msg : json_msgNackWarp });
193
194
  });
194
195
 
195
196
  it('t_ttl_rtt', () => {
@@ -231,6 +232,7 @@ describe('2PhW protocol', () => {
231
232
  let callback_msg_sent_expired;
232
233
 
233
234
  let json_msgWarp_src;
235
+ let str_msgWarp_src;
234
236
 
235
237
  beforeEach(() => {
236
238
  callback_msgWarp = jasmine.createSpy('callback_msgWarp').and.returnValue(true);
@@ -248,6 +250,7 @@ describe('2PhW protocol', () => {
248
250
 
249
251
  json_msgWarp_src= JSON_MsgWarp.create_with_id_user_hyperport(uuidv4(), '', '', TTL_MSEC_1500);
250
252
  json_msgWarp_src.referer= karr_referer_src;
253
+ str_msgWarp_src = JSON.stringify(json_msgWarp_src);
251
254
 
252
255
  jasmine.clock().tick(STT_MSEC_1000);
253
256
  expect(eventLog.arr_events.length).toBe(0);
@@ -262,83 +265,82 @@ describe('2PhW protocol', () => {
262
265
 
263
266
  it('receive JSON_MsgWarp', () => {
264
267
  jasmine.clock().tick(TTL_MSEC_1500 -STT_MSEC_1000 -1); // 1499
265
- twoPhW.handler_msg(json_msgWarp_src, json_msgWarp_src);
268
+ twoPhW.handler_json(str_msgWarp_src, json_msgWarp_src);
266
269
  expect(callback_msgWarp).toHaveBeenCalled();
267
270
  expect(eventLog.arr_events.length).toBe(1);
268
271
  expect(eventLog.arr_events[0].type).toBe('2PhW[JSON_MsgWarp]');
269
- expect(eventLog.arr_events[0].data).toBe(json_msgWarp_src);
270
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
272
+ expect(eventLog.arr_events[0].data).toEqual({ msg : str_msgWarp_src, json_msg: json_msgWarp_src });
273
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
271
274
 
272
275
  // dup
273
- twoPhW.handler_msg(json_msgWarp_src, json_msgWarp_src);
274
- expect(eventLog.arr_events.length).toBe(2);
275
- expect(eventLog.arr_events[1].type).toBe('2PhW[DROPPED!]');
276
- expect(eventLog.arr_events[1].data).toBe(json_msgWarp_src);
277
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
276
+ twoPhW.handler_json(str_msgWarp_src, json_msgWarp_src);
277
+ expect(eventLog.arr_events.length).toBe(1);
278
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
278
279
  });
279
280
 
280
281
  it('receive JSON_MsgWarp expired', () => {
281
282
  jasmine.clock().tick(TTL_MSEC_1500 -STT_MSEC_1000); // 1500
282
- twoPhW.handler_msg(json_msgWarp_src, json_msgWarp_src);
283
+ twoPhW.handler_json(str_msgWarp_src, json_msgWarp_src);
283
284
  expect(callback_msgWarp).not.toHaveBeenCalled();
284
- expect(eventLog.arr_events.length).toBe(1);
285
- expect(eventLog.arr_events[0].type).toBe('2PhW[DROPPED!]');
286
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateInitialState).toBe(true);
285
+ expect(eventLog.arr_events.length).toBe(0);
286
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateInitialState).toBe(true);
287
287
  });
288
288
 
289
289
  it('receive premature JSON_MsgEngage', () => {
290
290
  const json_msgEngage_recvd= JSON_MsgEngage.create_with_MsgWarp(json_msgWarp_src);
291
291
  json_msgEngage_recvd.referer= karr_referer_src;
292
292
 
293
- twoPhW.handler_msg(json_msgEngage_recvd, json_msgEngage_recvd);
294
- expect(eventLog.arr_events.length).toBe(1);
295
- expect(eventLog.arr_events[0].type).toBe('2PhW[DROPPED!]');
296
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateInitialState).toBe(true);
293
+ twoPhW.handler_json(json_msgEngage_recvd, json_msgEngage_recvd);
294
+ expect(eventLog.arr_events.length).toBe(0);
295
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateInitialState).toBe(true);
297
296
  });
298
297
 
299
- it('get_protocolState JSON_MsgWarp.compare(json_msgWarp, this._warp(json_msg).json_msgWarp )', () => {
300
- twoPhW.handler_msg(json_msgWarp_src, json_msgWarp_src);
298
+ it('traverse_State JSON_MsgWarp.compare(json_msgWarp, this._warp(json_msg).json_msgWarp )', () => {
299
+ twoPhW.handler_json(str_msgWarp_src, json_msgWarp_src);
301
300
  expect(eventLog.arr_events.length).toBe(1);
302
301
  expect(eventLog.arr_events[0].type).toBe('2PhW[JSON_MsgWarp]');
303
- expect(eventLog.arr_events[0].data).toBe(json_msgWarp_src);
304
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
302
+ expect(eventLog.arr_events[0].data).toEqual({ msg : str_msgWarp_src, json_msg: json_msgWarp_src });
303
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
305
304
 
306
305
  const json_msgWarp_wrong_dt= {
307
306
  ...json_msgWarp_src
308
307
  };
309
308
  jasmine.clock().tick(1); // 1001, make sure it is th wrong date
310
309
  json_msgWarp_wrong_dt.dt= new Date().toISOString();
311
- twoPhW.handler_msg(json_msgWarp_wrong_dt, json_msgWarp_wrong_dt);
312
- expect(eventLog.arr_events.length).toBe(2);
313
- expect(eventLog.arr_events[1].type).toBe('2PhW[DROPPED!]');
314
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
310
+ twoPhW.handler_json(json_msgWarp_wrong_dt, json_msgWarp_wrong_dt);
311
+ expect(eventLog.arr_events.length).toBe(1);
312
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
315
313
  });
316
314
 
317
315
  describe('warp sequence as Destination receiver;', () => {
318
316
  let json_msgAckWarp_dst;
317
+ let str_msgAckWarp_dst;
319
318
  let json_msgNackWarp_dst;
319
+ let str_msgNackWarp_dst;
320
320
 
321
321
  beforeEach(() => {
322
322
  json_msgAckWarp_dst= JSON_MsgAckWarp.create_with_msgOk(json_msgWarp_src, true);
323
323
  json_msgAckWarp_dst.referer= karr_referer_dst;
324
+ str_msgAckWarp_dst = JSON.stringify(json_msgAckWarp_dst);
324
325
 
325
326
  json_msgNackWarp_dst= JSON_MsgAckWarp.create_with_msgOk(json_msgWarp_src, false);
326
327
  json_msgNackWarp_dst.referer= karr_referer_dst;
328
+ str_msgNackWarp_dst = JSON.stringify(str_msgNackWarp_dst);
327
329
 
328
330
  expect(eventLog.arr_events.length).toBe(0);
329
331
 
330
332
  expect(Date.now()-T0).toBe(STT_MSEC_1000);
331
333
 
332
- twoPhW.handler_msg(json_msgWarp_src, json_msgWarp_src);
334
+ twoPhW.handler_json(str_msgWarp_src, json_msgWarp_src);
333
335
  expect(callback_msgWarp).toHaveBeenCalled();
334
336
  expect(eventLog.arr_events.length).toBe(1);
335
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
337
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
336
338
  });
337
339
 
338
340
  it('Ack expires', () => {
339
341
  jasmine.clock().tick(300); // register of Ack 300ms after creation
340
342
  expect(Date.now()-T0).toBe(STT_MSEC_1000 +300);
341
- twoPhW.register_msgAckWarp(json_msgAckWarp_dst);
343
+ twoPhW.register_msgAckWarp(str_msgAckWarp_dst, json_msgAckWarp_dst);
342
344
 
343
345
  // The Ack gets to live for THE ACK'S creation time + TTL*2 + STT
344
346
  // - Ack creation time @1000ms
@@ -354,57 +356,57 @@ describe('2PhW protocol', () => {
354
356
  expect(callback_msg_sent_expired).toHaveBeenCalled();
355
357
  expect(eventLog.arr_events.length).toBe(2);
356
358
  expect(eventLog.arr_events[1].type).toBe('2PhW[JSON_MsgAckWarp]');
357
- expect(eventLog.arr_events[1].data).toBe(json_msgAckWarp_dst);
358
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
359
+ expect(eventLog.arr_events[1].data).toEqual({ msg: str_msgAckWarp_dst, json_msg : json_msgAckWarp_dst });
360
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
359
361
 
360
362
  const json_msgEngage_src= JSON_MsgEngage.create_with_MsgWarp(json_msgWarp_src);
361
363
  json_msgEngage_src.referer= karr_referer_src;
362
364
 
363
- twoPhW.handler_msg(json_msgEngage_src, json_msgEngage_src);
364
- expect(eventLog.arr_events.length).toBe(3);
365
- expect(eventLog.arr_events[2].type).toBe('2PhW[DROPPED!]');
366
- expect(eventLog.arr_events[2].data).toBe(json_msgEngage_src);
365
+ twoPhW.handler_json(json_msgEngage_src, json_msgEngage_src);
366
+ expect(eventLog.arr_events.length).toBe(2);
367
367
  });
368
368
 
369
369
  it('NACK', () => {
370
- twoPhW.register_msgAckWarp(json_msgNackWarp_dst);
370
+ twoPhW.register_msgAckWarp(str_msgNackWarp_dst, json_msgNackWarp_dst);
371
371
  expect(eventLog.arr_events.length).toBe(2);
372
372
  expect(eventLog.arr_events[1].type).toBe('2PhW[JSON_MsgAckWarp]');
373
- expect(eventLog.arr_events[1].data).toBe(json_msgNackWarp_dst);
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
376
  const json_msgEngage_src= JSON_MsgEngage.create_with_MsgWarp(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
380
- twoPhW.handler_msg(json_msgEngage_src, json_msgEngage_src);
381
- expect(eventLog.arr_events.length).toBe(3);
382
- expect(eventLog.arr_events[2].type).toBe('2PhW[DROPPED!]');
380
+ twoPhW.handler_json(json_msgEngage_src, json_msgEngage_src);
381
+ expect(eventLog.arr_events.length).toBe(2);
383
382
  });
384
383
 
385
384
  describe('JSON_MsgAckWarp;', () => {
386
385
  let json_msgEngage_src;
386
+ let str_msgEngage_src;
387
387
 
388
388
  beforeEach(() => {
389
389
  LOGR_.toggled= {
390
390
  // RECVER : 1,
391
391
  // PROTOCOL_STATE : 1,
392
- // DROPS : 1
392
+ // DROPS : 1,
393
+ // LOG_TEST : true
393
394
  }
394
395
 
395
396
  jasmine.clock().tick(0);
396
397
  expect(Date.now()-T0).toBe(STT_MSEC_1000);
397
398
 
398
399
  // Ack
399
- twoPhW.register_msgAckWarp(json_msgAckWarp_dst);
400
+ twoPhW.register_msgAckWarp(str_msgAckWarp_dst, json_msgAckWarp_dst);
400
401
  expect(eventLog.arr_events.length).toBe(2);
401
402
  expect(eventLog.arr_events[1].type).toBe('2PhW[JSON_MsgAckWarp]');
402
- expect(eventLog.arr_events[1].data).toBe(json_msgAckWarp_dst);
403
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
403
+ expect(eventLog.arr_events[1].data).toEqual({ msg: str_msgAckWarp_dst, json_msg : json_msgAckWarp_dst });
404
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
404
405
 
405
406
  jasmine.clock().tick(STT_MSEC_1000); // STT_MSEC_1000 *2= RTT
406
407
  json_msgEngage_src= JSON_MsgEngage.create_with_MsgWarp(json_msgWarp_src);
407
408
  json_msgEngage_src.referer= karr_referer_src;
409
+ str_msgEngage_src = JSON.stringify(json_msgEngage_src);
408
410
 
409
411
  expect(Date.now()-T0).toBe(RTT_MSEC_2000);
410
412
  });
@@ -430,23 +432,22 @@ describe('2PhW protocol', () => {
430
432
  // - TTL= 1500, RTT= 2000; TTL*2 + RTT= 5000; timeout= 5000
431
433
  // - expires at 5000
432
434
 
433
- twoPhW.handler_msg(json_msgEngage_src, json_msgEngage_src);
435
+ twoPhW.handler_json(str_msgEngage_src, json_msgEngage_src);
434
436
  expect(callback_msgEngage).not.toHaveBeenCalled();
435
- expect(eventLog.arr_events.length).toBe(3);
436
- expect(eventLog.arr_events[2].type).toBe('2PhW[DROPPED!]');
437
- expect(eventLog.arr_events[2].data).toBe(json_msgEngage_src);
438
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
437
+ expect(eventLog.arr_events.length).toBe(2);
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
441
  const json_msgNackEngage_dst= JSON_MsgAckEngage.create_with_msgOk(json_msgEngage_src, false);
442
442
  json_msgNackEngage_dst.referer= karr_referer_dst;
443
- twoPhW.register_msgAckEngage(json_msgNackEngage_dst)
444
- expect(eventLog.arr_events.length).toBe(3);
445
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
443
+ twoPhW.register_msgAckEngage(JSON.stringify(json_msgNackEngage_dst), json_msgNackEngage_dst)
444
+ expect(eventLog.arr_events.length).toBe(2);
445
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
446
446
  });
447
447
 
448
448
  describe('JSON_MsgAckWarp;', () => {
449
449
  let json_msgNackEngage_dst;
450
+ let str_msgNackEngage_dst;
450
451
 
451
452
  beforeEach(() => {
452
453
  LOGR_.toggled= {
@@ -457,16 +458,17 @@ describe('2PhW protocol', () => {
457
458
 
458
459
  jasmine.clock().tick(STT_MSEC_1000); // 3000, STT_MSEC_1000 *3
459
460
 
460
- twoPhW.handler_msg(json_msgEngage_src, json_msgEngage_src);
461
+ twoPhW.handler_json(str_msgEngage_src, json_msgEngage_src);
461
462
  expect(callback_msgEngage).toHaveBeenCalled();
462
463
  expect(callback_msg_sent_expired).not.toHaveBeenCalled();
463
464
  expect(eventLog.arr_events.length).toBe(3);
464
465
  expect(eventLog.arr_events[2].type).toBe('2PhW[JSON_MsgEngage]');
465
- expect(eventLog.arr_events[2].data).toBe(json_msgEngage_src);
466
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
466
+ expect(eventLog.arr_events[2].data).toEqual({ msg: str_msgEngage_src, json_msg : json_msgEngage_src });
467
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
467
468
 
468
469
  json_msgNackEngage_dst= JSON_MsgAckEngage.create_with_msgOk(json_msgEngage_src, false);
469
470
  json_msgNackEngage_dst.referer= karr_referer_dst;
471
+ str_msgNackEngage_dst = JSON.stringify(json_msgNackEngage_dst);
470
472
 
471
473
  // jasmine.clock().tick(STT_MSEC_1000); // 4000, STT_MSEC_1000 *4
472
474
  // expect(Date.now()-T0).toBe(RTT_MSEC_2000 *2);
@@ -482,20 +484,20 @@ describe('2PhW protocol', () => {
482
484
  jasmine.clock().tick(2000 -1);
483
485
  expect(Date.now()-T0).toBe( t_ttl_rtt(TTL_MSEC_1500, RTT_MSEC_2000) -1);
484
486
 
485
- twoPhW.register_msgAckEngage(json_msgNackEngage_dst)
487
+ twoPhW.register_msgAckEngage(str_msgNackEngage_dst, json_msgNackEngage_dst)
486
488
  expect(eventLog.arr_events.length).toBe(4);
487
489
  expect(eventLog.arr_events[3].type).toBe('2PhW[JSON_MsgAckEngage]');
488
- expect(eventLog.arr_events[3].data).toBe(json_msgNackEngage_dst);
489
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateAckEngage).toBe(true);
490
+ expect(eventLog.arr_events[3].data).toEqual({ msg : str_msgNackEngage_dst, json_msg : json_msgNackEngage_dst });
491
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckEngage).toBe(true);
490
492
  });
491
493
 
492
494
  it('JSON_MsgAckEngage, expired', () => {
493
495
  jasmine.clock().tick(2000);
494
496
  expect(Date.now()-T0).toBe(t_ttl_rtt(TTL_MSEC_1500, RTT_MSEC_2000));
495
497
 
496
- twoPhW.register_msgAckEngage(json_msgNackEngage_dst)
498
+ twoPhW.register_msgAckEngage(str_msgNackEngage_dst, json_msgNackEngage_dst)
497
499
  expect(eventLog.arr_events.length).toBe(3);
498
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
500
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
499
501
  });
500
502
 
501
503
  });
@@ -509,7 +511,7 @@ describe('2PhW protocol', () => {
509
511
 
510
512
  // const json_msgAckWarp= JSON_MsgAckWarp.create_with_msgOk(json_msgWarp, true);
511
513
  // json_msgAckWarp.referer= karr_referer_dst;
512
- // expect((twoPhW.eventLog.get_protocolState(json_msgWarp_recvd)).state instanceof StateWarp).toBe(true);
514
+ // expect((twoPhW.eventLog.traverse_State(json_msgWarp_recvd)).state instanceof StateWarp).toBe(true);
513
515
 
514
516
  // twoPhW.eventLog.addEvent(json_msgAckWarp);
515
517
  // expect(eventLog.arr_events.length).toBe(2);
@@ -535,13 +537,13 @@ describe('2PhW protocol', () => {
535
537
 
536
538
 
537
539
  // jasmine.clock().tick(1000); // 1000
538
- // twoPhW.handler_msg(json_msgWarp_recvd, json_msgWarp_recvd);
540
+ // twoPhW.handler_json(json_msgWarp_recvd, json_msgWarp_recvd);
539
541
  // expect(eventLog.arr_events[0].type).toBe('2PhW[JSON_MsgWarp]');
540
542
  // expect(eventLog.arr_events[0].data).toBe(json_msgWarp_recvd);
541
- // expect((twoPhW.eventLog.get_protocolState(json_msgWarp_recvd)).state instanceof StateAckWarp).toBe(true);
543
+ // expect((twoPhW.eventLog.traverse_State(json_msgWarp_recvd)).state instanceof StateAckWarp).toBe(true);
542
544
 
543
545
  // jasmine.clock().tick(1000); // 2000
544
- // twoPhW.handler_msg(json_msgEngage_recvd, json_msgEngage_recvd);
546
+ // twoPhW.handler_json(json_msgEngage_recvd, json_msgEngage_recvd);
545
547
 
546
548
  // expect(eventLog.arr_events.length).toBe(3);
547
549
  // expect(eventLog.arr_events[2].type).toBe('2PhW[DROPPED!]');
@@ -570,6 +572,7 @@ describe('2PhW protocol', () => {
570
572
  let callback_msg_sent_expired;
571
573
 
572
574
  let json_msgWarp_src;
575
+ let str_msgWarp_src;
573
576
 
574
577
  beforeEach(() => {
575
578
  callback_msgAckWarp = jasmine.createSpy('callback_msgAckWarp').and.returnValue(true);
@@ -587,6 +590,7 @@ describe('2PhW protocol', () => {
587
590
 
588
591
  json_msgWarp_src= JSON_MsgWarp.create_with_id_user_hyperport(uuidv4(), '', '', TTL_MSEC_1500);
589
592
  json_msgWarp_src.referer= karr_referer_src;
593
+ str_msgWarp_src = JSON.stringify(json_msgWarp_src);
590
594
 
591
595
  expect(eventLog.arr_events.length).toBe(0);
592
596
  });
@@ -599,9 +603,9 @@ describe('2PhW protocol', () => {
599
603
  jasmine.clock().tick(TTL_MSEC_1500 -1);
600
604
  expect(Date.now()-T0).toBe(1499);
601
605
 
602
- twoPhW.register_msgWarp(json_msgWarp_src);
606
+ twoPhW.register_msgWarp(str_msgWarp_src, json_msgWarp_src);
603
607
  expect(eventLog.arr_events.length).toBe(1);
604
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
608
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
605
609
 
606
610
  jasmine.clock().tick(TTL_MSEC_1500 +1);
607
611
  expect(Date.now()-T0).toBe(t_ttl_rtt(TTL_MSEC_1500));
@@ -612,15 +616,18 @@ describe('2PhW protocol', () => {
612
616
  jasmine.clock().tick(TTL_MSEC_1500);
613
617
  expect(Date.now()-T0).toBe(1500);
614
618
 
615
- twoPhW.register_msgWarp(json_msgWarp_src);
619
+ twoPhW.register_msgWarp(str_msgWarp_src, json_msgWarp_src);
616
620
  expect(eventLog.arr_events.length).toBe(0);
617
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateInitialState).toBe(true);
621
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateInitialState).toBe(true);
618
622
  });
619
623
 
620
624
  describe('JSON_MsgAckWarp;', () => {
621
625
  let json_msgAckWarp_dst;
626
+ let str_msgAckWarp_dst;
622
627
  let json_msgNackWarp_dst;
628
+ let str_msgNackWarp_dst;
623
629
  let json_msgEngage_src;
630
+ let str_msgEngage_src;
624
631
 
625
632
  beforeEach(() => {
626
633
  LOGR_.toggled= {
@@ -629,25 +636,28 @@ describe('2PhW protocol', () => {
629
636
  // DROPS : 1
630
637
  }
631
638
 
632
- twoPhW.register_msgWarp(json_msgWarp_src);
639
+ twoPhW.register_msgWarp(str_msgWarp_src, json_msgWarp_src);
633
640
  expect(eventLog.arr_events.length).toBe(1);
634
641
  expect(eventLog.arr_events[0].type).toBe('2PhW[JSON_MsgWarp]');
635
- expect(eventLog.arr_events[0].data).toBe(json_msgWarp_src);
636
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
642
+ expect(eventLog.arr_events[0].data).toEqual({ msg : str_msgWarp_src, json_msg: json_msgWarp_src });
643
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
637
644
 
638
645
  expect(Date.now()-T0).toBe(0);
639
646
 
640
647
  jasmine.clock().tick(STT_MSEC_1000); // 1000
641
648
  json_msgAckWarp_dst= JSON_MsgAckWarp.create_with_msgOk(json_msgWarp_src, true);
642
649
  json_msgAckWarp_dst.referer= karr_referer_dst;
650
+ str_msgAckWarp_dst = JSON.stringify(json_msgAckWarp_dst);
643
651
 
644
652
  json_msgNackWarp_dst= JSON_MsgAckWarp.create_with_msgOk(json_msgWarp_src, false);
645
653
  json_msgNackWarp_dst.referer= karr_referer_dst;
654
+ str_msgNackWarp_dst = JSON.stringify(json_msgNackWarp_dst);
646
655
 
647
656
  jasmine.clock().tick(STT_MSEC_1000); // 2000
648
657
 
649
658
  json_msgEngage_src= JSON_MsgEngage.create_with_MsgWarp(json_msgWarp_src);
650
659
  json_msgEngage_src.referer= karr_referer_src;
660
+ str_msgEngage_src = JSON.stringify(json_msgEngage_src);
651
661
 
652
662
  expect(Date.now()-T0).toBe(STT_MSEC_1000 *2);
653
663
  expect(Date.now()-T0).toBe(RTT_MSEC_2000);
@@ -666,33 +676,30 @@ describe('2PhW protocol', () => {
666
676
  expect(callback_msgAckWarp).not.toHaveBeenCalled();
667
677
  expect(callback_msg_sent_expired).toHaveBeenCalled();
668
678
 
669
- twoPhW.handler_msg(json_msgAckWarp_dst, json_msgAckWarp_dst);
679
+ twoPhW.handler_json(json_msgAckWarp_dst, json_msgAckWarp_dst);
670
680
  expect(callback_msgAckWarp).not.toHaveBeenCalled();
671
- expect(eventLog.arr_events.length).toBe(2);
672
- expect(eventLog.arr_events[1].type).toBe('2PhW[DROPPED!]');
673
- expect(eventLog.arr_events[1].data).toBe(json_msgAckWarp_dst);
674
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
681
+ expect(eventLog.arr_events.length).toBe(1);
682
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateWarp).toBe(true);
675
683
  });
676
684
 
677
685
  it('send JSON_MsgWarp == NACK', () => {
678
- twoPhW.handler_msg(json_msgNackWarp_dst, json_msgNackWarp_dst);
686
+ twoPhW.handler_json(str_msgNackWarp_dst, json_msgNackWarp_dst);
679
687
  expect(eventLog.arr_events.length).toBe(2);
680
688
  expect(eventLog.arr_events[1].type).toBe('2PhW[JSON_MsgAckWarp]');
681
- expect(eventLog.arr_events[1].data).toBe(json_msgNackWarp_dst);
689
+ expect(eventLog.arr_events[1].data).toEqual({msg : str_msgNackWarp_dst, json_msg : json_msgNackWarp_dst });
682
690
  expect(callback_msgAckWarp).toHaveBeenCalled();
683
691
 
684
- twoPhW.register_msgEngage(json_msgEngage_src);
692
+ twoPhW.register_msgEngage(str_msgEngage_src, json_msgEngage_src);
685
693
  expect(eventLog.arr_events.length).toBe(2);
686
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
694
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
687
695
 
688
696
  jasmine.clock().tick(STT_MSEC_1000); // 3000
689
697
  const json_msgAckEngage_recv= JSON_MsgAckEngage.create_with_msgOk(json_msgEngage_src, true);
690
698
  json_msgAckEngage_recv.referer= karr_referer_dst;
691
699
 
692
700
  jasmine.clock().tick(STT_MSEC_1000); // 4000
693
- twoPhW.handler_msg(json_msgAckEngage_recv, json_msgAckEngage_recv);
694
- expect(eventLog.arr_events.length).toBe(3);
695
- expect(eventLog.arr_events[2].type).toBe('2PhW[DROPPED!]');
701
+ twoPhW.handler_json(json_msgAckEngage_recv, json_msgAckEngage_recv);
702
+ expect(eventLog.arr_events.length).toBe(2);
696
703
  });
697
704
 
698
705
  describe('register Engage!', () => {
@@ -705,12 +712,12 @@ describe('2PhW protocol', () => {
705
712
 
706
713
  expect(Date.now()-T0).toBe(RTT_MSEC_2000);
707
714
 
708
- twoPhW.handler_msg(json_msgAckWarp_dst, json_msgAckWarp_dst);
715
+ twoPhW.handler_json(str_msgAckWarp_dst, json_msgAckWarp_dst);
709
716
  expect(callback_msgAckWarp).toHaveBeenCalled();
710
717
  expect(eventLog.arr_events.length).toBe(2);
711
718
  expect(eventLog.arr_events[1].type).toBe('2PhW[JSON_MsgAckWarp]');
712
- expect(eventLog.arr_events[1].data).toBe(json_msgAckWarp_dst);
713
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
719
+ expect(eventLog.arr_events[1].data).toEqual({ msg: str_msgAckWarp_dst, json_msg : json_msgAckWarp_dst });
720
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
714
721
  });
715
722
 
716
723
  it('CAN register a Engage', () => {
@@ -718,18 +725,18 @@ describe('2PhW protocol', () => {
718
725
  jasmine.clock().tick(TTL_MSEC_1500*2 -1); // 4999
719
726
  expect(Date.now()-T0).toBe(4999);
720
727
 
721
- twoPhW.register_msgEngage(json_msgEngage_src);
728
+ twoPhW.register_msgEngage(str_msgEngage_src, json_msgEngage_src);
722
729
  expect(eventLog.arr_events.length).toBe(3);
723
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
730
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
724
731
  });
725
732
 
726
733
  it('delayed register of Engage', () => {
727
734
  expect(t_ttl_rtt(TTL_MSEC_1500, RTT_MSEC_2000) === 5000).toBe(true)
728
735
  jasmine.clock().tick(300);
729
736
  expect(Date.now()-T0).toBe(RTT_MSEC_2000 +300);
730
- twoPhW.register_msgEngage(json_msgEngage_src);
737
+ twoPhW.register_msgEngage(str_msgEngage_src, json_msgEngage_src);
731
738
  expect(eventLog.arr_events.length).toBe(3);
732
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
739
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
733
740
 
734
741
  jasmine.clock().tick( t_ttl_rtt(TTL_MSEC_1500) -300 -1); // 4999
735
742
  expect(Date.now()-T0).toBe(4999);
@@ -742,13 +749,14 @@ describe('2PhW protocol', () => {
742
749
  it('can NOT register an expired Engage', () => {
743
750
  expect(t_ttl_rtt(TTL_MSEC_1500, RTT_MSEC_2000) === 5000).toBe(true)
744
751
  jasmine.clock().tick(TTL_MSEC_1500*2); // 5000
745
- twoPhW.register_msgEngage(json_msgEngage_src);
752
+ twoPhW.register_msgEngage(str_msgEngage_src, json_msgEngage_src);
746
753
  expect(eventLog.arr_events.length).toBe(2);
747
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
754
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckWarp).toBe(true);
748
755
  });
749
756
 
750
757
  describe('Engage!', () => {
751
758
  let json_msgAckEngage_dst;
759
+ let str_msgAckEngage_dst;
752
760
 
753
761
  beforeEach(() => {
754
762
  LOGR_.toggled= {
@@ -759,13 +767,14 @@ describe('2PhW protocol', () => {
759
767
 
760
768
  expect(Date.now()-T0).toBe(RTT_MSEC_2000);
761
769
 
762
- twoPhW.register_msgEngage(json_msgEngage_src);
770
+ twoPhW.register_msgEngage(str_msgEngage_src, json_msgEngage_src);
763
771
  expect(eventLog.arr_events.length).toBe(3);
764
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
772
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
765
773
 
766
774
  jasmine.clock().tick(STT_MSEC_1000); // 3000
767
775
  json_msgAckEngage_dst= JSON_MsgAckEngage.create_with_msgOk(json_msgEngage_src, true);
768
776
  json_msgAckEngage_dst.referer= karr_referer_dst;
777
+ str_msgAckEngage_dst = JSON.stringify(json_msgAckEngage_dst);
769
778
 
770
779
  jasmine.clock().tick(STT_MSEC_1000); // 4000
771
780
  expect(callback_msg_sent_expired).not.toHaveBeenCalled();
@@ -781,11 +790,11 @@ describe('2PhW protocol', () => {
781
790
  expect(Date.now()-T0).toBe(4999);
782
791
  expect(callback_msg_sent_expired).not.toHaveBeenCalled();
783
792
 
784
- twoPhW.handler_msg(json_msgAckEngage_dst, json_msgAckEngage_dst);
793
+ twoPhW.handler_json(str_msgAckEngage_dst, json_msgAckEngage_dst);
785
794
  expect(eventLog.arr_events.length).toBe(4);
786
795
  expect(eventLog.arr_events[3].type).toBe('2PhW[JSON_MsgAckEngage]');
787
- expect(eventLog.arr_events[3].data).toBe(json_msgAckEngage_dst);
788
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateAckEngage).toBe(true);
796
+ expect(eventLog.arr_events[3].data).toEqual({ msg: str_msgAckEngage_dst, json_msg : json_msgAckEngage_dst });
797
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateAckEngage).toBe(true);
789
798
 
790
799
  jasmine.clock().tick(1); // 5000
791
800
  expect(callback_msg_sent_expired).not.toHaveBeenCalled();
@@ -799,11 +808,9 @@ describe('2PhW protocol', () => {
799
808
  expect(callback_msg_sent_expired).toHaveBeenCalled();
800
809
 
801
810
  // test to make sure a late ack isn't a valid AckEngage state
802
- twoPhW.handler_msg(json_msgAckEngage_dst, json_msgAckEngage_dst);
803
- expect(eventLog.arr_events.length).toBe(4);
804
- expect(eventLog.arr_events[3].type).toBe('2PhW[DROPPED!]');
805
- expect(eventLog.arr_events[3].data).toBe(json_msgAckEngage_dst);
806
- expect((twoPhW.eventLog.get_protocolState(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
811
+ twoPhW.handler_json(str_msgAckEngage_dst, json_msgAckEngage_dst);
812
+ expect(eventLog.arr_events.length).toBe(3);
813
+ expect((twoPhW.eventLog.traverse_State(json_msgWarp_src)).state instanceof StateEngage).toBe(true);
807
814
  });
808
815
 
809
816