Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update unit tests for verify plugin #635

Merged
merged 5 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/hardhat-zksync-verify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"fmt": "yarn prettier --write",
"eslint": "eslint 'src/**/*.ts' 'test/**/*.ts'",
"prettier": "prettier 'src/**/*.ts' 'test/**/*.ts'",
"test": "NODE_ENV=test c8 mocha test/tests.ts --no-timeout --exit",
"test": "c8 mocha --recursive \"test/tests/**/*.ts\" --exit",
"build": "tsc --build .",
"clean": "rimraf dist"
},
Expand Down
3 changes: 0 additions & 3 deletions packages/hardhat-zksync-verify/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { TASK_FLATTEN_GET_FLATTENED_SOURCE } from 'hardhat/builtin-tasks/task-na
import { Artifacts, HardhatRuntimeEnvironment, ResolvedFile } from 'hardhat/types';
import { isFullyQualifiedName, parseFullyQualifiedName } from 'hardhat/utils/contract-names';
import {
MULTIPLE_MATCHING_CONTRACTS,
CONTRACT_NAME_NOT_FOUND,
NO_MATCHING_CONTRACT,
LIBRARIES_EXPORT_ERROR,
Expand Down Expand Up @@ -48,8 +47,6 @@ export async function inferContractArtifacts(

if (contractMatches.length === 0) throw new ZkSyncVerifyPluginError(NO_MATCHING_CONTRACT);

if (contractMatches.length > 1) throw new ZkSyncVerifyPluginError(MULTIPLE_MATCHING_CONTRACTS);

return contractMatches[0];
}

Expand Down
6 changes: 3 additions & 3 deletions packages/hardhat-zksync-verify/src/task-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
BUILD_INFO_NOT_FOUND_ERROR,
} from './constants';

import { encodeArguments, retrieveContractBytecode } from './utils';
import { encodeArguments, extractModule, retrieveContractBytecode } from './utils';
import { Libraries } from './types';
import { ZkSyncVerifyPluginError } from './errors';
import { parseFullyQualifiedName } from 'hardhat/utils/contract-names';
Expand Down Expand Up @@ -109,7 +109,7 @@ export async function getConstructorArguments(
const constructorArgsModulePath = path.resolve(process.cwd(), args.constructorArgsModule);

try {
const constructorArguments = (await import(constructorArgsModulePath)).default;
const constructorArguments = await extractModule(constructorArgsModulePath);

// Since our plugin supports both encoded and decoded constructor arguments, we need to check how are they passed
if (!Array.isArray(constructorArguments) && !constructorArguments.startsWith('0x')) {
Expand Down Expand Up @@ -246,7 +246,7 @@ export async function getContractInfo(
deployedBytecode
);

if (contractInformation === null) {
if (contractInformation === undefined || contractInformation === null) {
throw new ZkSyncVerifyPluginError(NO_MATCHING_CONTRACT);
}
} else {
Expand Down
5 changes: 5 additions & 0 deletions packages/hardhat-zksync-verify/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,8 @@ export function parseWrongConstructorArgumentsError(string: string): string {

return `The number of constructor arguments you provided (${data['values']}) does not match the number of constructor arguments the contract has been deployed with (${data['types']}).`;
}

export async function extractModule(constructorArgsModulePath: string) {
const constructorArguments = (await import(constructorArgsModulePath)).default;
return constructorArguments;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
"name": "localGreeter",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.16;

contract Contract {
}
24 changes: 0 additions & 24 deletions packages/hardhat-zksync-verify/test/tests.ts

This file was deleted.

Loading
Loading