Peaceful.Canton.Localnet.Testing 0.7.3.1

Prefix Reserved
dotnet add package Peaceful.Canton.Localnet.Testing --version 0.7.3.1
                    
NuGet\Install-Package Peaceful.Canton.Localnet.Testing -Version 0.7.3.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Peaceful.Canton.Localnet.Testing" Version="0.7.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Peaceful.Canton.Localnet.Testing" Version="0.7.3.1" />
                    
Directory.Packages.props
<PackageReference Include="Peaceful.Canton.Localnet.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Peaceful.Canton.Localnet.Testing --version 0.7.3.1
                    
#r "nuget: Peaceful.Canton.Localnet.Testing, 0.7.3.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Peaceful.Canton.Localnet.Testing@0.7.3.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Peaceful.Canton.Localnet.Testing&version=0.7.3.1
                    
Install as a Cake Addin
#tool nuget:?package=Peaceful.Canton.Localnet.Testing&version=0.7.3.1
                    
Install as a Cake Tool

Peaceful.Canton.Localnet.Testing

For the full consumer guide, see docs/public/integration-testing.md.

xUnit fixtures for Canton LocalNet integration tests. Sub-modules:

  • EndpointDiscovery — env vars to URLs (JSON Ledger API, Keycloak token endpoint).
  • OAuth2TokenProviderclient_credentials grant with in-memory cache + refresh.
  • JsonLedgerAdminClient — thin HttpClient wrapper. Currently surfaces GET /v2/parties/participant-id.
  • DarUploaderPOST /v2/packages for one DAR or many; idempotent: a KNOWN_PACKAGE_VERSION 400 response is treated as success.
  • PartyAllocatorPOST /v2/parties with hint <consumer-prefix>-<instance-suffix> where the suffix is a 12-hex cryptographic random per fixture instance.
  • UserBuilderPOST /v2/users followed by POST /v2/users/{id}/rights to grant CanActAs / CanReadAs.
  • LocalnetFixture — composes the above into a single user-facing surface via Microsoft.Extensions.DependencyInjection and exposes convenience pass-throughs (UploadDarAsync, AllocatePartyAsync, CreateUserAsync, GetParticipantIdAsync). Validator(slot) returns a per-slot view exposing the same deep modules scoped to a single validator (handy for cross-validator scenarios); KnownSlots() returns the canonical slot set in stable order (sv-validator-1, a-validator-1, b-validator-1, c-validator-1, d-validator-1).

30-line example

await using var fixture = LocalnetFixture.FromEnvironment();

await fixture.UploadDarAsync("./dars/my-workflow-1.0.0.dar");

var party = await fixture.AllocatePartyAsync("globex");

await fixture.CreateUserAsync(
    userId: $"globex-user-{fixture.PartyAllocator.InstanceSuffix}",
    primaryParty: party.PartyId,
    actAs: new[] { party.PartyId });

Environment variables

The fixture reads these env vars (matching the compose stack ports in compose/modules/localnet/env/common.env):

Variable Required Default Purpose
CANTON_LOCALNET_PROFILE no a-validator-1 One of sv-validator-1, a-validator-1, b-validator-1, c-validator-1, d-validator-1.
CANTON_LOCALNET_JSON_API_URL no http://localhost:{10,11,12,13,14}975 per profile Base URL of the JSON Ledger API.
CANTON_LOCALNET_TOKEN_URL no for a/b/c/d, yes for sv http://localhost:8082/realms/{AValidator1,BValidator1,CValidator1,DValidator1}/protocol/openid-connect/token per profile. The SvValidator1 profile has no default — no SV realm is imported into Keycloak today (compose/modules/keycloak/conf/data/ ships A/B/C/D only), so the SV slot's token URL (along with its client id and client secret) must be set explicitly, e.g. pointing at a custom realm you've added. Keycloak token endpoint.
CANTON_LOCALNET_AUDIENCE no https://canton.network.global Expected aud claim.
CANTON_LOCALNET_CLIENT_ID yes OAuth2 client_id.
CANTON_LOCALNET_CLIENT_SECRET yes OAuth2 client_secret.
CANTON_LOCALNET_SCOPE no openid OAuth2 scope.

The integration test (LocalNetIntegrationTests) self-skips when CANTON_LOCALNET_JSON_API_URL / CLIENT_ID / CLIENT_SECRET are not set, so unit tests run cleanly on a developer machine without make up.

These env vars are the fixture / test config layer — distinct from canton-localnet.yaml, which configures the CLI's stack-boot (canton-localnet up). The fixture connects to an already-running stack and needs per-slot URLs / credentials, so env vars are the discovery mechanism here.

Run

dotnet test --filter "Category!=Integration"             # unit tests only
dotnet test                                              # all (smoke skipped unless env set)
dotnet pack src/Peaceful.Canton.Localnet.Testing -c Release

Layout

csharp/
  Directory.Build.props          # net10.0, nullable, treat warnings as errors
  Directory.Packages.props       # central package versions
  NuGet.config                   # pins source to nuget.org with mapping
  coverage.settings.xml          # MTP code-coverage config shared with csharp-ci.yaml
  Peaceful.Canton.Localnet.Testing.sln
  src/Peaceful.Canton.Localnet.Testing/
  tests/Peaceful.Canton.Localnet.Testing.Tests/
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.3.1 0 8/21/2026
0.7.0.1 192 8/13/2026
0.7.0.1-preview.1 53 8/6/2026
0.6.14.1-preview.1 56 8/5/2026
0.6.13.1-preview.1 59 7/22/2026
0.6.11.1-preview.1 265 7/14/2026
0.6.10.1-preview.1 191 7/4/2026
0.6.9.1-preview.1 110 6/24/2026
0.6.5.3-preview.1 194 6/14/2026
0.6.5.2 246 6/10/2026