mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
commit
90d9640900
5 changed files with 58 additions and 10 deletions
6
.github/workflows/ci-deploy.yml
vendored
6
.github/workflows/ci-deploy.yml
vendored
|
|
@ -38,6 +38,12 @@ jobs:
|
||||||
working-directory: hardhat
|
working-directory: hardhat
|
||||||
run: npx hardhat ignition deploy ./ignition/modules/Lock.js --network localhost
|
run: npx hardhat ignition deploy ./ignition/modules/Lock.js --network localhost
|
||||||
|
|
||||||
|
- name: Upload contract address artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: deployment-artifact
|
||||||
|
path: hardhat/deployment-output.json
|
||||||
|
|
||||||
- name: Commit container as new image with contracts
|
- name: Commit container as new image with contracts
|
||||||
run: |
|
run: |
|
||||||
docker commit geth-devnet ghcr.io/${{ github.repository_owner }}/go-ethereum:devnet-with-contracts
|
docker commit geth-devnet ghcr.io/${{ github.repository_owner }}/go-ethereum:devnet-with-contracts
|
||||||
|
|
|
||||||
20
.github/workflows/ci-test.yml
vendored
20
.github/workflows/ci-test.yml
vendored
|
|
@ -22,15 +22,21 @@ jobs:
|
||||||
|
|
||||||
- name: Wait for Geth RPC to be ready
|
- name: Wait for Geth RPC to be ready
|
||||||
run: |
|
run: |
|
||||||
for i in {1..10}; do
|
for i in {1..15}; do
|
||||||
curl -s http://localhost:8545 && break
|
curl -s http://localhost:8545 && break
|
||||||
echo "Waiting for Geth RPC..." && sleep 3
|
echo "Waiting for Geth RPC..." && sleep 3
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Install Hardhat dependencies
|
|
||||||
working-directory: hardhat
|
|
||||||
run: npm install
|
|
||||||
|
|
||||||
- name: Run Hardhat tests against devnet-with-contracts
|
|
||||||
working-directory: hardhat
|
- name: Download contract address artifact
|
||||||
run: npx hardhat test
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: deployment-artifact
|
||||||
|
path: hardhat/
|
||||||
|
|
||||||
|
- name: Install dependencies and run test
|
||||||
|
run: |
|
||||||
|
cd hardhat
|
||||||
|
npm install
|
||||||
|
npx hardhat test test/Lock.external.js --network hell
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
require("@nomicfoundation/hardhat-toolbox");
|
require("@nomicfoundation/hardhat-toolbox");
|
||||||
|
|
||||||
/** @type import('hardhat/config').HardhatUserConfig */
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
solidity: "0.8.28",
|
solidity: "0.8.28",
|
||||||
};
|
networks: {
|
||||||
|
hell: {
|
||||||
|
url: "http://127.0.0.1:8545",
|
||||||
|
accounts: [process.env.PRIVATE_KEY] // Set in GitHub Secrets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
15
hardhat/tasks/index.js
Normal file
15
hardhat/tasks/index.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
task("deploy", "Deploys the contract")
|
||||||
|
.addParam("unlockTime", "Timestamp after which the contract can be unlocked")
|
||||||
|
.setAction(async (taskArgs, hre) => {
|
||||||
|
const Contract = await hre.ethers.getContractFactory("Lock");
|
||||||
|
const contract = await Contract.deploy(taskArgs.unlockTime);
|
||||||
|
await contract.waitForDeployment();
|
||||||
|
|
||||||
|
const address = contract.target;
|
||||||
|
|
||||||
|
fs.writeFileSync("deployment-output.json", JSON.stringify({ address }));
|
||||||
|
|
||||||
|
console.log("Deployed to:", address);
|
||||||
|
});
|
||||||
17
hardhat/test/Lock.external.js
Normal file
17
hardhat/test/Lock.external.js
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
const { expect } = require("chai");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
describe("Lock (deployed contract)", function () {
|
||||||
|
let lock;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
const { address } = JSON.parse(fs.readFileSync("deployment-output.json", "utf-8"));
|
||||||
|
const Lock = await ethers.getContractFactory("Lock");
|
||||||
|
lock = Lock.attach(address);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should read unlock time", async () => {
|
||||||
|
const unlockTime = await lock.unlockTime();
|
||||||
|
expect(unlockTime).to.be.a("bigint");
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue