-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity ^0.8.7; | ||
import "hardhat/console.sol"; | ||
|
||
contract Deposit { | ||
receive() external payable { | ||
console.log("Calling receive with value", msg.value); | ||
} | ||
|
||
fallback() external payable { | ||
console.log("Calling fallback", msg.value); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { expect } = require("chai"); | ||
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; | ||
import { BigNumber, Contract } from 'ethers'; | ||
import hre, {ethers} from 'hardhat' | ||
|
||
describe("Deposit", function () { | ||
let contract: Contract; | ||
let signer: SignerWithAddress; | ||
|
||
beforeEach(async () => { | ||
// Deploy contact | ||
const factory = await ethers.getContractFactory("Deposit"); | ||
contract = await factory.deploy(); | ||
await contract.deployed(); | ||
|
||
// Store signer | ||
signer = (await ethers.getSigners())[0] | ||
}); | ||
describe("", function () { | ||
it("", async () => { | ||
const tx = await signer.sendTransaction({to: contract.address, value: 1000}) | ||
console.log('gas limit', tx.gasLimit.toString()) | ||
const rec = await tx.wait() | ||
console.log(rec) | ||
console.log('gas used', rec.gasUsed.toString()) | ||
}); | ||
}); | ||
}); |