From 5b90e2b6463a88979c633b0300351e10ef892ff1 Mon Sep 17 00:00:00 2001 From: Kyryl R Date: Sat, 21 Oct 2023 16:26:12 +0300 Subject: [PATCH] Updated tests. --- .../hardhat-project-minimal-ethers/migrates/1_deploy.ts | 8 ++++---- test/integration/adapters/ethersAdapter.ts | 9 ++++----- test/integration/adapters/truffleAdapter.ts | 8 ++++---- test/integration/transaction-storage.ts | 7 ++++++- test/unit/linker.ts | 4 ++-- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/test/fixture-projects/hardhat-project-minimal-ethers/migrates/1_deploy.ts b/test/fixture-projects/hardhat-project-minimal-ethers/migrates/1_deploy.ts index d181e0d..772d217 100644 --- a/test/fixture-projects/hardhat-project-minimal-ethers/migrates/1_deploy.ts +++ b/test/fixture-projects/hardhat-project-minimal-ethers/migrates/1_deploy.ts @@ -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(); }; diff --git a/test/integration/adapters/ethersAdapter.ts b/test/integration/adapters/ethersAdapter.ts index 2a39d68..f01f756 100644 --- a/test/integration/adapters/ethersAdapter.ts +++ b/test/integration/adapters/ethersAdapter.ts @@ -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); }); @@ -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); }); diff --git a/test/integration/adapters/truffleAdapter.ts b/test/integration/adapters/truffleAdapter.ts index 7d904a6..1f99196 100644 --- a/test/integration/adapters/truffleAdapter.ts +++ b/test/integration/adapters/truffleAdapter.ts @@ -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); }); @@ -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); }); diff --git a/test/integration/transaction-storage.ts b/test/integration/transaction-storage.ts index 34fb981..20ceeb6 100644 --- a/test/integration/transaction-storage.ts +++ b/test/integration/transaction-storage.ts @@ -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( @@ -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(), ); @@ -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( @@ -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( @@ -131,6 +134,7 @@ describe("TransactionStorage", async () => { nonce: 0, from: await (await deployer.getSigner()).getAddress(), chainId: await deployer.getChainId(), + value: 0, }); assert.equal( @@ -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( diff --git a/test/unit/linker.ts b/test/unit/linker.ts index b68eab6..4a93fec 100644 --- a/test/unit/linker.ts +++ b/test/unit/linker.ts @@ -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; }); }); });