diff --git a/packages/object/tests/hashgraph.test.ts b/packages/object/tests/hashgraph.test.ts index 07c5435b..5213d82d 100644 --- a/packages/object/tests/hashgraph.test.ts +++ b/packages/object/tests/hashgraph.test.ts @@ -32,9 +32,10 @@ describe("HashGraph construction tests", () => { }); test("Test: HashGraph should be DAG compatibility", () => { - /* - V1:ADD(1) - root / - \ - V2:ADD(2) + /* + __ V1:ADD(1) + ROOT / + \__ V2:ADD(2) */ const drp1 = obj1.drp as AddWinsSet; const drp2 = obj2.drp as AddWinsSet; @@ -55,8 +56,8 @@ describe("HashGraph construction tests", () => { test("Test: HashGraph with 2 root vertices", () => { /* - root - V1:ADD(1) - fakeRoot - V2:ADD(1) + ROOT -- V1:ADD(1) + FAKE_ROOT -- V2:ADD(1) */ const drp1 = obj1.drp as AddWinsSet; drp1.add(1); @@ -97,8 +98,8 @@ describe("HashGraph for AddWinSet tests", () => { test("Test: Add Two Vertices", () => { /* - V1:NOP <- V2:ADD(1) <- V2:REMOVE(1) - */ + ROOT -- ADD(1) -- REMOVE(1) + */ const drp1 = obj1.drp as AddWinsSet; drp1.add(1); @@ -114,10 +115,10 @@ describe("HashGraph for AddWinSet tests", () => { test("Test: Add Two Concurrent Vertices With Same Value", () => { /* - _ V2:REMOVE(1) - V1:ADD(1) / - \ _ V3:ADD(1) - */ + __ V2:REMOVE(1) + ROOT -- V1:ADD(1) / + \__ V3:ADD(1) + */ const drp1 = obj1.drp as AddWinsSet; const drp2 = obj2.drp as AddWinsSet; @@ -142,10 +143,10 @@ describe("HashGraph for AddWinSet tests", () => { test("Test: Add Two Concurrent Vertices With Different Values", () => { /* - _ V2:REMOVE(1) - V1:ADD(1) / - \ _ V3:ADD(2) - */ + __ V2:REMOVE(1) + ROOT -- V1:ADD(1) / + \__ V3:ADD(2) + */ const drp1 = obj1.drp as AddWinsSet; const drp2 = obj2.drp as AddWinsSet; @@ -172,10 +173,10 @@ describe("HashGraph for AddWinSet tests", () => { test("Test: Tricky Case", () => { /* - ___ V2:REMOVE(1) <- V4:ADD(10) - V1:ADD(1) / - \ ___ V3:ADD(1) <- V5:REMOVE(5) - */ + __ V2:REMOVE(1) -- V4:ADD(10) + ROOT -- V1:ADD(1) / + \__ V3:ADD(1) -- V5:REMOVE(5) + */ const drp1 = obj1.drp as AddWinsSet; const drp2 = obj2.drp as AddWinsSet; @@ -206,10 +207,10 @@ describe("HashGraph for AddWinSet tests", () => { test("Test: Yuta Papa's Case", () => { /* - ___ V2:REMOVE(1) <- V4:ADD(2) - V1:ADD(1) / - \ ___ V3:REMOVE(2) <- V5:ADD(1) - */ + __ V2:REMOVE(1) -- V4:ADD(2) + ROOT -- V1:ADD(1) / + \__ V3:REMOVE(2) -- V5:ADD(1) + */ const drp1 = obj1.drp as AddWinsSet; const drp2 = obj2.drp as AddWinsSet; @@ -238,14 +239,15 @@ describe("HashGraph for AddWinSet tests", () => { test("Test: Mega Complex Case", () => { /* - __ V6:ADD(3) - / - ___ V2:ADD(1) <-- V3:RM(2) <-- V7:RM(1) <-- V8:RM(3) - / ______________/ - V1:ADD(1)/ / - \ / - \ ___ V4:RM(2) <-- V5:ADD(2) <-- V9:RM(1) - */ + __ V6:ADD(3) + / + ___ V2:ADD(1) -- V3:RM(2) -- V7:RM(1) --- V8:RM(3) + / / + / ______________/ + ROOT -- V1:ADD(1) / + \ / + \__ V4:RM(2) -- V5:ADD(2) -- V9:RM(1) + */ const drp1 = obj1.drp as AddWinsSet; const drp2 = obj2.drp as AddWinsSet; @@ -293,14 +295,15 @@ describe("HashGraph for AddWinSet tests", () => { test("Test: Mega Complex Case 1", () => { /* - __ V5:ADD(3) - / - ___ V2:ADD(1) <-- V3:RM(2) <-- V6:RM(1) <-- V8:RM(3) - / ^ - V1:ADD(1)/ \ - \ \ - \ ___ V4:RM(2) <-------------------- V7:ADD(2) <-- V9:RM(1) - */ + __ V5:ADD(3) + / + ___ V2:ADD(1) -- V3:RM(2) -- V6:RM(1) -- V8:RM(3) + / \ + / \ + ROOT -- V1:ADD(1) \ + \ \ + \__ V4:RM(2) ----------------------------- V7:ADD(2) -- V9:RM(1) + */ const drp1 = obj1.drp as AddWinsSet; const drp2 = obj2.drp as AddWinsSet; @@ -350,10 +353,10 @@ describe("HashGraph for AddWinSet tests", () => { test("Test: Joao's latest brain teaser", () => { /* - __ V2:Add(2) <------------\ - V1:Add(1) / \ - V5:RM(2) - \__ V3:RM(2) <- V4:RM(2) <--/ - */ + __ V2:ADD(2) -------------\ + ROOT -- V1:ADD(1) / \ V5:RM(2) + \__ V3:RM(2) -- V4:RM(2) --/ + */ const drp1 = obj1.drp as AddWinsSet; const drp2 = obj2.drp as AddWinsSet; @@ -400,11 +403,11 @@ describe("HashGraph for PseudoRandomWinsSet tests", () => { test("Test: Many concurrent operations", () => { /* - --- V1:ADD(1) - /---- V2:ADD(2) - V0:Nop -- V3:ADD(3) - \---- V4:ADD(4) - ---- V5:ADD(5) + /-- V1:ADD(1) + /--- V2:ADD(2) + ROOT -- V3:ADD(3) + \__ V4:ADD(4) + \__ V5:ADD(5) */ const drp1 = obj1.drp as PseudoRandomWinsSet; @@ -482,7 +485,7 @@ describe("Vertex state tests", () => { test("Test: Vertex states work correctly with single HashGraph", () => { /* - root---V1:ADD(1)---V2:ADD(2)---V3:ADD(3) + ROOT -- V1:ADD(1) -- V2:ADD(2) -- V3:ADD(3) */ const drp1 = obj1.drp as AddWinsSet; @@ -510,11 +513,11 @@ describe("Vertex state tests", () => { test("Test: Tricky merging", () => { /* - A1<----------A4 __ - / / \ - root <-- B2 <-- A6 - \ \ / - C3<--------C5 ----- + __ V1:ADD(1) ------ V4:ADD(4) __ + / / \ + ROOT -- V2:ADD(2) ------/ \ V6:ADD(6) + \ \ / + -- V3:ADD(3) ------ V5:ADD(5) -- */ // in above hashgraph, A represents drp1, B represents drp2, C represents drp3 @@ -569,13 +572,14 @@ describe("Vertex state tests", () => { test("Test: Vertex states with mega complex case", () => { /* - __ V6:ADD(3) - / - ___ V2:ADD(1) <-- V3:RM(2) <-- V7:RM(1) <-- V8:RM(3) - / ______________/ - V1:ADD(1)/ / - \ / - \ ___ V4:RM(2) <-- V5:ADD(2) <-- V9:RM(1) + __ V6:ADD(3) + / + ___ V2:ADD(1) -- V3:RM(2) -- V7:RM(1) ------ V8:RM(3) + / / + / _________________/ + ROOT -- V1:ADD(1) / + \ / + \__ V4:RM(2) -- V5:ADD(2) -- V9:RM(1) */ const drp1 = obj1.drp as AddWinsSet;