Skip to content

Commit

Permalink
Deposit example
Browse files Browse the repository at this point in the history
  • Loading branch information
antico5 committed Sep 21, 2021
1 parent 43e520b commit fa91ead
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
14 changes: 14 additions & 0 deletions misc/contracts/Deposit.sol
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);
}
}
28 changes: 28 additions & 0 deletions misc/test/deposit_test.ts
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())
});
});
});

0 comments on commit fa91ead

Please sign in to comment.