250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 기준
- blockchain
- useState
- CLASS
- solidity
- Props
- HTML
- Redux
- express.js
- hardhat
- SSR
- tailwindcss
- REACT
- middleware
- built in object
- Ethereum
- CSS
- web
- API
- Interface
- evm
- node.js
- typeScript
- bitcoin
- error
- nextJS
- JavaScript
- graphQL
- concept
- 삶
Archives
- Today
- Total
ReasonJun
Hardhat : describe(), Fixture(), ethers.getSigners() 본문
Blockchain/HardHat
Hardhat : describe(), Fixture(), ethers.getSigners()
ReasonJun 2023. 10. 20. 15:12728x90
import { ethers } from "hardhat";
describe("VendingMachine", function () {
// We define a fixture to reuse the same setup in every test.
// We use loadFixture to run this setup once, snapshot that state,
// and reset Hardhat Network to that snapshot in every test.
async function VendingMachineFixture() {
// Contracts are deployed using the first signer/account by default
const [owner, otherAccount] = await ethers.getSigners();
const VendingMachine = await ethers.getContractFactory("VendingMachine");
const vendingMachine = await VendingMachine.deploy();
return { vendingMachine, owner, otherAccount };
}
});
- describe("VendingMachine", function () { ... });: This defines a test suite named "VendingMachine" using Mocha. Inside this suite, you would typically write multiple test cases to test different functions and behaviors of the "VendingMachine" contract.
- async function VendingMachineFixture() { ... }: This is a function named "VendingMachineFixture" that appears to be intended for creating a fixture (a common setup) for your tests. This fixture sets up an instance of the "VendingMachine" contract and provides references to the owner and another account. The await ethers.getSigners() function is used to get a list of available signers (Ethereum accounts) for testing.
- Inside the VendingMachineFixture function, the VendingMachine contract is deployed, and the owner and otherAccount are obtained from the available signers.
It's important to note that you need to add actual test cases within the describe block to test the functions and behavior of the "VendingMachine" contract. You can use assertions and ethers functions to interact with the deployed contract and check its state and behavior in your tests.
728x90
'Blockchain > HardHat' 카테고리의 다른 글
Hardhat : Solidity-coverage (0) | 2023.10.20 |
---|---|
Hardhat : Event filtering (attach, getLogs, topic, Interface, getTransactionReceipt, parseLog) (0) | 2023.10.20 |
Hardhat : .to.emit().withArgs(); (0) | 2023.10.20 |
Hardhat : loadFixture(), it(), expect() (0) | 2023.10.20 |
Hardhat : ethers.getContractFactory() / deploy() / deployed() (1) | 2023.10.20 |
Comments