Commit f89e27c4 authored by Developer's avatar Developer

update test

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