11import type { VerifyContractArgs } from "@nomicfoundation/hardhat-verify/verify" ;
2+ import type { VerifyResult } from "@nomicfoundation/ignition-core" ;
23import type { VerificationProvidersConfig } from "hardhat/types/config" ;
34import type { HardhatRuntimeEnvironment } from "hardhat/types/hre" ;
45
@@ -9,7 +10,7 @@ import sinon from "sinon";
910import { internalVerifyAction } from "../../src/internal/tasks/verify.js" ;
1011import { useEphemeralIgnitionProject } from "../test-helpers/use-ignition-project.js" ;
1112
12- describe ( "ignition verify task" , ( ) => {
13+ describe . only ( "ignition verify task" , ( ) => {
1314 useEphemeralIgnitionProject ( "minimal" ) ;
1415
1516 let consoleLogStub : sinon . SinonStub ;
@@ -28,6 +29,15 @@ describe("ignition verify task", () => {
2829 consoleErrorStub . restore ( ) ;
2930 } ) ;
3031
32+ const exampleVerifyInfo : VerifyResult = {
33+ address : "0x1234567890123456789012345678901234567890" ,
34+ constructorArgs : [ ] ,
35+ libraries : { } ,
36+ contract : "contracts/Foo.sol:Foo" ,
37+ creationTxHash :
38+ "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" ,
39+ } ;
40+
3141 it ( "should verify on all enabled providers" , async function ( ) {
3242 const verifyCallsByProvider : Array < keyof VerificationProvidersConfig > = [ ] ;
3343
@@ -42,14 +52,7 @@ describe("ignition verify task", () => {
4252 } ;
4353
4454 const mockGetVerificationInformation = async function * ( ) {
45- yield {
46- address : "0x1234567890123456789012345678901234567890" ,
47- constructorArgs : [ ] ,
48- libraries : { } ,
49- contract : "contracts/Foo.sol:Foo" ,
50- creationTxHash :
51- "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" ,
52- } ;
55+ yield exampleVerifyInfo ;
5356 } ;
5457
5558 await internalVerifyAction (
@@ -99,14 +102,7 @@ describe("ignition verify task", () => {
99102 } ;
100103
101104 const mockGetVerificationInformation = async function * ( ) {
102- yield {
103- address : "0x1234567890123456789012345678901234567890" ,
104- constructorArgs : [ ] ,
105- libraries : { } ,
106- contract : "contracts/Foo.sol:Foo" ,
107- creationTxHash :
108- "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" ,
109- } ;
105+ yield exampleVerifyInfo ;
110106 } ;
111107
112108 await internalVerifyAction (
@@ -203,29 +199,14 @@ describe("ignition verify task", () => {
203199 assert . equal ( verifyCalls . length , 6 ) ;
204200
205201 // Each contract should be verified on each provider
206- for ( const contract of [ "contracts/Foo.sol:Foo" , "contracts/Bar.sol:Bar" ] ) {
207- for ( const provider of [ "etherscan" , "blockscout" , "sourcify" ] ) {
208- assert . isTrue (
209- verifyCalls . some (
210- ( c ) => c . provider === provider && c . contract === contract ,
211- ) ,
212- `Expected ${ contract } to be verified on ${ provider } ` ,
213- ) ;
214- }
215- }
216-
217- // Both contracts should have "Verifying contract" log lines
218- const logCalls = consoleLogStub . getCalls ( ) . map ( ( c ) => c . args [ 0 ] ) ;
219- assert . isTrue (
220- logCalls . some ( ( log : string ) =>
221- log . includes ( 'Verifying contract "contracts/Foo.sol:Foo"' ) ,
222- ) ,
223- ) ;
224- assert . isTrue (
225- logCalls . some ( ( log : string ) =>
226- log . includes ( 'Verifying contract "contracts/Bar.sol:Bar"' ) ,
227- ) ,
228- ) ;
202+ assert . deepEqual ( verifyCalls , [
203+ { provider : "etherscan" , contract : "contracts/Foo.sol:Foo" } ,
204+ { provider : "blockscout" , contract : "contracts/Foo.sol:Foo" } ,
205+ { provider : "sourcify" , contract : "contracts/Foo.sol:Foo" } ,
206+ { provider : "etherscan" , contract : "contracts/Bar.sol:Bar" } ,
207+ { provider : "blockscout" , contract : "contracts/Bar.sol:Bar" } ,
208+ { provider : "sourcify" , contract : "contracts/Bar.sol:Bar" } ,
209+ ] ) ;
229210 } ) ;
230211
231212 it ( "should pass force flag through to each provider call" , async function ( ) {
@@ -245,14 +226,7 @@ describe("ignition verify task", () => {
245226 } ;
246227
247228 const mockGetVerificationInformation = async function * ( ) {
248- yield {
249- address : "0x1234567890123456789012345678901234567890" ,
250- constructorArgs : [ ] ,
251- libraries : { } ,
252- contract : "contracts/Foo.sol:Foo" ,
253- creationTxHash :
254- "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" ,
255- } ;
229+ yield exampleVerifyInfo ;
256230 } ;
257231
258232 await internalVerifyAction (
@@ -270,24 +244,23 @@ describe("ignition verify task", () => {
270244 } ) ;
271245
272246 it ( "should skip contracts when artifacts cannot be resolved" , async function ( ) {
247+ let verifyContractCalled = false ;
248+
273249 const mockGetVerificationInformation = async function * ( ) {
274250 yield "contracts/Foo.sol:Foo" ;
275251 } ;
276252
277253 await internalVerifyAction (
278254 { deploymentId : "test-deployment" , force : false } ,
279255 this . hre ,
280- async ( ) => true ,
256+ async ( ) => {
257+ verifyContractCalled = true ;
258+
259+ return true ;
260+ } ,
281261 mockGetVerificationInformation ,
282262 ) ;
283263
284- const logCalls = consoleLogStub . getCalls ( ) . map ( ( c ) => c . args [ 0 ] ) ;
285- assert . isTrue (
286- logCalls . some (
287- ( log : string ) =>
288- log . includes ( "Could not resolve contract artifacts" ) &&
289- log . includes ( "contracts/Foo.sol:Foo" ) ,
290- ) ,
291- ) ;
264+ assert . isFalse ( verifyContractCalled ) ;
292265 } ) ;
293266} ) ;
0 commit comments