Skip to content

Commit

Permalink
Add testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Sep 13, 2024
1 parent fd798f4 commit 1f89efa
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions packages/plugin-hardhat/test/defender-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,45 @@ test('calls defender deploy with multiple external libraries', async t => {
assertResult(t, result);
});

test('calls defender deploy with metadata', async t => {
const { spy, deploy, fakeHre, fakeChainId } = t.context;

const contractPath = 'contracts/Greeter.sol';
const contractName = 'Greeter';

const factory = await ethers.getContractFactory(contractName);
const result = await deploy.defenderDeploy(fakeHre, factory, {
metadata: {
commitHash: '4ae3e0d',
tag: 'v1.0.0',
anyOtherField: 'anyValue',
},
});

const buildInfo = await hre.artifacts.getBuildInfo(`${contractPath}:${contractName}`);
sinon.assert.calledWithExactly(spy, {
contractName: contractName,
contractPath: contractPath,
network: fakeChainId,
artifactPayload: JSON.stringify(buildInfo),
licenseType: undefined,
constructorBytecode: '0x',
verifySourceCode: true,
relayerId: undefined,
salt: undefined,
createFactoryAddress: undefined,
txOverrides: undefined,
libraries: undefined,
metadata: {
commitHash: '4ae3e0d',
tag: 'v1.0.0',
anyOtherField: 'anyValue',
},
});

assertResult(t, result);
});

test('waits until address is available', async t => {
const getDeployedContractStub = sinon.stub();
getDeployedContractStub.onFirstCall().returns({
Expand Down

0 comments on commit 1f89efa

Please sign in to comment.