Skip to content

Commit 1505c35

Browse files
committed
fix(tests): remove integrity crate deps to fix __num_entry_types symbol conflict
Linking zome_person_integrity, zome_resource_integrity, and zome_gouvernance_integrity into one native test binary causes linker errors: multiple definition of '__num_entry_types' multiple definition of '__num_link_types' These C-level symbols are generated by #[hdk_entry_types]/#[hdk_link_types] macros in each integrity crate, and collide when all three are linked together. Fix: remove all three integrity crate deps. Replace every integrity type reference in the test crate with local mirror structs/enums using serde: - ResourceState, DeviceStatus, ParticipationClaimType local enums - VfAction as String (e.g. "Transfer") - Commitment/EconomicEvent/Claim as serde_json::Value - PersonMirror/ReaAgentMirror get holochain_serialized_bytes::SerializedBytes derive so to_app_option() still works for entry decoding
1 parent 6489f8b commit 1505c35

18 files changed

Lines changed: 315 additions & 181 deletions

Cargo.lock

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dnas/nondominium/tests/Cargo.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ tokio = { workspace = true }
1717
serde = { workspace = true }
1818
serde_json = "1"
1919
rmp-serde = "1"
20-
# Integrity crates compile as rlib (not just cdylib) so they work on host target.
21-
# These MUST be [dependencies] (not [dev-dependencies]) because lib.rs exports
22-
# the common module which references their types.
23-
zome_person_integrity = { path = "../zomes/integrity/zome_person" }
24-
zome_resource_integrity = { path = "../zomes/integrity/zome_resource" }
25-
zome_gouvernance_integrity = { path = "../zomes/integrity/zome_gouvernance" }
20+
# holochain_serialized_bytes provides the SerializedBytes derive macro needed
21+
# for mirror structs to work with Record::entry().to_app_option().
22+
holochain_serialized_bytes = { workspace = true }
2623

2724
[[test]]
2825
name = "misc"

dnas/nondominium/tests/src/common/fixtures.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
//!
33
//! These mirror the TS `samplePerson`, `samplePrivateData`, etc. helpers
44
//! from `tests/src/nondominium/person/common.ts`.
5+
//!
6+
//! All governance enums (VfAction, ParticipationClaimType) are represented as
7+
//! `String` to avoid importing integrity crates. The serde serialisation of
8+
//! Rust enums defaults to the variant name, so `"Transfer"`, `"CustodyTransfer"`,
9+
//! etc. round-trip correctly.
510
611
use holochain::prelude::*;
712
use serde::{Deserialize, Serialize};
813

14+
use super::mirrors::ParticipationClaimType;
15+
916
// ── Role name constants ──────────────────────────────────────
1017
// These MUST match the exact strings the `RoleType::from_str` validation accepts.
1118

@@ -175,10 +182,11 @@ pub fn sample_device(person_hash: ActionHash, device_id: impl Into<String>) -> D
175182
// ── Governance / Commitment fixtures ─────────────────────────
176183

177184
/// Input for `propose_commitment` zome call.
178-
/// The `action` field uses the `VfAction` enum from governance integrity.
185+
/// The `action` field is a `String` matching the `VfAction` enum variant name
186+
/// (e.g. `"Transfer"`, `"Work"`, `"Use"`).
179187
#[derive(Debug, Clone, Serialize, Deserialize)]
180188
pub struct ProposeCommitmentInput {
181-
pub action: zome_gouvernance_integrity::VfAction,
189+
pub action: String,
182190
pub provider: AgentPubKey,
183191
pub resource_hash: Option<ActionHash>,
184192
pub resource_spec_hash: Option<ActionHash>,
@@ -195,7 +203,7 @@ pub fn sample_commitment(provider: AgentPubKey) -> ProposeCommitmentInput {
195203
+ 24 * 60 * 60 * 1_000_000;
196204

197205
ProposeCommitmentInput {
198-
action: zome_gouvernance_integrity::VfAction::Transfer,
206+
action: "Transfer".to_string(),
199207
provider,
200208
resource_hash: None,
201209
resource_spec_hash: None,
@@ -205,9 +213,10 @@ pub fn sample_commitment(provider: AgentPubKey) -> ProposeCommitmentInput {
205213
}
206214

207215
/// Input for `log_economic_event` zome call.
216+
/// The `action` field is a `String` matching the `VfAction` enum variant name.
208217
#[derive(Debug, Clone, Serialize, Deserialize)]
209218
pub struct LogEconomicEventInput {
210-
pub action: zome_gouvernance_integrity::VfAction,
219+
pub action: String,
211220
pub provider: AgentPubKey,
212221
pub receiver: AgentPubKey,
213222
pub resource_inventoried_as: ActionHash,
@@ -250,13 +259,15 @@ pub fn sample_metrics() -> PerformanceMetricsInput {
250259
}
251260

252261
/// Input for `issue_participation_receipts` zome call.
262+
/// The `claim_types` field uses `Vec<ParticipationClaimType>` (local mirror enum)
263+
/// which serializes identically to the integrity crate's enum.
253264
#[derive(Debug, Clone, Serialize, Deserialize)]
254265
pub struct IssueParticipationReceiptsInput {
255266
pub fulfills: ActionHash,
256267
pub fulfilled_by: ActionHash,
257268
pub provider: AgentPubKey,
258269
pub receiver: AgentPubKey,
259-
pub claim_types: Vec<zome_gouvernance_integrity::ParticipationClaimType>,
270+
pub claim_types: Vec<ParticipationClaimType>,
260271
pub provider_metrics: PerformanceMetricsInput,
261272
pub receiver_metrics: PerformanceMetricsInput,
262273
pub resource_hash: Option<ActionHash>,
@@ -266,7 +277,7 @@ pub struct IssueParticipationReceiptsInput {
266277
/// Input for `get_my_participation_claims` zome call.
267278
#[derive(Debug, Clone, Serialize, Deserialize)]
268279
pub struct GetMyParticipationClaimsInput {
269-
pub claim_type_filter: Option<zome_gouvernance_integrity::ParticipationClaimType>,
280+
pub claim_type_filter: Option<ParticipationClaimType>,
270281
pub from_time: Option<Timestamp>,
271282
pub to_time: Option<Timestamp>,
272283
pub limit: Option<u32>,
@@ -277,7 +288,7 @@ pub struct GetMyParticipationClaimsInput {
277288
pub struct DeriveReputationSummaryInput {
278289
pub period_start: Timestamp,
279290
pub period_end: Timestamp,
280-
pub claim_type_filter: Option<Vec<zome_gouvernance_integrity::ParticipationClaimType>>,
291+
pub claim_type_filter: Option<Vec<ParticipationClaimType>>,
281292
}
282293

283294
// ── Capability-based sharing fixtures ────────────────────────

dnas/nondominium/tests/src/common/mirrors.rs

Lines changed: 142 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,65 @@
11
//! Mirror structs for coordinator output types.
22
//!
33
//! Coordinator crates cannot be imported directly because they depend on `hdk`
4-
//! which requires a WASM target. These lightweight mirror structs replicate
5-
//! the serialisation shape so Sweettest can deserialize zome call responses.
4+
//! which requires a WASM target. Integrity crates cannot be linked together
5+
//! because each emits C-level `__num_entry_types` / `__num_link_types` symbols
6+
//! that conflict when multiple integrity crates are linked into one binary.
7+
//!
8+
//! These lightweight mirror structs replicate the serialisation shape so
9+
//! Sweettest can deserialize zome call responses without importing any
10+
//! integrity crate.
611
712
use holochain::prelude::*;
813
use serde::{Deserialize, Serialize};
914

15+
// ── Local enum mirrors ─────────────────────────────────────
16+
17+
/// Mirror of `ResourceState` from `zome_resource_integrity`.
18+
/// Variant names must match the serde serialisation of the real enum.
19+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
20+
pub enum ResourceState {
21+
#[default]
22+
PendingValidation,
23+
Active,
24+
Maintenance,
25+
Retired,
26+
Reserved,
27+
}
28+
29+
/// Mirror of `DeviceStatus` from `zome_person_integrity`.
30+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
31+
pub enum DeviceStatus {
32+
Active,
33+
Inactive,
34+
Revoked,
35+
}
36+
37+
/// Mirror of `ParticipationClaimType` from `zome_gouvernance_integrity::ppr`.
38+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
39+
pub enum ParticipationClaimType {
40+
// Genesis Role - Network Entry
41+
ResourceCreation,
42+
ResourceValidation,
43+
// Core Usage Role - Custodianship
44+
CustodyTransfer,
45+
CustodyAcceptance,
46+
// Intermediate Roles - Specialized Services
47+
MaintenanceCommitmentAccepted,
48+
MaintenanceFulfillmentCompleted,
49+
StorageCommitmentAccepted,
50+
StorageFulfillmentCompleted,
51+
TransportCommitmentAccepted,
52+
TransportFulfillmentCompleted,
53+
GoodFaithTransfer,
54+
// Network Governance
55+
DisputeResolutionParticipation,
56+
ValidationActivity,
57+
RuleCompliance,
58+
// Resource End-of-Life Management
59+
EndOfLifeDeclaration,
60+
EndOfLifeValidation,
61+
}
62+
1063
// ── Person zome mirrors ──────────────────────────────────────
1164

1265
/// Mirror of `PersonProfileOutput` from `zome_person::person`.
@@ -17,8 +70,7 @@ pub struct PersonProfileOutput {
1770
}
1871

1972
/// Mirror of `Person` from `zome_person_integrity`.
20-
/// We keep a separate mirror rather than importing the integrity crate directly
21-
/// so that tests remain decoupled from integrity compilation quirks.
73+
/// Implements `TryFrom<SerializedBytes>` so it can be used with `Record::entry().to_app_option()`.
2274
#[derive(Debug, Clone, Serialize, Deserialize)]
2375
pub struct PersonMirror {
2476
pub name: String,
@@ -27,6 +79,7 @@ pub struct PersonMirror {
2779
#[serde(default)]
2880
pub hrea_agent_hash: Option<ActionHash>,
2981
}
82+
holochain_serialized_bytes::holochain_serial!(PersonMirror);
3083

3184
/// Mirror of `PrivatePersonData` from `zome_person_integrity`.
3285
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -63,6 +116,7 @@ pub struct GetPersonRolesOutput {
63116
}
64117

65118
/// Mirror of hREA `ReaAgent` for cross-DNA bridge tests.
119+
/// Implements `TryFrom<SerializedBytes>` so it can be used with `Record::entry().to_app_option()`.
66120
#[derive(Debug, Clone, Serialize, Deserialize)]
67121
pub struct ReaAgentMirror {
68122
pub id: Option<ActionHash>,
@@ -72,6 +126,7 @@ pub struct ReaAgentMirror {
72126
pub classified_as: Option<Vec<String>>,
73127
pub note: Option<String>,
74128
}
129+
holochain_serialized_bytes::holochain_serial!(ReaAgentMirror);
75130

76131
// ── Resource zome mirrors ────────────────────────────────────
77132

@@ -86,6 +141,26 @@ pub struct ResourceSpecMirror {
86141
pub is_active: bool,
87142
}
88143

144+
/// Mirror of `ResourceSpecification` from `zome_resource_integrity` (full entry shape).
145+
/// Used in `GetResourceSpecWithRulesOutput` mirrors that return the raw entry.
146+
#[derive(Debug, Clone, Serialize, Deserialize)]
147+
pub struct ResourceSpecificationMirror {
148+
pub name: String,
149+
pub description: String,
150+
pub category: String,
151+
pub image_url: Option<String>,
152+
pub tags: Vec<String>,
153+
pub is_active: bool,
154+
}
155+
156+
/// Mirror of `GovernanceRule` from `zome_resource_integrity`.
157+
#[derive(Debug, Clone, Serialize, Deserialize)]
158+
pub struct GovernanceRuleMirror {
159+
pub rule_type: String,
160+
pub rule_data: String,
161+
pub enforced_by: Option<String>,
162+
}
163+
89164
/// Mirror of `CreateResourceSpecificationOutput` from `zome_resource::resource_specification`.
90165
#[derive(Debug, Clone, Serialize, Deserialize)]
91166
pub struct CreateResourceSpecOutput {
@@ -101,14 +176,13 @@ pub struct GetAllResourceSpecsOutput {
101176
}
102177

103178
/// Mirror of `EconomicResource` from `zome_resource_integrity`.
104-
/// The `state` field is serialized as a string by the `ResourceState::Display` impl.
105179
#[derive(Debug, Clone, Serialize, Deserialize)]
106180
pub struct EconomicResourceMirror {
107181
pub quantity: f64,
108182
pub unit: String,
109183
pub custodian: AgentPubKey,
110184
pub current_location: Option<String>,
111-
pub state: zome_resource_integrity::ResourceState,
185+
pub state: ResourceState,
112186
}
113187

114188
/// Mirror of `CreateEconomicResourceOutput` from `zome_resource::economic_resource`.
@@ -127,49 +201,103 @@ pub struct GetAllEconomicResourcesOutput {
127201
// ── Governance / Commitment / Event mirrors ──────────────────
128202

129203
/// Mirror of `ProposeCommitmentOutput` from `zome_gouvernance::commitment`.
204+
/// The `commitment` field is left as opaque JSON since tests mostly need the hash.
130205
#[derive(Debug, Clone, Serialize, Deserialize)]
131206
pub struct ProposeCommitmentOutput {
132207
pub commitment_hash: ActionHash,
133-
pub commitment: zome_gouvernance_integrity::Commitment,
208+
pub commitment: serde_json::Value,
134209
}
135210

136211
/// Mirror of `LogEconomicEventOutput` from `zome_gouvernance::economic_event`.
137212
#[derive(Debug, Clone, Serialize, Deserialize)]
138213
pub struct LogEconomicEventOutput {
139214
pub event_hash: ActionHash,
140-
pub event: zome_gouvernance_integrity::EconomicEvent,
215+
pub event: serde_json::Value,
141216
pub ppr_claims: Option<IssueParticipationReceiptsOutputMirror>,
142217
}
143218

144219
/// Mirror of `ClaimCommitmentOutput` from `zome_gouvernance::commitment`.
145220
#[derive(Debug, Clone, Serialize, Deserialize)]
146221
pub struct ClaimCommitmentOutput {
147222
pub claim_hash: ActionHash,
148-
pub claim: zome_gouvernance_integrity::Claim,
223+
pub claim: serde_json::Value,
149224
}
150225

151226
// ── PPR (Private Participation Receipts) mirrors ─────────────
152227

228+
/// Mirror of `PerformanceMetrics` from `zome_gouvernance_integrity::ppr`.
229+
#[derive(Debug, Clone, Serialize, Deserialize)]
230+
pub struct PerformanceMetricsMirror {
231+
pub timeliness: f64,
232+
pub quality: f64,
233+
pub reliability: f64,
234+
pub communication: f64,
235+
pub overall_satisfaction: f64,
236+
pub notes: Option<String>,
237+
}
238+
239+
/// Mirror of `CryptographicSignature` from `zome_gouvernance_integrity::ppr`.
240+
#[derive(Debug, Clone, Serialize, Deserialize)]
241+
pub struct CryptographicSignatureMirror {
242+
pub recipient_signature: Signature,
243+
pub counterparty_signature: Signature,
244+
pub signed_data_hash: [u8; 32],
245+
pub signing_timestamp: Timestamp,
246+
}
247+
248+
/// Mirror of `PrivateParticipationClaim` from `zome_gouvernance_integrity::ppr`.
249+
#[derive(Debug, Clone, Serialize, Deserialize)]
250+
pub struct PrivateParticipationClaimMirror {
251+
// Standard ValueFlows fields
252+
pub fulfills: ActionHash,
253+
pub fulfilled_by: ActionHash,
254+
pub claimed_at: Timestamp,
255+
// PPR-specific extensions
256+
pub claim_type: ParticipationClaimType,
257+
pub performance_metrics: PerformanceMetricsMirror,
258+
pub bilateral_signature: CryptographicSignatureMirror,
259+
// Additional context
260+
pub counterparty: AgentPubKey,
261+
pub resource_hash: Option<ActionHash>,
262+
pub notes: Option<String>,
263+
}
264+
153265
/// Mirror of `IssueParticipationReceiptsOutput` from `zome_gouvernance::ppr`.
154266
#[derive(Debug, Clone, Serialize, Deserialize)]
155267
pub struct IssueParticipationReceiptsOutputMirror {
156268
pub provider_claim_hash: ActionHash,
157269
pub receiver_claim_hash: ActionHash,
158-
pub provider_claim: zome_gouvernance_integrity::PrivateParticipationClaim,
159-
pub receiver_claim: zome_gouvernance_integrity::PrivateParticipationClaim,
270+
pub provider_claim: PrivateParticipationClaimMirror,
271+
pub receiver_claim: PrivateParticipationClaimMirror,
160272
}
161273

162274
/// Mirror of `GetMyParticipationClaimsOutput` from `zome_gouvernance::ppr`.
163275
#[derive(Debug, Clone, Serialize, Deserialize)]
164276
pub struct GetMyParticipationClaimsOutput {
165-
pub claims: Vec<(ActionHash, zome_gouvernance_integrity::PrivateParticipationClaim)>,
277+
pub claims: Vec<(ActionHash, PrivateParticipationClaimMirror)>,
166278
pub total_count: u32,
167279
}
168280

281+
/// Mirror of `ReputationSummary` from `zome_gouvernance_integrity::ppr`.
282+
#[derive(Debug, Clone, Serialize, Deserialize)]
283+
pub struct ReputationSummaryMirror {
284+
pub total_claims: u32,
285+
pub average_performance: f64,
286+
pub creation_claims: u32,
287+
pub custody_claims: u32,
288+
pub service_claims: u32,
289+
pub governance_claims: u32,
290+
pub end_of_life_claims: u32,
291+
pub period_start: Timestamp,
292+
pub period_end: Timestamp,
293+
pub agent: AgentPubKey,
294+
pub generated_at: Timestamp,
295+
}
296+
169297
/// Mirror of `DeriveReputationSummaryOutput` from `zome_gouvernance::ppr`.
170298
#[derive(Debug, Clone, Serialize, Deserialize)]
171299
pub struct DeriveReputationSummaryOutput {
172-
pub summary: zome_gouvernance_integrity::ReputationSummary,
300+
pub summary: ReputationSummaryMirror,
173301
pub claims_included: u32,
174302
}
175303

@@ -213,5 +341,5 @@ pub struct DeviceMirror {
213341
pub owner_person: ActionHash,
214342
pub registered_at: Timestamp,
215343
pub last_active: Timestamp,
216-
pub status: zome_person_integrity::DeviceStatus,
344+
pub status: DeviceStatus,
217345
}

dnas/nondominium/tests/src/common/zome_calls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ pub async fn propose_commitment(
414414
pub async fn get_all_commitments(
415415
conductor: &SweetConductor,
416416
cell: &SweetCell,
417-
) -> Vec<zome_gouvernance_integrity::Commitment> {
417+
) -> Vec<serde_json::Value> {
418418
conductor
419419
.call(&cell.zome("zome_gouvernance"), "get_all_commitments", ())
420420
.await
@@ -449,7 +449,7 @@ pub async fn log_economic_event(
449449
pub async fn get_all_economic_events(
450450
conductor: &SweetConductor,
451451
cell: &SweetCell,
452-
) -> Vec<zome_gouvernance_integrity::EconomicEvent> {
452+
) -> Vec<serde_json::Value> {
453453
conductor
454454
.call(
455455
&cell.zome("zome_gouvernance"),

0 commit comments

Comments
 (0)