-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding hardhat toolbox and few improvements (#3)
* updated: changes related toolbox and other improvements * Update ci.yml * few fixes * Update README.md * updated: pipeline to use latest npm
- Loading branch information
1 parent
62b25bd
commit 1ee9568
Showing
9 changed files
with
97 additions
and
2,485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ jobs: | |
e2e-test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
node-version: [14.x, 16.x, 18.x] | ||
|
@@ -26,16 +27,19 @@ jobs: | |
# uses: borales/[email protected] | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: yarn | ||
- name: "Install packages" | ||
run: yarn | ||
- name: "Rename .env.example to .env" | ||
run: mv .env.example .env | ||
- name: "Install packages with latest npm" | ||
run: npm i -g npm@latest && npm install | ||
- name: "Copy .env.example to .env" | ||
run: cp .env.example .env | ||
- name: "Start hardhat node" | ||
run: yarn hardhat node & sleep 3 | ||
run: npx hardhat node & sleep 3 | ||
- name: "Check for solidity linter errors" | ||
run: npx hardhat check | ||
- name: "Compile contracts" | ||
run: yarn compile | ||
run: npm run compile | ||
- name: "Check solidity coverage" | ||
run: npm run coverage | ||
- name: "Run tests" | ||
run: yarn test | ||
run: npm run test | ||
- name: "Deploy contracts" | ||
run: yarn deploy | ||
run: npm run deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,31 @@ | ||
/* | ||
* This script can only be run through Hardhat, and not through node directly. | ||
* Since ethers or any other hardhat plugins are globally available to Hardhat Runtime Environment. So we are not importing them explicitly. | ||
* So when running this script through node, we will get an error saying that ethers or any other plugins not defined error. | ||
*/ | ||
|
||
const { expect } = require("chai"); | ||
const { ethers } = require("hardhat"); | ||
|
||
describe("Contract Tests", function () { | ||
it("Should return the new greeting once it's changed", async function () { | ||
let accounts; | ||
let greeterContract; | ||
|
||
// `before` will run only once, useful for deploying the contract and use it on every test | ||
// It receives a callback, which can be async. | ||
before(async () => { | ||
// Get the ContractFactory and Signers here. | ||
const contractFactory = await ethers.getContractFactory("Greeter"); | ||
const contract = await contractFactory.deploy("Hello, world!"); | ||
await contract.deployed(); | ||
accounts = await ethers.getSigners(); | ||
// Deploy the contract specifying the constructor arguments | ||
greeterContract = await contractFactory.deploy("Hello, Hardhat!"); | ||
await greeterContract.deployed(); | ||
}); | ||
|
||
expect(await contract.getGreeting()).to.equal("Hello, world!"); | ||
const setGreetingTx = await contract.setGreeting("Hola, mundo!"); | ||
it("Should return the new greeting once it's changed", async function () { | ||
expect(await greeterContract.getGreeting()).to.equal("Hello, Hardhat!"); | ||
const setGreetingTx = await greeterContract.setGreeting("Hola, mundo!"); | ||
// wait for the transaction to be mined | ||
await setGreetingTx.wait(); | ||
expect(await contract.getGreeting()).to.equal("Hola, mundo!"); | ||
expect(await greeterContract.getGreeting()).to.equal("Hola, mundo!"); | ||
}); | ||
}); |
Oops, something went wrong.