Skip to content

Commit

Permalink
fix: attempt to fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed May 2, 2024
1 parent e77abdf commit 37fee78
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
30 changes: 21 additions & 9 deletions src/__tests__/ceramic_integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,24 @@ describe('Ceramic Integration Test', () => {
beforeAll(async () => {
ipfsApiPort1 = await getPort()
ipfsApiPort2 = await getPort()
;[ipfs1, ipfs2, ipfs3, ipfs4] = await Promise.all([
createIPFS(ipfsApiPort1),
createIPFS(ipfsApiPort2),
createIPFS(),
createIPFS(),
])
if (process.env['CAS_USE_IPFS_STORAGE']) {
;[ipfs1, ipfs2, ipfs3, ipfs4] = await Promise.all([
createIPFS(ipfsApiPort1),
createIPFS(ipfsApiPort2),
createIPFS(),
createIPFS(),
])
} else {
;[ipfs3, ipfs4] = await Promise.all([
createIPFS(ipfsApiPort1),
createIPFS(ipfsApiPort2),
createIPFS(),
createIPFS(),
])
}

// Now make sure all ipfs nodes are connected to all other ipfs nodes
const ipfsNodes = [ipfs1, ipfs2, ipfs3, ipfs4]
const ipfsNodes = process.env['CAS_USE_IPFS_STORAGE'] ? [ipfs1, ipfs2, ipfs3, ipfs4] : [ipfs3, ipfs4]
for (const [i] of ipfsNodes.entries()) {
for (const [j] of ipfsNodes.entries()) {
if (i == j) {
Expand All @@ -296,8 +305,11 @@ describe('Ceramic Integration Test', () => {
})

afterAll(async () => {
// await Promise.all([ipfsServer1.stop(), ipfsServer2.stop()])
await Promise.all([ipfs1.stop(), ipfs2.stop(), ipfs3.stop(), ipfs4.stop()])
if (process.env['CAS_USE_IPFS_STORAGE']) {
await Promise.all([ipfs1.stop(), ipfs2.stop(), ipfs3.stop(), ipfs4.stop()])
} else {
await Promise.all([ipfs3.stop(), ipfs4.stop()])
}
await ganacheServer.close()
await anchorLauncher.stop()
})
Expand Down
10 changes: 6 additions & 4 deletions src/services/__tests__/anchor-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ describe('anchor service', () => {
expectPresent(request)
expect(anchor.requestId).toEqual(request.id)

const anchorRecord = await ipfsService.retrieveRecord(anchor.cid)
expect(anchorRecord.prev.toString()).toEqual(request.cid)
expect(anchorRecord.proof).toEqual(ipfsProofCid)
expect(anchorRecord.path).toEqual(anchor.path)
if (process.env['CAS_USE_IPFS_STORAGE']) {
const anchorRecord = await ipfsService.retrieveRecord(anchor.cid)
expect(anchorRecord.prev.toString()).toEqual(request.cid)
expect(anchorRecord.proof).toEqual(ipfsProofCid)
expect(anchorRecord.path).toEqual(anchor.path)
}
}

expectPresent(anchors[0])
Expand Down

0 comments on commit 37fee78

Please sign in to comment.