Skip to content

Commit

Permalink
[PAY-123] Fix flaky rewards test (#4528)
Browse files Browse the repository at this point in the history
  • Loading branch information
piazzatron authored Dec 22, 2022
1 parent 22d0f62 commit cdc103f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions libs/tests/rewardsAttesterTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ describe('Delay calculator tests', () => {
const solSlot = {
last: 100
}
// new slots every 250ms
// new slots every ~250ms for 4 slots/sec
// give it a little padding to make sure we produce
// a slot before the pollingInterval runs
const i = setInterval(() => {
solSlot.last += 1
}, 250)
}, 230)

const libs = new MockLibs(
() => solSlot.last,
Expand All @@ -138,13 +140,15 @@ describe('Delay calculator tests', () => {
})
calc.start()
const slotThreshold1 = await calc.getSolanaSlotThreshold()
// Initially this should be 0.5sec/slot
// Initially this rate should be 0.5sec/slot
// 100 starting - 1s * 2slot/sec
assert.strictEqual(slotThreshold1, 90)

// Wait for staleness interval
// Wait for staleness interval of 1s
await new Promise((res) => setTimeout(res, 1100))
const slotThreshold2 = await calc.getSolanaSlotThreshold()
// Current slot should be 104, and there should be 4 slots/sec,
// Current slot should be 104
// it should calculate 4 slot/sec
// so 5 sec lag behind = 104 - 5 * 4 = 84
assert.strictEqual(slotThreshold2, 84)

Expand Down

0 comments on commit cdc103f

Please sign in to comment.