mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
Add tests
This commit is contained in:
parent
f5bfdc4d96
commit
a68460f65d
4 changed files with 30 additions and 2 deletions
6
.github/workflows/ci-deploy.yaml
vendored
6
.github/workflows/ci-deploy.yaml
vendored
|
|
@ -39,7 +39,11 @@ jobs:
|
|||
|
||||
- name: Deploy Contracts
|
||||
working-directory: ./hardhat
|
||||
run: npx hardhat run scripts/deploy.ts --network localhost
|
||||
run: npx hardhat ignition deploy ./ignition/modules/Lock.ts --network localhost
|
||||
|
||||
- name: Test Contracts
|
||||
working-directory: ./hardhat
|
||||
run: npx hardhat test --network localhost
|
||||
|
||||
- name: Autotag
|
||||
id: autotag
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@ services:
|
|||
--datadir /root/.ethereum
|
||||
--http
|
||||
--http.addr 0.0.0.0
|
||||
--http.api eth,net,web3,personal
|
||||
--http.api eth,net,web3
|
||||
--allow-insecure-unlock
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ const config: HardhatUserConfig = {
|
|||
localhost: {
|
||||
url: "http://127.0.0.1:8545",
|
||||
chainId: 1337
|
||||
},
|
||||
node: {
|
||||
url: "http:127.0.0.1:8545",
|
||||
chainId: 31337
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
20
hardhat/test/Contracts.ts
Normal file
20
hardhat/test/Contracts.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { expect } from "chai";
|
||||
import hre from "hardhat";
|
||||
import { time } from "@nomicfoundation/hardhat-toolbox/network-helpers";
|
||||
|
||||
describe("Lock", function () {
|
||||
it("Should set the right unlockTime", async function () {
|
||||
const lockedAmount = 1_000_000_000;
|
||||
const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60;
|
||||
const unlockTime = (await time.latest()) + ONE_YEAR_IN_SECS;
|
||||
|
||||
// deploy a lock contract where funds can be withdrawn
|
||||
// one year in the future
|
||||
const lock = await hre.ethers.deployContract("Lock", [unlockTime], {
|
||||
value: lockedAmount,
|
||||
});
|
||||
|
||||
// assert that the value is correct
|
||||
expect(await lock.unlockTime()).to.equal(unlockTime);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue