Skip to content

Commit acfcd1b

Browse files
fix(RNG): test fixes
1 parent 9ce3f4b commit acfcd1b

File tree

4 files changed

+57
-30
lines changed

4 files changed

+57
-30
lines changed

contracts/deploy/00-home-chain-arbitration.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,6 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
149149
await execute("KlerosCore", { from: deployer, log: true }, "changeCurrencyRates", pnk, 12225583, 12);
150150
await execute("KlerosCore", { from: deployer, log: true }, "changeCurrencyRates", dai, 60327783, 11);
151151
await execute("KlerosCore", { from: deployer, log: true }, "changeCurrencyRates", weth, 1, 1);
152-
await deploy("DisputeResolver", {
153-
from: deployer,
154-
args: [klerosCore.address],
155-
log: true,
156-
});
157152

158153
const link = linkByChain.get(Number(await getChainId())) ?? AddressZero; // LINK not needed on hardhat local node
159154
const keyHash = keyHashByChain.get(Number(await getChainId())) ?? AddressZero;

contracts/test/arbitration/draw.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ describe("Draw Benchmark", async () => {
441441
}
442442

443443
// Create a dispute
444-
const tx = await arbitrable.createDispute(2, "0x00", 0, {
444+
const tx = await arbitrable.functions["createDispute(string)"]("RNG test", {
445445
value: arbitrationCost,
446446
});
447447
const trace = await network.provider.send("debug_traceTransaction", [tx.hash]);
@@ -451,9 +451,20 @@ describe("Draw Benchmark", async () => {
451451
// Relayer tx
452452
const tx2 = await homeGateway
453453
.connect(await ethers.getSigner(relayer))
454-
.relayCreateDispute(31337, lastBlock.hash, disputeId, 2, "0x00", arbitrable.address, {
455-
value: arbitrationCost,
456-
});
454+
.functions["relayCreateDispute((bytes32,uint256,address,uint256,uint256,uint256,string,uint256,bytes))"](
455+
{
456+
foreignBlockHash: lastBlock.hash,
457+
foreignChainID: 31337,
458+
foreignArbitrable: arbitrable.address,
459+
foreignDisputeID: disputeId,
460+
externalDisputeID: ethers.utils.keccak256(ethers.utils.toUtf8Bytes("RNG test")),
461+
templateId: 0,
462+
templateUri: "",
463+
choices: 2,
464+
extraData: `0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003`, // General Court, 3 jurors
465+
},
466+
{ value: arbitrationCost }
467+
);
457468

458469
await network.provider.send("evm_increaseTime", [2000]); // Wait for minStakingTime
459470
await network.provider.send("evm_mine");

contracts/test/arbitration/unstake.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe("Unstake juror", async () => {
103103

104104
expect(await core.getJurorCourtIDs(deployer)).to.be.deep.equal([BigNumber.from("1"), BigNumber.from("2")]);
105105

106-
await core.createDispute(2, extraData, { value: arbitrationCost });
106+
await core.functions["createDispute(uint256,bytes)"](2, extraData, { value: arbitrationCost });
107107

108108
await network.provider.send("evm_increaseTime", [2000]); // Wait for minStakingTime
109109
await network.provider.send("evm_mine");

contracts/test/integration/index.ts

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,9 @@ describe("Integration tests", async () => {
176176

177177
const roundInfo = await core.getRoundInfo(0, 0);
178178
expect(roundInfo.drawnJurors).deep.equal([deployer, deployer, deployer]);
179-
expect(roundInfo.tokensAtStakePerJuror).to.equal(ONE_HUNDRED_PNK.mul(2));
179+
expect(roundInfo.pnkAtStakePerJuror).to.equal(ONE_HUNDRED_PNK.mul(2));
180180
expect(roundInfo.totalFeesForJurors).to.equal(arbitrationCost);
181+
expect(roundInfo.feeToken).to.equal(ethers.constants.AddressZero);
181182

182183
expect((await core.disputes(0)).period).to.equal(Period.evidence);
183184

@@ -210,55 +211,75 @@ describe("Integration tests", async () => {
210211

211212
await core.setStake(1, ONE_THOUSAND_PNK);
212213
await core.getJurorBalance(deployer, 1).then((result) => {
213-
expect(result.staked).to.equal(ONE_THOUSAND_PNK);
214-
expect(result.locked).to.equal(0);
214+
expect(result.totalStaked).to.equal(ONE_THOUSAND_PNK);
215+
expect(result.totalLocked).to.equal(0);
215216
logJurorBalance(result);
216217
});
217218

218219
await core.setStake(1, ONE_HUNDRED_PNK.mul(5));
219220
await core.getJurorBalance(deployer, 1).then((result) => {
220-
expect(result.staked).to.equal(ONE_HUNDRED_PNK.mul(5));
221-
expect(result.locked).to.equal(0);
221+
expect(result.totalStaked).to.equal(ONE_HUNDRED_PNK.mul(5));
222+
expect(result.totalLocked).to.equal(0);
222223
logJurorBalance(result);
223224
});
224225

225226
await core.setStake(1, 0);
226227
await core.getJurorBalance(deployer, 1).then((result) => {
227-
expect(result.staked).to.equal(0);
228-
expect(result.locked).to.equal(0);
228+
expect(result.totalStaked).to.equal(0);
229+
expect(result.totalLocked).to.equal(0);
229230
logJurorBalance(result);
230231
});
231232

232233
await core.setStake(1, ONE_THOUSAND_PNK.mul(4));
233234
await core.getJurorBalance(deployer, 1).then((result) => {
234-
expect(result.staked).to.equal(ONE_THOUSAND_PNK.mul(4));
235-
expect(result.locked).to.equal(0);
235+
expect(result.totalStaked).to.equal(ONE_THOUSAND_PNK.mul(4));
236+
expect(result.totalLocked).to.equal(0);
236237
logJurorBalance(result);
237238
});
238-
const tx = await arbitrable.createDispute(2, "0x00", 0, {
239+
const tx = await arbitrable.functions["createDispute(string)"]("RNG test", {
239240
value: arbitrationCost,
240241
});
241242
const trace = await network.provider.send("debug_traceTransaction", [tx.hash]);
242243
const [disputeId] = ethers.utils.defaultAbiCoder.decode(["uint"], `0x${trace.returnValue}`); // get returned value from createDispute()
243-
console.log("Dispute Created");
244-
expect(tx).to.emit(foreignGateway, "DisputeCreation");
245-
expect(tx).to.emit(foreignGateway, "OutgoingDispute");
246-
console.log(`disputeId: ${disputeId}`);
244+
console.log("Dispute Created with disputeId: %d", disputeId);
245+
await expect(tx)
246+
.to.emit(foreignGateway, "CrossChainDisputeOutgoing")
247+
.withArgs(anyValue, arbitrable.address, 1, 2, "0x00");
248+
await expect(tx)
249+
.to.emit(arbitrable, "DisputeRequest")
250+
.withArgs(
251+
foreignGateway.address,
252+
1,
253+
BigNumber.from("100587076116875319099890440047601180158236049259177371049006183970829186180694"),
254+
0,
255+
""
256+
);
247257

248258
const lastBlock = await ethers.provider.getBlock(tx.blockNumber - 1);
249259
const disputeHash = ethers.utils.solidityKeccak256(
250-
["uint", "bytes", "bytes", "uint", "uint", "bytes", "address"],
251-
[31337, lastBlock.hash, ethers.utils.toUtf8Bytes("createDispute"), disputeId, 2, "0x00", arbitrable.address]
260+
["bytes", "bytes32", "uint256", "address", "uint256", "uint256", "bytes"],
261+
[ethers.utils.toUtf8Bytes("createDispute"), lastBlock.hash, 31337, arbitrable.address, disputeId, 2, "0x00"]
252262
);
253263

254-
const events = (await tx.wait()).events;
264+
console.log("dispute hash: ", disputeHash);
255265

256266
// Relayer tx
257267
const tx2 = await homeGateway
258268
.connect(relayer)
259-
.relayCreateDispute(31337, lastBlock.hash, disputeId, 2, "0x00", arbitrable.address, {
260-
value: arbitrationCost,
261-
});
269+
.functions["relayCreateDispute((bytes32,uint256,address,uint256,uint256,uint256,string,uint256,bytes))"](
270+
{
271+
foreignBlockHash: lastBlock.hash,
272+
foreignChainID: 31337,
273+
foreignArbitrable: arbitrable.address,
274+
foreignDisputeID: disputeId,
275+
externalDisputeID: ethers.utils.keccak256(ethers.utils.toUtf8Bytes("RNG test")),
276+
templateId: 0,
277+
templateUri: "",
278+
choices: 2,
279+
extraData: "0x00",
280+
},
281+
{ value: arbitrationCost }
282+
);
262283
expect(tx2).to.emit(homeGateway, "Dispute");
263284
const events2 = (await tx2.wait()).events;
264285

0 commit comments

Comments
 (0)