Skip to content

Commit b90c970

Browse files
committed
test: added a test for IncrementalNG
1 parent 9643594 commit b90c970

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 0.1.0 (2021-11-11)
22

3-
- feat: modern toolchain setup and simple RNG smart contracts ([17f6a76](https://github.com/kleros/kleros-v2/commit/17f6a76))
43
- docs: initial commit ([23356e7](https://github.com/kleros/kleros-v2/commit/23356e7))
54
- docs: license file added ([cb62d2c](https://github.com/kleros/kleros-v2/commit/cb62d2c))
5+
- docs: readme and spdx headers ([8a5b397](https://github.com/kleros/kleros-v2/commit/8a5b397))
66
- docs: updated ([5b9a8f1](https://github.com/kleros/kleros-v2/commit/5b9a8f1))
7+
- feat: modern toolchain setup and simple RNG smart contracts ([17f6a76](https://github.com/kleros/kleros-v2/commit/17f6a76))

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818

1919
## Toolchain:
2020

21-
- Node 16
22-
- Yarn 3 without [PlugnPlay](https://yarnpkg.com/getting-started/migration/#switching-to-plugnplay)
2321
- Solidity 0.8
2422
- Hardhat
2523
- Ethers
2624
- Waffle
2725
- Typescript
26+
- Node 16
27+
- Yarn 3 without [PlugnPlay](https://yarnpkg.com/getting-started/migration/#switching-to-plugnplay)
2828

2929
## Contributing
3030

@@ -36,7 +36,7 @@
3636
- on MacOS via [brew](https://brew.sh/): `brew install node`
3737
- on Windows via [Chocolatey](https://chocolatey.org/): `choco install nvs`
3838
- Install Yarn v1.22: `npm install -g yarn`
39-
- Upgrade Yarn to v3: `yarn set version berry`
39+
- [Upgrade](https://yarnpkg.com/getting-started/install#updating-to-the-latest-versions) Yarn to v3: `yarn set version berry`
4040

4141
### Optional Steps
4242

@@ -70,6 +70,6 @@ Each directory at the root of this repository contains code for each individual
7070
- **`dynamic-script/`**: allows fetching the dynamic content for the arbitration, as described by [ERC-1497: Evidence Standard](https://github.com/ethereum/EIPs/issues/1497).
7171
- **`evidence-display/`**: display interface that should be used to render the evidence for arbitrators, as described by [ERC-1497: Evidence Standard](https://github.com/ethereum/EIPs/issues/1497).
7272

73-
## Deployed Addresses
73+
## Deployment
7474

7575
See [contracts/README.md](contracts/README.md#deployed-addresses).

contracts/test/rng/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from "chai";
22
import { ethers } from "hardhat";
3+
import { BigNumber } from "ethers";
34

45
describe("ConstantNG", function () {
56
it("Should return always the same number", async function () {
@@ -13,3 +14,19 @@ describe("ConstantNG", function () {
1314
expect(await constantRNG.getRN(437280)).to.equal(42);
1415
});
1516
});
17+
18+
describe("IncrementalNG", function () {
19+
it("Should return a number incrementing each time", async function () {
20+
const IncrementalNG = await ethers.getContractFactory("IncrementalNG");
21+
const incrementalNG = await IncrementalNG.deploy();
22+
await incrementalNG.deployed();
23+
24+
expect(await incrementalNG.callStatic.getRN(689376)).to.equal(0);
25+
await incrementalNG.getRN(29543);
26+
expect(await incrementalNG.callStatic.getRN(5894382)).to.equal(1);
27+
await incrementalNG.getRN(BigNumber.from(2).pow(255));
28+
expect(await incrementalNG.callStatic.getRN(3465)).to.equal(2);
29+
await incrementalNG.getRN(0);
30+
expect(await incrementalNG.callStatic.getRN(0)).to.equal(3);
31+
});
32+
});

contracts/typechain/factories/IncrementalNG__factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const _abi = [
8787
];
8888

8989
const _bytecode =
90-
"0x608060405234801561001057600080fd5b50610180806100206000396000f3fe60806040526004361061004a5760003560e01c80631c73601e1461004f5780637b9c34e0146100815780638381f58a14610096578063c1cbbca7146100ac578063ca4742f1146100bd575b600080fd5b34801561005b57600080fd5b5061006f61006a366004610131565b6100e7565b60405190815260200160405180910390f35b61009461008f366004610131565b6100ba565b005b3480156100a257600080fd5b5061006f60005481565b6100946100ba366004610131565b50565b3480156100c957600080fd5b5061006f6100d8366004610131565b50600080546001810190915590565b60008054600181018255806100ff5750600092915050565b6040805133602082015290810182905260600160408051601f1981840301815291905280516020909101209392505050565b60006020828403121561014357600080fd5b503591905056fea264697066735822122040cb2f1d7acbbaf5795cf4881e9b2f91a28086592f5227ed248deab156debf1864736f6c63430008090033";
90+
"0x608060405234801561001057600080fd5b50610180806100206000396000f3fe60806040526004361061004a5760003560e01c80631c73601e1461004f5780637b9c34e0146100815780638381f58a14610096578063c1cbbca7146100ac578063ca4742f1146100bd575b600080fd5b34801561005b57600080fd5b5061006f61006a366004610131565b6100e7565b60405190815260200160405180910390f35b61009461008f366004610131565b6100ba565b005b3480156100a257600080fd5b5061006f60005481565b6100946100ba366004610131565b50565b3480156100c957600080fd5b5061006f6100d8366004610131565b50600080546001810190915590565b60008054600181018255806100ff5750600092915050565b6040805133602082015290810182905260600160408051601f1981840301815291905280516020909101209392505050565b60006020828403121561014357600080fd5b503591905056fea2646970667358221220abbb67524d2ef027650864ec865ea3d2edccc0a550cc8eb16ac0a69c005e2a3c64736f6c63430008090033";
9191

9292
export class IncrementalNG__factory extends ContractFactory {
9393
constructor(

contracts/typechain/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
/* Autogenerated file. Do not edit manually. */
22
/* tslint:disable */
33
/* eslint-disable */
4-
export type { Greeter } from "./Greeter";
54
export type { ConstantNG } from "./ConstantNG";
65
export type { IncrementalNG } from "./IncrementalNG";
76
export type { RNG } from "./RNG";
87

9-
export { Greeter__factory } from "./factories/Greeter__factory";
108
export { ConstantNG__factory } from "./factories/ConstantNG__factory";
119
export { IncrementalNG__factory } from "./factories/IncrementalNG__factory";
1210
export { RNG__factory } from "./factories/RNG__factory";

0 commit comments

Comments
 (0)