trazaeo 0.5.4

Open-source provenance SDK and specification for verifiable EO and climate data workflows
Documentation
use super::{
    DeterministicS3StorageAdaptor, ProofLogAdaptor, S3PutRequest, SolanaProofLogAdaptor,
    StorageAdaptor,
};
use crate::envelope::{Attestation, PublishEnvelope};
use crate::solana::{init_solana_client, SolanaConfig};

fn publish() -> PublishEnvelope {
    PublishEnvelope {
        schema_version: "1.0.0".to_string(),
        envelope_type: "publish".to_string(),
        issued_at: "2026-01-01T00:00:00Z".to_string(),
        subject_id: "publish-1".to_string(),
        dataset_id: "sst".to_string(),
        dataset_version: "v1".to_string(),
        input_refs: vec!["obj://in".to_string()],
        output_refs: vec!["obj://out".to_string()],
        published_artifacts: vec![crate::checkpoint::CheckpointArtifact {
            artifact_id: "artifact-1".to_string(),
            content_root_hash: "0000000000000000000000000000000000000000000000000000000000000000"
                .to_string(),
            content_descriptor_ref: None,
            content_descriptor_hash: None,
            media_type: "application/vnd+zarr".to_string(),
        }],
        primary_artifact_id: "artifact-1".to_string(),
        checkpoint_manifest_ref: "checkpoint://1".to_string(),
        checkpoint_manifest_hash:
            "0000000000000000000000000000000000000000000000000000000000000000".to_string(),
        checkpoint_id: "checkpoint-1".to_string(),
        checkpoint_log_root_hash:
            "0000000000000000000000000000000000000000000000000000000000000000".to_string(),
        lineage_refs: vec!["capture://1".to_string()],
        verification_policy_id: "verify-default".to_string(),
        attestations: vec![Attestation {
            signer_id: "s".to_string(),
            key_id: "k".to_string(),
            signature: "sig".to_string(),
            signed_at: "2026-01-01T00:00:00Z".to_string(),
        }],
        key_id: "key-1".to_string(),
        stac_refs: vec![],
        reward_context_ref: None,
        reward_context_hash: None,
        provenance_start_mode: "transport_capture".to_string(),
        bootstrap_origin_label: None,
        reward_eligible: false,
    }
}

#[test]
fn deterministic_s3_storage_adaptor_puts_bytes() {
    let adaptor = DeterministicS3StorageAdaptor::new("bucket-a", Some("photos"));
    let stored = adaptor
        .put_bytes(&S3PutRequest {
            key: adaptor.build_key("artifact.bin"),
            bytes: b"hello".to_vec(),
            content_type: "application/octet-stream".to_string(),
        })
        .expect("store object");
    assert_eq!(stored.uri, "s3://bucket-a/photos/artifact.bin");
    assert_eq!(stored.byte_length, 5);
}

#[test]
fn solana_proof_log_adaptor_logs_and_verifies() {
    let client = init_solana_client(&SolanaConfig {
        cluster: "solana-testnet".to_string(),
        program_id: "program-1".to_string(),
    });
    let adaptor = SolanaProofLogAdaptor::new(client, [7u8; 32], "attestor-key");
    let env = publish();
    let result = adaptor
        .log_publish_proof(&env, "2026-01-01T00:01:00Z", 1700000000, [0u8; 32])
        .expect("log proof");
    adaptor
        .verify_publish_proof(&env, &result.commitment)
        .expect("verify proof");
}