Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 2a087d6

Browse files
committed
Add test of encodeCreation() with default constructor
1 parent 5706855 commit 2a087d6

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

packages/encoder/test/constructor.test.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,30 @@ beforeAll(async () => {
5959

6060
describe("Encoding", () => {
6161
describe("Constructors", () => {
62-
let encoder: Encoder.ContractEncoder;
63-
let bytecode: string;
64-
65-
beforeAll(async () => {
66-
encoder = await Encoder.forArtifact(artifacts.TestContract, {
62+
it("Encodes constructors", async () => {
63+
const artifact = artifacts.TestContract;
64+
const encoder = await Encoder.forArtifact(artifact, {
6765
projectInfo: { compilations }
6866
});
69-
bytecode = Shims.NewToLegacy.forBytecode(artifacts.TestContract.bytecode);
70-
});
71-
72-
it("Encodes constructors", async () => {
67+
const bytecode = Shims.NewToLegacy.forBytecode(artifact.bytecode);
7368
const { data } = await encoder.encodeCreation([1]);
7469
assert.strictEqual(
7570
data,
7671
bytecode +
7772
"0000000000000000000000000000000000000000000000000000000000000001"
7873
);
7974
});
75+
76+
it("Encodes implicit default constructors", async () => {
77+
const artifact = artifacts.AuxContract;
78+
//check that it really is implicit, that it's not in the ABI
79+
assert(!artifact.abi.some(abi => abi.type === "constructor"));
80+
const encoder = await Encoder.forArtifact(artifact, {
81+
projectInfo: { compilations }
82+
});
83+
const bytecode = Shims.NewToLegacy.forBytecode(artifact.bytecode);
84+
const { data } = await encoder.encodeCreation([]);
85+
assert.strictEqual(data, bytecode);
86+
});
8087
});
8188
});

0 commit comments

Comments
 (0)