Skip to content

test(sdk): pin the empty-label contender path (None → null label, contender kept) #5752

Open

Description

@romchornyi

Expected Behavior

Tests pin what happens to a contender whose domain document has an empty label:

  • ContenderRequest reads it as label: None and keeps created_at;
  • the C contender built from it has a null label pointer, and has_created_at / created_at stay as decoded;
  • the contender stays in the list. It is not dropped, and only its display label is missing.

Current Behavior

#5718 moved the contender decode into rs-sdk. ContenderRequest::from_document filters an empty label to None, and ffi_contender turns None into a null pointer. The list conversion used to allocate an empty C string instead. No test covers the empty-label case.

A valid DPNS document cannot have an empty label: DPNS v1–v3 require minLength: 3, and Drive-ABCI enforces it when the document is created. The tests are defensive. Null already means "did not decode", and the Swift readers already handle it.

Possible Solution

  • rs-sdk: a unit test in contender_request.rs that builds a domain document with label: "" and asserts label == None and created_at unchanged.
  • rs-sdk-ffi: a test in contender_document.rs that passes a ContenderRequest with label: None to ffi_contender and asserts a null label, the timestamp fields as given, and the identity id kept. It frees the contender afterwards.

Alternatives Considered

Reject empty labels explicitly in rs-sdk-ffi. That check already happens in rs-sdk, the layer that owns the decode, so a second check in the FFI would duplicate it.

Additional Context

Raised in review of #5718: #5718 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions