Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ jobs:
--head=HEAD \
--parallel
- name: Coverage summary
run: |
echo "::group::Unit test coverage summary"
yarn script:coverage:report \
--base=origin/${{ github.base_ref }} \
--head=HEAD
echo "::endgroup::"
check-migration-lock:
# Verifies migrations.lock.json is in sync with src/migrations for any
# affected SQL store package that defines a `migrations:check-lock`
Expand Down
2 changes: 1 addition & 1 deletion core/acs-reader/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 0,
functions: 0,
Expand Down
2 changes: 1 addition & 1 deletion core/amulet-service/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 80,
functions: 80,
Expand Down
2 changes: 1 addition & 1 deletion core/asyncapi-client/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 80,
functions: 80,
Expand Down
2 changes: 1 addition & 1 deletion core/daml-codegen-helpers/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 0,
functions: 0,
Expand Down
4 changes: 2 additions & 2 deletions core/ledger-client-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"dev": "tsup --watch --onSuccess \"tsc\"",
"flatpack": "yarn pack --out \"$FLATPACK_OUTDIR\"",
"clean": "tsc -b --clean; rm -rf dist",
"test": "vitest run --project node --project browser --passWithNoTests",
"test:coverage": "vitest run --project node --project browser --coverage --passWithNoTests"
"test": "vitest run --project node --project browser",
"test:coverage": "vitest run --project node --project browser --coverage"
},
"devDependencies": {
"@types/node": "^25.3.3",
Expand Down
146 changes: 146 additions & 0 deletions core/ledger-client-types/src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { describe, expect, it } from 'vitest'
import { EventFilterBySetup, TransactionFilterBySetup } from './utils'

const PARTY_ID = 'alice::abc123'
const TEMPLATE_ID = 'pkg:Module:Template'
const INTERFACE_ID = 'pkg:Module:Interface'

describe('TransactionFilterBySetup', () => {
it('builds a party filter for a single template id', () => {
const filter = TransactionFilterBySetup({
partyId: PARTY_ID,
templateIds: TEMPLATE_ID,
})

expect(filter.filtersByParty).toEqual({
[PARTY_ID]: {
cumulative: [
{
identifierFilter: {
TemplateFilter: {
value: {
templateId: TEMPLATE_ID,
includeCreatedEventBlob: true,
},
},
},
},
],
},
})
})

it('normalizes template ids and adds a wildcard filter when requested', () => {
const filter = TransactionFilterBySetup({
partyId: PARTY_ID,
templateIds: [TEMPLATE_ID, 'pkg:Module:Other'],
includeWildcard: true,
})

expect(filter.filtersByParty?.[PARTY_ID]?.cumulative).toEqual([
{
identifierFilter: {
TemplateFilter: {
value: {
templateId: TEMPLATE_ID,
includeCreatedEventBlob: true,
},
},
},
},
{
identifierFilter: {
TemplateFilter: {
value: {
templateId: 'pkg:Module:Other',
includeCreatedEventBlob: true,
},
},
},
},
{
identifierFilter: {
WildcardFilter: {
value: { includeCreatedEventBlob: true },
},
},
},
])
})

it('builds interface filters when no template ids are provided', () => {
const filter = TransactionFilterBySetup({
partyId: PARTY_ID,
interfaceIds: INTERFACE_ID,
})

expect(filter.filtersByParty?.[PARTY_ID]?.cumulative).toEqual([
{
identifierFilter: {
InterfaceFilter: {
value: {
interfaceId: INTERFACE_ID,
includeInterfaceView: true,
includeCreatedEventBlob: true,
},
},
},
},
])
})

it('uses filtersForAnyParty for master users', () => {
const filter = TransactionFilterBySetup({
isMasterUser: true,
templateIds: TEMPLATE_ID,
})

expect(filter.filtersByParty).toEqual({})
expect(filter.filtersForAnyParty).toEqual({
cumulative: [
{
identifierFilter: {
InterfaceFilter: {
value: {
interfaceId: TEMPLATE_ID,
includeInterfaceView: true,
includeCreatedEventBlob: true,
},
},
},
},
],
})
})

it('requires a party id for non-master users', () => {
expect(() =>
TransactionFilterBySetup({ templateIds: TEMPLATE_ID })
).toThrow('Party must be provided for non-master users')
})
})

describe('EventFilterBySetup', () => {
it('defaults verbose to false', () => {
const filter = EventFilterBySetup({
partyId: PARTY_ID,
templateIds: TEMPLATE_ID,
})

expect(filter.verbose).toBe(false)
})

it('includes verbose when requested', () => {
const filter = EventFilterBySetup({
partyId: PARTY_ID,
templateIds: TEMPLATE_ID,
verbose: true,
})

expect(filter.verbose).toBe(true)
expect(filter.filtersByParty?.[PARTY_ID]?.cumulative).toHaveLength(1)
})
})
3 changes: 2 additions & 1 deletion core/ledger-client-types/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export default defineConfig({
test: {
coverage: {
include: ['src/**/*.ts'],
exclude: ['src/generated-clients/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 0,
functions: 0,
Expand Down
2 changes: 1 addition & 1 deletion core/ledger-client/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig({
include: ['src/**/*.ts'],
exclude: ['src/test-utils.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 80,
functions: 80,
Expand Down
2 changes: 1 addition & 1 deletion core/ledger-proto/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 0,
functions: 0,
Expand Down
2 changes: 1 addition & 1 deletion core/provider-dapp/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 80,
functions: 80,
Expand Down
2 changes: 1 addition & 1 deletion core/provider-ledger/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 80,
functions: 80,
Expand Down
2 changes: 1 addition & 1 deletion core/rpc-errors/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 80,
functions: 80,
Expand Down
2 changes: 1 addition & 1 deletion core/rpc-generator/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 0,
functions: 0,
Expand Down
2 changes: 1 addition & 1 deletion core/rpc-transport/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 0,
functions: 0,
Expand Down
2 changes: 1 addition & 1 deletion core/signing-blockdaemon/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 80,
functions: 80,
Expand Down
2 changes: 1 addition & 1 deletion core/signing-dfns/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 80,
functions: 80,
Expand Down
2 changes: 1 addition & 1 deletion core/signing-fireblocks/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 80,
functions: 80,
Expand Down
2 changes: 1 addition & 1 deletion core/signing-internal/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
coverage: {
include: ['src/**/*.ts'],
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reporter: ['text', 'html', 'lcov', 'json-summary'],
thresholds: {
lines: 80,
functions: 80,
Expand Down
6 changes: 2 additions & 4 deletions core/signing-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"dev": "tsup --watch --onSuccess \"tsc\"",
"flatpack": "yarn pack --out \"$FLATPACK_OUTDIR\"",
"clean": "tsc -b --clean && rm -rf ./dist",
"test": "vitest run --project node --project browser --passWithNoTests",
"test:coverage": "vitest run --project node --project browser --coverage --passWithNoTests"
"test": "vitest run --project node",
"test:coverage": "vitest run --project node --coverage"
},
"dependencies": {
"@canton-network/core-wallet-auth": "workspace:^",
Expand All @@ -35,9 +35,7 @@
"@types/fs-extra": "^11.0.4",
"@types/lodash": "^4.17.24",
"@types/node": "^25.3.3",
"@vitest/browser-playwright": "^4.1.2",
"@vitest/coverage-v8": "^4.1.2",
"playwright": "^1.58.2",
"tsup": "^8.5.1",
"typescript": "^5.9.3",
"vitest": "^4.1.2"
Expand Down
Loading