tests: use at.least to compare dates on the hlc tests. (#2196)

Should fix [this
error](https://github.com/umap-project/umap/actions/runs/11165503827/job/31037336947?pr=2188)
This commit is contained in:
David Larlet 2024-10-07 08:20:58 -04:00 committed by GitHub
commit 76ebe1c0ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -81,7 +81,7 @@ describe('HybridLogicalClock', () => {
const now = Date.now() const now = Date.now()
clock = new HybridLogicalClock(now, 5, 'local') clock = new HybridLogicalClock(now, 5, 'local')
const result = clock.receive(`${now}:7:remote`) 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.nn).to.equal(8)
expect(result.id).to.equal('local') expect(result.id).to.equal('local')
}) })
@ -100,7 +100,12 @@ describe('HybridLogicalClock', () => {
clock = new HybridLogicalClock(now, 5, 'local') clock = new HybridLogicalClock(now, 5, 'local')
const result = clock.receive(`${now - 1000}:7:remote`) const result = clock.receive(`${now - 1000}:7:remote`)
expect(result.walltime).to.be.least(now) 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') expect(result.id).to.equal('local')
}) })
}) })
@ -117,7 +122,7 @@ describe('HybridLogicalClock', () => {
const event2 = hlc.tick() const event2 = hlc.tick()
// Simulate receiving a message from another node // 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() const event3 = hlc.tick()