Skip to content

Commit

Permalink
Updated tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrylR committed Oct 21, 2023
1 parent 8fda9a6 commit 5b90e2b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Deployer } from "../../../../src/deployer/Deployer";
export = async (deployer: Deployer) => {
const ContractWithConstructorArguments = await getContractFactory("ContractWithConstructorArguments");

// const contract = await deployer.deploy(ContractWithConstructorArguments, ["hello"], {
// gasLimit: 1000000,
// });
const contract = await deployer.deploy(ContractWithConstructorArguments, ["hello"], {
gasLimit: 1000000,
});

// await contract.name();
await contract.name();
};
9 changes: 4 additions & 5 deletions test/integration/adapters/ethersAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ describe("EthersAdapter", () => {
});

it("should get abi", async () => {
const abi = (await pureEhtersAdapter.getContractDeployParams(ContractWithConstructor)).abi;
const abi = pureEhtersAdapter.getInterface(ContractWithConstructor);

expect(abi).to.deep.equal(Interface.from(contractWithConstructorABI));
});

it("should get bytecode", async () => {
const bytecode = (await pureEhtersAdapter.getContractDeployParams(ContractWithConstructor)).bytecode;
const bytecode = pureEhtersAdapter.getRawBytecode(ContractWithConstructor);

expect(bytecode).to.equal(contractWithConstructorBytecode);
});
Expand All @@ -78,14 +78,13 @@ describe("EthersAdapter", () => {
});

it("should get abi", async () => {
const abi = (await ethersAdapter.getContractDeployParams(ContractWithConstructorArguments__factory)).abi;
const abi = ethersAdapter.getInterface(ContractWithConstructorArguments__factory);

expect(abi).to.deep.equal(Interface.from(contractWithConstructorABI));
});

it("should get bytecode", async () => {
const bytecode = (await ethersAdapter.getContractDeployParams(ContractWithConstructorArguments__factory))
.bytecode;
const bytecode = ethersAdapter.getRawBytecode(ContractWithConstructorArguments__factory);

expect(bytecode).to.equal(contractWithConstructorBytecode);
});
Expand Down
8 changes: 4 additions & 4 deletions test/integration/adapters/truffleAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ describe("TruffleAdapter", () => {
});

it("should get abi", async () => {
const abi = (await adapter.getContractDeployParams(contractWithConstructorArtifact)).abi;
const abi = adapter.getInterface(contractWithConstructorArtifact);

expect(abi).to.deep.equal(Interface.from(contractWithConstructorABI));
});

it("should get bytecode", async () => {
const bytecode = (await adapter.getContractDeployParams(contractWithConstructorArtifact)).bytecode;
const bytecode = adapter.getRawBytecode(contractWithConstructorArtifact);

expect(bytecode).to.equal(contractWithConstructorBytecode);
});
Expand All @@ -80,13 +80,13 @@ describe("TruffleAdapter", () => {
});

it("should get abi", async () => {
const abi = (await adapter.getContractDeployParams(contractWithConstructorArtifact)).abi;
const abi = adapter.getInterface(contractWithConstructorArtifact);

expect(abi).to.deep.equal(Interface.from(contractWithConstructorABI));
});

it("should get bytecode", async () => {
const bytecode = (await adapter.getContractDeployParams(contractWithConstructorArtifact)).bytecode;
const bytecode = adapter.getRawBytecode(contractWithConstructorArtifact);

expect(bytecode).to.equal(contractWithConstructorBytecode);
});
Expand Down
7 changes: 6 additions & 1 deletion test/integration/transaction-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe("TransactionStorage", async () => {
const tx = await factory.getDeployTransaction("hello", {
from: await (await deployer.getSigner()).getAddress(),
chainId: await deployer.getChainId(),
value: 0,
});

assert.equal(
Expand All @@ -55,8 +56,8 @@ describe("TransactionStorage", async () => {

assert.equal(
await TransactionProcessor.tryRestoreContractAddressByName(
this.hre,
"contracts/another-contracts/Contracts.sol:ContractWithConstructorArguments",
this.hre,
),
await contract.getAddress(),
);
Expand Down Expand Up @@ -94,6 +95,7 @@ describe("TransactionStorage", async () => {
const data = await factory.getDeployTransaction("hello", {
chainId: 1,
from: await (await deployer.getSigner()).getAddress(),
value: 0,
});

await expect(TransactionProcessor.tryRestoreContractAddressByKeyFields(data, this.hre)).to.be.rejectedWith(
Expand All @@ -112,6 +114,7 @@ describe("TransactionStorage", async () => {
const tx = await factory.getDeployTransaction("hello", {
from: ZeroAddress,
chainId: await deployer.getChainId(),
value: 0,
});

await expect(TransactionProcessor.tryRestoreContractAddressByKeyFields(tx, this.hre)).to.be.rejectedWith(
Expand All @@ -131,6 +134,7 @@ describe("TransactionStorage", async () => {
nonce: 0,
from: await (await deployer.getSigner()).getAddress(),
chainId: await deployer.getChainId(),
value: 0,
});

assert.equal(
Expand All @@ -150,6 +154,7 @@ describe("TransactionStorage", async () => {
const data = await factory.getDeployTransaction("hello2", {
from: await (await deployer.getSigner()).getAddress(),
chainId: await deployer.getChainId(),
value: 0,
});

await expect(TransactionProcessor.tryRestoreContractAddressByKeyFields(data, this.hre)).to.be.rejectedWith(
Expand Down
4 changes: 2 additions & 2 deletions test/unit/linker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { Linker } from "../../src/deployer/Linker";
describe("Linker", () => {
describe("validateBytecode", () => {
it("should not throw error if bytecode does not contain unresolved libraries", () => {
expect(Linker.isValidBytecode("0x12345678")).to.be.true;
expect(Linker.isBytecodeNeedsLinking("0x12345678")).to.be.true;
});

it("should throw error if bytecode contains unresolved libraries", () => {
expect(Linker.isValidBytecode("0x1234__LibraryName__5678")).to.be.false;
expect(Linker.isBytecodeNeedsLinking("0x1234__LibraryName__5678")).to.be.false;
});
});
});

0 comments on commit 5b90e2b

Please sign in to comment.