Merge pull request #18 from radost5454/ggggg

testtt
This commit is contained in:
radost5454 2025-06-04 17:22:57 +03:00 committed by GitHub
commit 90d9640900
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 58 additions and 10 deletions

View file

@ -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

View file

@ -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

View file

@ -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
View 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);
});

View 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");
});
});