-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[evm] Separated the Move contract tests from the Solidity contract tests
- Added the suffix `_Sol` to the names of the Solidity contracts so that they don't conflict with the Move contract names - Duplicated the hardhat tests, so one is for the Move contracts, and another is for the Solidity contracts, and they don't overlap - Merged the automated test scripts. `compile_all_and_test.sh` will compile both Move and Solidity contracts and test them. - Fixed the test failures in the Event contract TODO: - move-to-yul does not support string literals. Closes: diem#180
- Loading branch information
1 parent
6d2afae
commit b5287fe
Showing
15 changed files
with
196 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,42 @@ | ||
const { expect } = require("chai"); | ||
const { ethers } = require("hardhat"); | ||
|
||
describe("Event", function () { | ||
before(async function () { | ||
this.Event = await ethers.getContractFactory("Event"); | ||
this.event = await this.Event.deploy(); | ||
await this.event.deployed(); | ||
}); | ||
it("emitSimpleEvent(42) should return an event", async function () { | ||
const tx = this.event.emitSimpleEvent(42); | ||
await expect(tx).to.emit(this.event, 'SimpleEvent').withArgs(42); | ||
}); | ||
it("emitSimpleEventTwice(42) should return two events", async function () { | ||
const tx = this.event.emitSimpleEventTwice(42); | ||
const make_test = function(contract_name) { | ||
return function() { | ||
before(async function () { | ||
this.Event = await ethers.getContractFactory(contract_name); | ||
this.event = await this.Event.deploy(); | ||
await this.event.deployed(); | ||
}); | ||
it("emitSimpleEvent(42) should return an event", async function () { | ||
const tx = this.event.emitSimpleEvent(42); | ||
await expect(tx).to.emit(this.event, 'SimpleEvent').withArgs(42); | ||
await expect(tx).to.emit(this.event, 'SimpleEvent').withArgs(84); | ||
}); | ||
it("emitMyEvent(42) should return an event", async function () { | ||
const tx = this.event.emitMyEvent(42); | ||
await expect(tx).to.emit(this.event, 'MyEvent').withArgs(42, 'hello_event'); | ||
}); | ||
it("emitMyEventTwice(42) should return two events", async function () { | ||
const tx = this.event.emitMyEventTwice(42); | ||
await expect(tx).to.emit(this.event, 'MyEvent').withArgs(42, 'hello_event_#1'); | ||
await expect(tx).to.emit(this.event, 'MyEvent').withArgs(84, 'hello_event_#2'); | ||
}); | ||
}); | ||
}); | ||
it("emitSimpleEventTwice(42) should return two events", async function () { | ||
const tx = this.event.emitSimpleEventTwice(42); | ||
await expect(tx).to.emit(this.event, 'SimpleEvent').withArgs(42); | ||
await expect(tx).to.emit(this.event, 'SimpleEvent').withArgs(84); | ||
}); | ||
it("emitMyEvent(42) should return an event", async function () { | ||
const tx = this.event.emitMyEvent(42); | ||
await expect(tx).to.emit(this.event, 'MyEvent').withArgs(42, 'hello_event'); | ||
}); | ||
it("emitMyEventTwice(42) should return two events", async function () { | ||
const tx = this.event.emitMyEventTwice(42); | ||
await expect(tx).to.emit(this.event, 'MyEvent').withArgs(42, 'hello_event_#1'); | ||
await expect(tx).to.emit(this.event, 'MyEvent').withArgs(84, 'hello_event_#2'); | ||
}); | ||
it("emitMyEventWith(42, 'hello_event') should return an event", async function () { | ||
const tx = this.event.emitMyEventWith(42, "hello_event"); | ||
await expect(tx).to.emit(this.event, 'MyEvent').withArgs(42, 'hello_event'); | ||
}); | ||
it("emitMyEventWithTwice(42, 'hello_event') should return two events", async function () { | ||
const tx = this.event.emitMyEventWithTwice(42, "hello_event"); | ||
await expect(tx).to.emit(this.event, 'MyEvent').withArgs(42, 'hello_event'); | ||
await expect(tx).to.emit(this.event, 'MyEvent').withArgs(84, 'hello_event'); | ||
}); | ||
} | ||
}; | ||
|
||
describe("Event (the Move contract)", make_test('Event')); | ||
describe("Event_Sol (the Solidity contract)", make_test('Event_Sol')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
const { expect } = require("chai"); | ||
const { ethers } = require("hardhat"); | ||
|
||
describe("Native", function () { | ||
before(async function () { | ||
this.Native = await ethers.getContractFactory("Native"); | ||
this.native = await this.Native.deploy(); | ||
await this.native.deployed(); | ||
}); | ||
it("getContractAddr() should return the contract address", async function () { | ||
const tx = this.native.getContractAddr(); | ||
expect(await tx).to.equal(this.native.address); | ||
}); | ||
it("getSenderAddr() should return the sender address", async function () { | ||
const tx = this.native.getSenderAddr(); | ||
expect(await tx).to.equal(this.native.signer.address); | ||
}); | ||
}); | ||
const make_test = function(contract_name) { | ||
return function () { | ||
before(async function () { | ||
this.Native = await ethers.getContractFactory(contract_name); | ||
this.native = await this.Native.deploy(); | ||
await this.native.deployed(); | ||
}); | ||
it("getContractAddr() should return the contract address", async function () { | ||
const tx = this.native.getContractAddr(); | ||
expect(await tx).to.equal(this.native.address); | ||
}); | ||
it("getSenderAddr() should return the sender address", async function () { | ||
const tx = this.native.getSenderAddr(); | ||
expect(await tx).to.equal(this.native.signer.address); | ||
}); | ||
} | ||
}; | ||
|
||
describe("Native (the Move contract)", make_test("Native")); | ||
describe("Native_Sol (the Solidity contract)", make_test("Native_Sol")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
const { expect } = require("chai"); | ||
const { ethers } = require("hardhat"); | ||
|
||
describe("Revert", function () { | ||
before(async function () { | ||
this.Revert = await ethers.getContractFactory("Revert"); | ||
this.revert = await this.Revert.deploy(); | ||
await this.revert.deployed(); | ||
}); | ||
it("revertIf0(0) should revert", async function () { | ||
const tx = this.revert.revertIf0(0); | ||
await expect(tx).to.be.reverted; | ||
}); | ||
it("revertWithMessage() should revert with a message", async function () { | ||
const tx = this.revert.revertWithMessage(); | ||
await expect(tx).to.be.revertedWith('error message'); | ||
}); | ||
}); | ||
const make_test = function(contract_name) { | ||
return function () { | ||
before(async function () { | ||
this.Revert = await ethers.getContractFactory(contract_name); | ||
this.revert = await this.Revert.deploy(); | ||
await this.revert.deployed(); | ||
}); | ||
it("revertIf0(0) should revert", async function () { | ||
const tx = this.revert.revertIf0(0); | ||
await expect(tx).to.be.reverted; | ||
}); | ||
it("revertWithMessage() should revert with a message", async function () { | ||
const tx = this.revert.revertWithMessage(); | ||
await expect(tx).to.be.revertedWith('error message'); | ||
}); | ||
} | ||
}; | ||
|
||
describe("Revert (the Move contract)", make_test("Revert")); | ||
describe("Revert_Sol (the Solidity contract)", make_test("Revert_Sol")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters