Skip to content

Commit

Permalink
fix: correct failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjei committed Jun 30, 2023
1 parent 7e7f9f6 commit f55e832
Show file tree
Hide file tree
Showing 8 changed files with 468 additions and 452 deletions.
10 changes: 5 additions & 5 deletions packages/actions/test/data/samples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ const fakeCircuitSmallNoContributors = generateFakeCircuit({
data: {
name: "Circuit Small",
description: "Short description of Circuit Small",
prefix: "circuit_small",
prefix: "circuit-small",
sequencePosition: 1,
fixedTimeWindow: 10,
zKeySizeInBytes: 45020,
Expand Down Expand Up @@ -342,7 +342,7 @@ const fakeCircuitSmallNoContributors = generateFakeCircuit({
verification: {
cfOrVm: CircuitContributionVerificationMechanism.CF,
vm: {
vmConfigurationType: "",
vmConfigurationType: ""
}
}
}
Expand Down Expand Up @@ -420,7 +420,7 @@ const fakeCircuitSmallContributors = generateFakeCircuit({
data: {
name: "Circuit Small",
description: "Short description of Circuit Small",
prefix: "circuit-small",
prefix: "circuit_small",
sequencePosition: 1,
fixedTimeWindow: 10,
zKeySizeInBytes: 45020,
Expand Down Expand Up @@ -476,7 +476,7 @@ const fakeCircuitSmallContributors = generateFakeCircuit({
verification: {
cfOrVm: CircuitContributionVerificationMechanism.CF,
vm: {
vmConfigurationType: "",
vmConfigurationType: ""
}
}
}
Expand Down Expand Up @@ -544,7 +544,7 @@ const fakeCircuitForFinalization = generateFakeCircuit({
verification: {
cfOrVm: CircuitContributionVerificationMechanism.CF,
vm: {
vmConfigurationType: "",
vmConfigurationType: ""
}
}
}
Expand Down
866 changes: 440 additions & 426 deletions packages/actions/test/unit/ec2.test.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/actions/test/unit/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("Setup", () => {
await signInWithEmailAndPassword(userAuth, users[1].data.email, passwords[1])
const circuit = fakeCircuitsData.fakeCircuitSmallNoContributors
const ceremony = fakeCeremoniesData.fakeCeremonyNotCreated
ceremonyId = await setupCeremony(userFunctions, ceremony, ceremonyBucketPostfix, [circuit as any])
ceremonyId = await setupCeremony(userFunctions, ceremony, ceremonyBucketPostfix, [circuit.data])
expect(ceremonyId).to.be.a.string
const ceremonyDoc = await getDocumentById(
userFirestore,
Expand Down
16 changes: 15 additions & 1 deletion packages/actions/test/utils/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,23 @@ import { FirebaseApp } from "firebase/app"
import { Auth } from "firebase-admin/auth"
import { getCurrentFirebaseAuthUser, signInToFirebaseWithCredentials } from "../../src/index"
import { getAuthenticationConfiguration } from "./configs"
import { generatePseudoRandomStringOfNumbers, sleep } from "./helpers"
import { UserDocumentReferenceAndData } from "../../src/types/index"

/**
* Sleeps the function execution for given millis.
* @dev to be used in combination with loggers when writing data into files.
* @param ms <number> - sleep amount in milliseconds
* @returns <Promise<any>>
*/
export const sleep = (ms: any) => new Promise((resolve) => setTimeout(resolve, ms))

/**
* Return a pseudo random string of numeric values of specified length.
* @param length <string> - the number of values.
* @returns <string> - a pseudo random string of numeric values.
*/
export const generatePseudoRandomStringOfNumbers = (length: number): string => Math.random().toString(length)

/**
* Create a new Firebase user account with specified email and password.
* @notice On successful creation of the user account, this user will also be signed in to your application.
Expand Down
14 changes: 0 additions & 14 deletions packages/actions/test/utils/helpers.ts

This file was deleted.

6 changes: 4 additions & 2 deletions packages/actions/test/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export {
cleanUpMockUsers,
createNewFirebaseUserWithEmailAndPw,
generateUserPasswords,
setCustomClaims
setCustomClaims,
sleep,
authenticateUserWithGithub,
generatePseudoRandomStringOfNumbers
} from "./authentication"
export { sleep, generatePseudoRandomStringOfNumbers } from "./helpers"
2 changes: 1 addition & 1 deletion packages/backend/src/functions/ceremony.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export const finalizeCeremony = functions
const circuitData = circuit.data()
const { verification } = circuitData

if (verification.cfOrVm === CircuitContributionVerificationMechanism.CF) {
if (verification.cfOrVm === CircuitContributionVerificationMechanism.VM) {
const { vm } = verification
await terminateEC2Instance(ec2Client, vm.vmInstanceId)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export const getAWSVariables = (): any => {
!process.env.AWS_SECRET_ACCESS_KEY ||
!process.env.AWS_ROLE_ARN ||
!process.env.AWS_AMI_ID ||
!process.env.AWS_SNS_TOPIC
!process.env.AWS_SNS_TOPIC_ARN
)
logAndThrowError(COMMON_ERRORS.CM_WRONG_CONFIGURATION)

Expand All @@ -411,7 +411,7 @@ export const getAWSVariables = (): any => {
region: process.env.AWS_REGION || "us-east-1",
roleArn: process.env.AWS_ROLE_ARN!,
amiId: process.env.AWS_AMI_ID!,
snsTopic: process.env.AWS_SNS_TOPIC!
snsTopic: process.env.AWS_SNS_TOPIC_ARN!
}
}

Expand Down

0 comments on commit f55e832

Please sign in to comment.