Skip to content

Commit 2a5089d

Browse files
committed
Use separate test for bigint blocktags
1 parent 3327765 commit 2a5089d

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

packages/hardhat-ethers/test/hardhat-ethers-provider.ts

+37-8
Original file line numberDiff line numberDiff line change
@@ -540,15 +540,7 @@ describe("hardhat ethers provider", function () {
540540
blockTag: blockNumber - 1,
541541
});
542542

543-
const gasEstimationBigInt = await this.env.ethers.provider.estimateGas({
544-
from: signer.address,
545-
to: await contract.getAddress(),
546-
data: "0x371303c0", // inc()
547-
blockTag: BigInt(blockNumber - 1),
548-
});
549-
550543
assertWithin(Number(gasEstimationBefore), 65_000, 70_000);
551-
assert.strictEqual(gasEstimationBefore, gasEstimationBigInt);
552544
});
553545

554546
it("should accept a block hash", async function () {
@@ -696,6 +688,43 @@ describe("hardhat ethers provider", function () {
696688
);
697689
});
698690

691+
it("should accept a block number as a bigint", async function () {
692+
const signer = await this.env.ethers.provider.getSigner(0);
693+
const factory = new this.env.ethers.ContractFactory<[], ExampleContract>(
694+
EXAMPLE_CONTRACT.abi,
695+
EXAMPLE_CONTRACT.deploymentBytecode,
696+
signer
697+
);
698+
const contract = await factory.deploy();
699+
await contract.inc();
700+
701+
const blockNumber = await this.env.ethers.provider.getBlockNumber();
702+
703+
const resultAfter = await this.env.ethers.provider.call({
704+
from: signer.address,
705+
to: contract,
706+
data: "0x3fa4f245", // value()
707+
blockTag: "latest",
708+
});
709+
710+
assert.strictEqual(
711+
resultAfter,
712+
"0x0000000000000000000000000000000000000000000000000000000000000001"
713+
);
714+
715+
const resultBefore = await this.env.ethers.provider.call({
716+
from: signer.address,
717+
to: contract,
718+
data: "0x3fa4f245", // value()
719+
blockTag: BigInt(blockNumber - 1),
720+
});
721+
722+
assert.strictEqual(
723+
resultBefore,
724+
"0x0000000000000000000000000000000000000000000000000000000000000000"
725+
);
726+
});
727+
699728
it("should accept a block hash", async function () {
700729
const signer = await this.env.ethers.provider.getSigner(0);
701730
const factory = new this.env.ethers.ContractFactory<[], ExampleContract>(

0 commit comments

Comments
 (0)