Skip to content

Commit

Permalink
refactor: all test descriptions (#276)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Lewandowski <[email protected]>
  • Loading branch information
trungnotchung and JanLewDev authored Dec 5, 2024
1 parent f6b948d commit 3a45ee4
Showing 1 changed file with 65 additions and 61 deletions.
126 changes: 65 additions & 61 deletions packages/object/tests/hashgraph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>;
const drp2 = obj2.drp as AddWinsSet<number>;
Expand All @@ -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<number>;
drp1.add(1);
Expand Down Expand Up @@ -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<number>;
drp1.add(1);
Expand All @@ -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<number>;
const drp2 = obj2.drp as AddWinsSet<number>;
Expand All @@ -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<number>;
const drp2 = obj2.drp as AddWinsSet<number>;
Expand All @@ -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<number>;
const drp2 = obj2.drp as AddWinsSet<number>;
Expand Down Expand Up @@ -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<number>;
const drp2 = obj2.drp as AddWinsSet<number>;
Expand Down Expand Up @@ -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<number>;
const drp2 = obj2.drp as AddWinsSet<number>;
Expand Down Expand Up @@ -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<number>;
const drp2 = obj2.drp as AddWinsSet<number>;
Expand Down Expand Up @@ -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<number>;
const drp2 = obj2.drp as AddWinsSet<number>;
Expand Down Expand Up @@ -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<number>;
Expand Down Expand Up @@ -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<number>;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<number>;
Expand Down

1 comment on commit 3a45ee4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Benchmark.js Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.

Benchmark suite Current: 3a45ee4 Previous: 76d22c9 Ratio
Create HashGraph with 1000 vertices 11.21 ops/sec (±2.03%) 246 ops/sec (±0.36%) 21.94
Create 2 DRP Objects (1000 vertices each) and Merge 0.52 ops/sec (±2.31%) 0.98 ops/sec (±3.13%) 1.88

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.