Skip to content

Commit

Permalink
test: Pause works correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoCentonze committed Sep 27, 2023
1 parent bc6b109 commit a8ba608
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", []);


Check failure on line 112 in test/index.test.ts

View workflow job for this annotation

GitHub Actions / test

Delete `⏎`
// Spams requests, only the last MAX_RANGE * MAX_REQUESTS should be picked up
for (let i = 0; i < 1000; ++i) {

Check failure on line 114 in test/index.test.ts

View workflow job for this annotation

GitHub Actions / test

Delete `·`
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;
Expand Down

0 comments on commit a8ba608

Please sign in to comment.