Skip to content

Commit

Permalink
test: various improvements (openwallet-foundation#1361)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra authored Mar 2, 2023
1 parent fd13bb8 commit cb4e469
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 17 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ module.exports = {
},
},
{
files: ['jest.config.ts', '.eslintrc.js'],
files: ['jest.config.ts', '.eslintrc.js', './scripts/**'],
env: {
node: true,
},
rules: {
'@typescript-eslint/no-var-requires': 'off',
'no-undef': 'off',
},
},
{
files: ['demo/**'],
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ jobs:
uses: ./.github/actions/setup-node
with:
node-version: ${{ matrix.node-version }}

- name: Add ref-napi resolution in Node18
run: node ./scripts/add-ref-napi-resolution.js
if: matrix.node-version == '18.x'

- name: Install dependencies
run: yarn install

Expand Down
2 changes: 1 addition & 1 deletion packages/anoncreds/tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
jest.setTimeout(25000)
jest.setTimeout(50000)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '@aries-framework/core'
import { ariesAskar } from '@hyperledger/aries-askar-shared'

import { describeRunInNodeVersion } from '../../../../../tests/runInVersion'
import { TestRecord } from '../../../../core/src/storage/__tests__/TestRecord'
import { agentDependencies, getAgentConfig, getAgentContext } from '../../../../core/tests/helpers'
import { AskarWallet } from '../../wallet/AskarWallet'
Expand All @@ -16,7 +17,7 @@ import { askarQueryFromSearchQuery } from '../utils'

const startDate = Date.now()

describe('AskarStorageService', () => {
describeRunInNodeVersion([18], 'AskarStorageService', () => {
let wallet: AskarWallet
let storageService: AskarStorageService<TestRecord>
let agentContext: AgentContext
Expand Down
3 changes: 2 additions & 1 deletion packages/askar/src/wallet/__tests__/AskarWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from '@aries-framework/core'
import { Store } from '@hyperledger/aries-askar-shared'

import { describeRunInNodeVersion } from '../../../../../tests/runInVersion'
import { encodeToBase58 } from '../../../../core/src/utils/base58'
import { agentDependencies } from '../../../../core/tests/helpers'
import testLogger from '../../../../core/tests/logger'
Expand All @@ -35,7 +36,7 @@ const walletConfig: WalletConfig = {
keyDerivationMethod: KeyDerivationMethod.Raw,
}

describe('AskarWallet basic operations', () => {
describeRunInNodeVersion([18], 'AskarWallet basic operations', () => {
let askarWallet: AskarWallet

const seed = TypedArrayEncoder.fromString('sample-seed-min-of-32-bytes-long')
Expand Down
3 changes: 2 additions & 1 deletion packages/askar/src/wallet/__tests__/packing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
KeyDerivationMethod,
} from '@aries-framework/core'

import { describeRunInNodeVersion } from '../../../../../tests/runInVersion'
import { agentDependencies } from '../../../../core/tests/helpers'
import testLogger from '../../../../core/tests/logger'
import { AskarWallet } from '../AskarWallet'
Expand All @@ -20,7 +21,7 @@ const walletConfig: WalletConfig = {
keyDerivationMethod: KeyDerivationMethod.Raw,
}

describe('askarWallet packing', () => {
describeRunInNodeVersion([18], 'askarWallet packing', () => {
let askarWallet: AskarWallet

beforeEach(async () => {
Expand Down
10 changes: 0 additions & 10 deletions packages/bbs-signatures/tests/util.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
export function testSkipNode17And18(...parameters: Parameters<typeof test>) {
const version = process.version

if (version.startsWith('v17.') || version.startsWith('v18.')) {
test.skip(...parameters)
} else {
test(...parameters)
}
}

export function describeSkipNode17And18(...parameters: Parameters<typeof describe>) {
const version = process.version

Expand Down
2 changes: 1 addition & 1 deletion packages/tenants/tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import 'reflect-metadata'

jest.setTimeout(20000)
jest.setTimeout(50000)
15 changes: 15 additions & 0 deletions scripts/add-ref-napi-resolution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fs = require('fs')
const path = require('path')

// Read package.json
const packageJsonPath = path.join(__dirname, '..', 'package.json')
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath))

// Add ref-napi resolution
packageJson.resolutions = {
...packageJson.resolutions,
'ref-napi': 'npm:@2060.io/ref-napi',
}

// Write package.json
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
4 changes: 3 additions & 1 deletion tests/e2e-askar-indy-sdk-wallet-subject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getAgentOptions } from '../packages/core/tests/helpers'
import { Agent, AutoAcceptCredential, MediatorPickupStrategy } from '@aries-framework/core'

import { e2eTest } from './e2e-test'
import { describeRunInNodeVersion } from './runInVersion'
import { SubjectInboundTransport } from './transport/SubjectInboundTransport'
import { SubjectOutboundTransport } from './transport/SubjectOutboundTransport'

Expand Down Expand Up @@ -46,7 +47,8 @@ const senderAgentOptions = getAgentOptions(
})
)

describe.skip('E2E Askar-AnonCredsRS-IndyVDR Subject tests', () => {
// Performance issues outside of Node 18
describeRunInNodeVersion([18], 'E2E Askar-AnonCredsRS-IndyVDR Subject tests', () => {
let recipientAgent: AnonCredsTestsAgent
let mediatorAgent: AnonCredsTestsAgent
let senderAgent: AnonCredsTestsAgent
Expand Down
12 changes: 12 additions & 0 deletions tests/runInVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type NodeVersions = 14 | 16 | 17 | 18

export function describeRunInNodeVersion(versions: NodeVersions[], ...parameters: Parameters<typeof describe>) {
const runtimeVersion = process.version
const mappedVersions = versions.map((version) => `v${version}.`)

if (mappedVersions.some((version) => runtimeVersion.startsWith(version))) {
describe(...parameters)
} else {
describe.skip(...parameters)
}
}

0 comments on commit cb4e469

Please sign in to comment.