Skip to content

Commit

Permalink
chore: increase test coverage (#1012)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikola-bozin-txfusion authored Apr 12, 2024
1 parent 9342184 commit 352beb4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/hardhat-zksync-verify/test/tests/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@ Instead, this name was received: ${contractFQN}`);
name: 'localGreeter',
});
});

it('should return the empty object', async function () {
const libraries = await getLibraries({} as any);

expect(libraries).to.deep.equal({});
});
});

describe('checkVerificationStatus', async function () {
Expand Down
17 changes: 17 additions & 0 deletions packages/hardhat-zksync-verify/test/tests/solc/bytecode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ describe('compareBytecode', () => {
expect(result).to.equal(null);
});

it('should correctly normalize bytecode with address placeholder', async () => {
const bytecodeWithPlaceholder =
'73000000000000000000000000000000000000000000000000000000000000000000' + 'someBytecode';
const symbolsWithPush20Opcode = {
object: '73' + 'someRuntimeBytecode',
};

const normalizedResult = await bytecodes.normalizeBytecode(
bytecodeWithPlaceholder,
symbolsWithPush20Opcode as any,
);

const expectedNormalizedBytecode = 'someBytecode'; // Adjust this based on your zeroOutSlices implementation

expect(normalizedResult.normalizedBytecode).to.include(expectedNormalizedBytecode);
});

it('should return the normalized bytecode when it matches the reference bytecode', async () => {
const deployedBytecode: Bytecode = new Bytecode('deployedBytecode');
const runtimeBytecodeSymbols = {
Expand Down
26 changes: 24 additions & 2 deletions packages/hardhat-zksync-verify/test/tests/task-actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ describe('verify', async function () {
},
run: sinon.stub().resolves({}),
};

await verify(
{
address: '0x1234567890',
Expand All @@ -557,7 +556,7 @@ describe('verify', async function () {
const hre = {
network: {
zksync: true,
verifyURL: 'http://localhost:3000/verify',
verifyURL: undefined,
},
run: sinon.stub().resolves({}),
};
Expand Down Expand Up @@ -622,6 +621,29 @@ describe('getConstructorArguments', async function () {
sinon.restore();
});

it('should throw an error if constructorArguments are neither an array nor start with 0x', async function () {
const args = {
constructorArgsModule: 'path/to/module',
};
const hre = {
network: {
zksync: true,
},
};
const runSuperStub = sinon.stub().resolves();
const extractModuleStub = sinon.stub(utils, 'extractModule').resolves('invalidConstructorArguments');

try {
await getConstructorArguments(args, hre as any, runSuperStub as any);
fail('Expected a ZkSyncVerifyPluginError to be thrown');
} catch (error: any) {
console.info(error.message);
expect(error.message).to.include('Importing the module for the constructor arguments list failed');
} finally {
extractModuleStub.restore();
}
});

it('should call runSuper if zksync is false', async function () {
const args = {};
const hre = {
Expand Down

0 comments on commit 352beb4

Please sign in to comment.