From 979d34f3fa6bcf7c6d5c0c1feadc8b722f5f3e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Fri, 4 Oct 2024 22:46:33 +0200 Subject: [PATCH 1/2] tests: use `at.least` to compare dates on the hlc tests. --- umap/static/umap/unittests/hlc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/unittests/hlc.js b/umap/static/umap/unittests/hlc.js index f32a56f5..eaf026f4 100644 --- a/umap/static/umap/unittests/hlc.js +++ b/umap/static/umap/unittests/hlc.js @@ -81,7 +81,7 @@ describe('HybridLogicalClock', () => { const now = Date.now() clock = new HybridLogicalClock(now, 5, 'local') const result = clock.receive(`${now}:7:remote`) - expect(result.walltime).to.equal(now) + expect(result.walltime).to.be.at.least(now) expect(result.nn).to.equal(8) expect(result.id).to.equal('local') }) @@ -117,7 +117,7 @@ describe('HybridLogicalClock', () => { const event2 = hlc.tick() // Simulate receiving a message from another node - const remoteEvent = hlc.receive(`${Date.now() - 50}:5:remote-id`) + hlc.receive(`${Date.now() - 50}:5:remote-id`) const event3 = hlc.tick() From 37ffea97a9ef149fe03e59bb2e9b8221d7ece6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Sat, 5 Oct 2024 21:16:45 +0200 Subject: [PATCH 2/2] FIXUP: adapt the tests to a slow CI --- umap/static/umap/unittests/hlc.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/unittests/hlc.js b/umap/static/umap/unittests/hlc.js index eaf026f4..41d366b6 100644 --- a/umap/static/umap/unittests/hlc.js +++ b/umap/static/umap/unittests/hlc.js @@ -100,7 +100,12 @@ describe('HybridLogicalClock', () => { clock = new HybridLogicalClock(now, 5, 'local') const result = clock.receive(`${now - 1000}:7:remote`) expect(result.walltime).to.be.least(now) - expect(result.nn).to.equal(6) + if (result.walltime > now) { + expect(result.nn).to.equal(5) + } + else { + expect(result.nn).to.equal(6) + } expect(result.id).to.equal('local') }) })