diff --git a/.github/workflows/ci-deploy.yaml b/.github/workflows/ci-deploy.yaml index ea1521cbb6..9d8eb9818a 100644 --- a/.github/workflows/ci-deploy.yaml +++ b/.github/workflows/ci-deploy.yaml @@ -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 diff --git a/docker-compose.yaml b/docker-compose.yaml index 38e085c3de..e787bcf445 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -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 diff --git a/hardhat/hardhat.config.ts b/hardhat/hardhat.config.ts index 417322d85a..b2eb00b58a 100644 --- a/hardhat/hardhat.config.ts +++ b/hardhat/hardhat.config.ts @@ -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 } } }; diff --git a/hardhat/test/Contracts.ts b/hardhat/test/Contracts.ts new file mode 100644 index 0000000000..6ba77e82c1 --- /dev/null +++ b/hardhat/test/Contracts.ts @@ -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); + }); +}); \ No newline at end of file