Skip to content

Commit 6fb8d96

Browse files
committed
chore: rng testcases
1 parent bfaefd2 commit 6fb8d96

File tree

4 files changed

+3612
-3592
lines changed

4 files changed

+3612
-3592
lines changed

contracts/deploy/03-vea-mock.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5656

5757
// TODO: disable the gateway until fully initialized with the correct fees OR allow disputeCreators to add funds again if necessary.
5858
const signer = (await hre.ethers.getSigners())[0];
59-
const core = await KlerosCore__factory.connect(klerosCore.address, signer);
59+
const core = KlerosCore__factory.connect(klerosCore.address, signer);
6060
// TODO: set up the correct fees for the FORKING_COURT
6161
const fee = (await core.courts(Courts.GENERAL)).feeForJuror;
6262
await execute("ForeignGatewayOnEthereum", { from: deployer, log: true }, "changeCourtJurorFee", Courts.GENERAL, fee);

contracts/scripts/keeperBot.ts

+3
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,10 @@ async function main() {
484484
if (!disputes) {
485485
return;
486486
}
487+
487488
let disputesWithoutJurors = await filterAsync(disputes, async (dispute) => {
489+
console.log(dispute.id);
490+
console.log(dispute.currentRoundIndex);
488491
return !(await isDisputeFullyDrawn(dispute));
489492
});
490493

contracts/test/rng/index.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,46 @@
11
import { expect } from "chai";
22
import { ethers, network } from "hardhat";
3-
import { BigNumber } from "ethers";
3+
import { toBigInt } from "ethers";
44
import { IncrementalNG, BlockHashRNG } from "../../typechain-types";
55

66
let rng, rngFactory;
77
const initialNg = 424242;
8+
const abiCoder = ethers.AbiCoder.defaultAbiCoder();
89

910
describe("IncrementalNG", async () => {
1011
beforeEach("Setup", async () => {
1112
rngFactory = await ethers.getContractFactory("IncrementalNG");
1213
rng = (await rngFactory.deploy(initialNg)) as IncrementalNG;
13-
await rng.deployed();
1414
});
1515

1616
it("Should return a number incrementing each time", async () => {
17-
expect(await rng.callStatic.receiveRandomness(689376)).to.equal(initialNg);
17+
expect(await rng.receiveRandomness.staticCall(689376)).to.equal(initialNg);
1818
await rng.receiveRandomness(29543);
19-
expect(await rng.callStatic.receiveRandomness(5894382)).to.equal(initialNg + 1);
19+
expect(await rng.receiveRandomness.staticCall(5894382)).to.equal(initialNg + 1);
2020
await rng.receiveRandomness(0);
21-
expect(await rng.callStatic.receiveRandomness(3465)).to.equal(initialNg + 2);
22-
await rng.receiveRandomness(BigNumber.from(2).pow(255));
23-
expect(await rng.callStatic.receiveRandomness(0)).to.equal(initialNg + 3);
21+
expect(await rng.receiveRandomness.staticCall(3465)).to.equal(initialNg + 2);
22+
await rng.receiveRandomness(toBigInt(2) ** toBigInt(255));
23+
expect(await rng.receiveRandomness.staticCall(0)).to.equal(initialNg + 3);
2424
});
2525
});
2626

2727
describe("BlockHashRNG", async () => {
2828
beforeEach("Setup", async () => {
2929
rngFactory = await ethers.getContractFactory("BlockHashRNG");
3030
rng = (await rngFactory.deploy()) as BlockHashRNG;
31-
await rng.deployed();
3231
});
3332

3433
it("Should return a non-zero number for a block number in the past", async () => {
3534
const tx = await rng.receiveRandomness(9876543210);
3635
const trace = await network.provider.send("debug_traceTransaction", [tx.hash]);
37-
const [rn] = ethers.utils.defaultAbiCoder.decode(["uint"], `0x${trace.returnValue}`);
36+
const [rn] = abiCoder.decode(["uint"], `0x${trace.returnValue}`);
3837
expect(rn).to.equal(0);
3938
});
4039

4140
it("Should return zero for a block number in the future", async () => {
4241
const tx = await rng.receiveRandomness(5);
4342
const trace = await network.provider.send("debug_traceTransaction", [tx.hash]);
44-
const [rn] = ethers.utils.defaultAbiCoder.decode(["uint"], `0x${trace.returnValue}`);
43+
const [rn] = abiCoder.decode(["uint"], `0x${trace.returnValue}`);
4544
expect(rn).to.not.equal(0);
4645
});
4746
});

0 commit comments

Comments
 (0)