Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Logging block timestamps
import { BigNumber } from "@ethersproject/bignumber";
import { Signer } from "@ethersproject/abstract-signer";
import { waffle } from "@nomiclabs/buidler";
import { expect } from "chai";
export function shouldBehaveLikeGreeter(_signers: Signer[]): void {
describe("1st Block", function () {
beforeEach(async function () {
await waffle.provider.send("evm_setNextBlockTimestamp", [1597348800]);
const blockTimestamp: BigNumber = await this.testotron.getBlockTimestamp();
console.log({ "1stTimestamp": blockTimestamp.toString() });
});
it("should pass the 1st test", async function () {
expect(await this.greeter.greet()).to.equal("Hello, world!");
await this.greeter.setGreeting("Hola, mundo!");
expect(await this.greeter.greet()).to.equal("Hola, mundo!");
});
});
describe("2nd Block", function () {
it("pass the 2nd test", async function () {
expect(await this.greeter.greet()).to.equal("Hello, world!");
await this.greeter.setGreeting("Hola, mundo!");
expect(await this.greeter.greet()).to.equal("Hola, mundo!");
});
beforeEach(async function () {
const blockTimestamp: BigNumber = await this.testotron.getBlockTimestamp();
console.log({ "2ndTimestamp": blockTimestamp.toString() });
});
});
describe("3rd Block", function () {
it("pass the 2nd test", async function () {
expect(await this.greeter.greet()).to.equal("Hello, world!");
await this.greeter.setGreeting("Hola, mundo!");
expect(await this.greeter.greet()).to.equal("Hola, mundo!");
});
beforeEach(async function () {
const blockTimestamp: BigNumber = await this.testotron.getBlockTimestamp();
console.log({ "3rdTimestamp": blockTimestamp.toString() });
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.