File tree 2 files changed +14
-6
lines changed
2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -82,8 +82,10 @@ describe("VMs", () => {
82
82
let ec2 : EC2Client
83
83
84
84
beforeAll ( async ( ) => {
85
- ec2 = await createEC2Client ( )
86
- ssmClient = await createSSMClient ( )
85
+ if ( envType === TestingEnvironment . PRODUCTION ) {
86
+ ec2 = await createEC2Client ( )
87
+ ssmClient = await createSSMClient ( )
88
+ }
87
89
} )
88
90
89
91
if ( envType === TestingEnvironment . PRODUCTION ) {
@@ -335,9 +337,11 @@ describe("VMs", () => {
335
337
336
338
// delete users and mock ceremonies
337
339
await cleanUpMockUsers ( adminAuth , adminFirestore , users )
338
- await cleanUpRecursively ( adminFirestore , ceremonyId )
339
- await cleanUpRecursively ( adminFirestore , secondCeremonyId )
340
- await cleanUpRecursively ( adminFirestore , ceremonyClosed . uid )
340
+ try {
341
+ await cleanUpRecursively ( adminFirestore , ceremonyId )
342
+ await cleanUpRecursively ( adminFirestore , secondCeremonyId )
343
+ await cleanUpRecursively ( adminFirestore , ceremonyClosed . uid )
344
+ } catch ( error : any ) { }
341
345
342
346
// remove local files
343
347
fs . rmdirSync ( `${ outputDirectory } ` , { recursive : true } )
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import {
34
34
getAWSVariables
35
35
} from "../lib/utils"
36
36
import { LogLevel } from "../types/enums"
37
+ import { EC2Client } from "@aws-sdk/client-ec2"
37
38
38
39
dotenv . config ( )
39
40
@@ -307,14 +308,17 @@ export const finalizeCeremony = functions
307
308
308
309
printLog ( `Ceremony ${ ceremonyDoc . id } correctly finalized - Coordinator ${ participantDoc . id } ` , LogLevel . INFO )
309
310
310
- const ec2Client = await createEC2Client ( )
311
+ // avoid creating the object if none of the circuits use a VM
312
+ let ec2Client : EC2Client
311
313
312
314
// terminate the VMs
313
315
for ( const circuit of circuits ) {
314
316
const circuitData = circuit . data ( )
315
317
const { verification } = circuitData
316
318
317
319
if ( verification . cfOrVm === CircuitContributionVerificationMechanism . VM ) {
320
+ // avoid creating object twice if the Circuit is not using a VM
321
+ ec2Client = await createEC2Client ( )
318
322
const { vm } = verification
319
323
await terminateEC2Instance ( ec2Client , vm . vmInstanceId )
320
324
}
You can’t perform that action at this time.
0 commit comments