Skip to content

Commit a68460f

Browse files
committed
Add tests
1 parent f5bfdc4 commit a68460f

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

.github/workflows/ci-deploy.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ jobs:
3939

4040
- name: Deploy Contracts
4141
working-directory: ./hardhat
42-
run: npx hardhat run scripts/deploy.ts --network localhost
42+
run: npx hardhat ignition deploy ./ignition/modules/Lock.ts --network localhost
43+
44+
- name: Test Contracts
45+
working-directory: ./hardhat
46+
run: npx hardhat test --network localhost
4347

4448
- name: Autotag
4549
id: autotag

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ services:
1414
--datadir /root/.ethereum
1515
--http
1616
--http.addr 0.0.0.0
17-
--http.api eth,net,web3,personal
17+
--http.api eth,net,web3
1818
--allow-insecure-unlock

hardhat/hardhat.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ const config: HardhatUserConfig = {
77
localhost: {
88
url: "http://127.0.0.1:8545",
99
chainId: 1337
10+
},
11+
node: {
12+
url: "http:127.0.0.1:8545",
13+
chainId: 31337
1014
}
1115
}
1216
};

hardhat/test/Contracts.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { expect } from "chai";
2+
import hre from "hardhat";
3+
import { time } from "@nomicfoundation/hardhat-toolbox/network-helpers";
4+
5+
describe("Lock", function () {
6+
it("Should set the right unlockTime", async function () {
7+
const lockedAmount = 1_000_000_000;
8+
const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60;
9+
const unlockTime = (await time.latest()) + ONE_YEAR_IN_SECS;
10+
11+
// deploy a lock contract where funds can be withdrawn
12+
// one year in the future
13+
const lock = await hre.ethers.deployContract("Lock", [unlockTime], {
14+
value: lockedAmount,
15+
});
16+
17+
// assert that the value is correct
18+
expect(await lock.unlockTime()).to.equal(unlockTime);
19+
});
20+
});

0 commit comments

Comments
 (0)