From a8ba6087b9fb6b0b38796392c8f2df4f41087db0 Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 27 Sep 2023 11:49:41 +0200 Subject: [PATCH] test: Pause works correctly --- test/index.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/index.test.ts b/test/index.test.ts index 864c1b3..29f4139 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -100,6 +100,29 @@ describe("VRF Test Suite", function () { ); }); + it("When paused it catches up the specified amount of blocks", async () => { + (userArgs.allowedSenders as string[]).push(user.address); + + // Simulates request to ignore + await inbox.connect(user).requestRandomness(mockConsumer.address, data); + + // Triggers pause condition + for (let i = 0; i < 1001; ++i) ethers.provider.send("evm_mine", []); + + + // Spams requests, only the last MAX_RANGE * MAX_REQUESTS should be picked up + for (let i = 0; i < 1000; ++i) { + await inbox.connect(user).requestRandomness(mockConsumer.address, data); + } + + const exec = await vrf.run({ userArgs }); + const res = exec.result as Web3FunctionResultV2; + + if (!res.canExec) assert.fail(res.message); + + expect(res.callData).to.have.lengthOf(500); + }); + it("Doesn't execute if no event was emitted", async () => { const exec = await vrf.run({ userArgs }); const res = exec.result as Web3FunctionResultV2;