Skip to content

Commit

Permalink
test: update setup and storage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjei committed Mar 21, 2023
1 parent 53eeddd commit 4e4e1e5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
23 changes: 20 additions & 3 deletions packages/actions/test/e2e/01-setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import {
commonTerms,
getDocumentById,
getCeremonyCircuits,
checkIfObjectExist
checkIfObjectExist,
getWasmStorageFilePath
} from "../../src"
import { CeremonyState, TestingEnvironment } from "../../src/types/enums"

Expand Down Expand Up @@ -74,6 +75,10 @@ describe("Setup", () => {
const r1csLocalFilePath = `./${r1csName}`
const r1csStorageFilePath = getR1csStorageFilePath(circuit.data.prefix!, r1csName)

const wasmName = `${circuit.data.prefix}.wasm`
const wasmLocalFilePath = `./${wasmName}`
const wasmStorageFilePath = getWasmStorageFilePath(circuit.data.prefix!, wasmName)

let ceremonyId: string
let circuitId: string

Expand Down Expand Up @@ -154,10 +159,20 @@ describe("Setup", () => {
streamChunkSizeInMb
)

// 5. setup ceremony
// 5. upload wasm
fs.writeFileSync(wasmLocalFilePath, "wasm")
await multiPartUpload(
userFunctions,
ceremonyBucket,
wasmStorageFilePath,
wasmLocalFilePath,
streamChunkSizeInMb
)

// 6. setup ceremony
ceremonyId = await setupCeremony(userFunctions, ceremony.data, ceremony.data.prefix!, [circuit.data])

// 6. confirm
// 7. confirm
const ceremonyDoc = await getDocumentById(
userFirestore,
commonTerms.collections.ceremonies.name,
Expand Down Expand Up @@ -192,6 +207,7 @@ describe("Setup", () => {
expect(await checkIfObjectExist(userFunctions, ceremonyBucket, zkeyStorageFilePath)).to.be.true
expect(await checkIfObjectExist(userFunctions, ceremonyBucket, potStorageFilePath)).to.be.true
expect(await checkIfObjectExist(userFunctions, ceremonyBucket, r1csStorageFilePath)).to.be.true
expect(await checkIfObjectExist(userFunctions, ceremonyBucket, wasmStorageFilePath)).to.be.true
})
it("should fail to create a new ceremony when the coordinator provides the wrong path to a file required for a ceremony setup (zkey)", async () => {
const objectName = "test_upload.zkey"
Expand All @@ -215,6 +231,7 @@ describe("Setup", () => {
await deleteObjectFromS3(ceremonyBucket, zkeyStorageFilePath)
await deleteObjectFromS3(ceremonyBucket, potStorageFilePath)
await deleteObjectFromS3(ceremonyBucket, r1csStorageFilePath)
await deleteObjectFromS3(ceremonyBucket, wasmStorageFilePath)
await deleteBucket(ceremonyBucket)
await deleteBucket(duplicateBucketName)
// clean up ceremony
Expand Down
16 changes: 15 additions & 1 deletion packages/actions/test/unit/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
} from "../../src"
import { TestingEnvironment } from "../../src/types/enums"
import { ChunkWithUrl, ETagWithPartNumber } from "../../src/types/index"
import { getChunksAndPreSignedUrls, uploadParts } from "../../src/helpers/storage"
import { getChunksAndPreSignedUrls, getWasmStorageFilePath, uploadParts } from "../../src/helpers/storage"
import { completeMultiPartUpload, openMultiPartUpload } from "../../src/helpers/functions"

chai.use(chaiAsPromised)
Expand Down Expand Up @@ -608,6 +608,20 @@ describe("Storage", () => {
})
})

describe("getWasmStorageFilePath", () => {
const wasmCompleteFilename = "circuit.wasm"
it("should return the correct path for a wasm file", () => {
const result = getWasmStorageFilePath(
fakeCircuitsData.fakeCircuitSmallNoContributors.data.prefix!,
wasmCompleteFilename
)
expect(result).to.equal(
`${commonTerms.collections.circuits.name}/${fakeCircuitsData.fakeCircuitSmallNoContributors.data
.prefix!}/${wasmCompleteFilename}`
)
})
})

describe("getPotStorageFilePath", () => {
const potFile = `${potFilenameTemplate}8.ptau`
it("should return the correct path for a pot file", () => {
Expand Down

0 comments on commit 4e4e1e5

Please sign in to comment.