Commit f89e27c4 authored by Developer's avatar Developer

update test

parent 8263bce8
const {
loadFixture,
} = require("@nomicfoundation/hardhat-toolbox/network-helpers");
const { expect } = require("chai");
describe("TestMCOPY", function () {
async function deployTestMCOPYFixture() {
let testMCOPY;
beforeEach(async function () {
const TestMCOPY = await ethers.getContractFactory("TestMCOPY");
const testMCOPY = await TestMCOPY.deploy();
return { testMCOPY };
}
testMCOPY = await TestMCOPY.deploy();
await testMCOPY.waitForDeployment();
});
describe("Deployment", function () {
it("Should deploy successfully", async function () {
const { testMCOPY } = await loadFixture(deployTestMCOPYFixture);
expect(testMCOPY.target).to.not.be.null;
});
});
describe("Opcodes", function () {
it("Should correctly perform mcopy", async function () {
const { testMCOPY } = await loadFixture(deployTestMCOPYFixture);
const result = await testMCOPY.testExplicitMCopy();
expect(result).to.equal("0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
});
......
const {
time,
loadFixture,
} = require("@nomicfoundation/hardhat-toolbox/network-helpers");
const { anyValue } = require("@nomicfoundation/hardhat-chai-matchers/withArgs");
const { expect } = require("chai");
describe("TTest", function () {
async function deployTTestFixture() {
const [owner, otherAccount] = await ethers.getSigners();
let ttest;
let owner;
let otherAccount;
beforeEach(async function () {
[owner, otherAccount] = await ethers.getSigners();
const TTest = await ethers.getContractFactory("TTest");
const ttest = await TTest.deploy();
return { ttest, owner, otherAccount };
}
ttest = await TTest.deploy();
await ttest.waitForDeployment();
});
describe("Deployment", function () {
it("Should deploy successfully", async function () {
const { ttest } = await loadFixture(deployTTestFixture);
expect(ttest.target).to.not.be.null;
});
});
describe("Opcodes", function () {
it("Should return BASEFEE", async function () {
const { ttest } = await loadFixture(deployTTestFixture);
// In Hardhat Network, basefee is 1_000_000_000 by default after london
const basefee = await ttest.testBASEFEE();
expect(basefee).to.be.gt(0);
});
it("Should return PREVRANDAO", async function () {
const { ttest } = await loadFixture(deployTTestFixture);
const prevrandao = await ttest.testPREVRANDAO();
expect(prevrandao).to.not.be.null;
});
it("Should return BLOBHASH", async function () {
const { ttest } = await loadFixture(deployTTestFixture);
// Hardhat does not support blobs yet.
// The blobhash opcode will return 0x00...0
const bhash = await ttest.testBLOBHASH();
......@@ -45,7 +38,6 @@ describe("TTest", function () {
});
it("Should return BLOBFEE", async function () {
const { ttest } = await loadFixture(deployTTestFixture);
// In Hardhat Network with cancun fork, blobbasefee is 1.
const blobfee = await ttest.testBLOBFEE();
expect(blobfee).to.equal(1);
......@@ -54,8 +46,6 @@ describe("TTest", function () {
describe("Reentrancy", function () {
it("Should prevent reentrant calls", async function () {
const { ttest } = await loadFixture(deployTTestFixture);
// To test re-entrancy, we deploy an Attacker contract
// that will try to call the `test` function again from its fallback.
const Attacker = await ethers.getContractFactory("Attacker");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment