Skip to content

Seed DPNS contested-name prerequisites via SDK_TEST_DATA (extend create_sdk_test_data) #3720

Open

Description

@lklimek

Problem

packages/rs-sdk/tests/fetch/contested_resource.rs::check_mn_voting_prerequisites requires the chain to contain manually-seeded test data:

  1. At least 3 different DPNS names under the dash parent domain.
  2. 3 identities each registering a contested-resource entry for the DPNS name testname (i.e., a 3-way contest in-flight on dash/testname).

Three tests depend on this prereq and are gated with #[ignore = "requires manual DPNS names setup for masternode voting tests; …"]:

  • tests/fetch/contested_resource.rs:31 test_contested_resources
  • tests/fetch/contested_resource.rs:68 test_contested_resources_paging
  • tests/fetch/contested_resource.rs:148 test_contested_resources_end_index_values

Today, running them against a freshly-built local devnet (even one built with SDK_TEST_DATA=true) errors out with:

ERROR main::fetch::contested_resource: Prerequisites for masternode voting tests not met, please configure the network accordingly,
  errors: [
    "Please create at least 3 different DPNS names for masternode voting tests, found 0",
    "Please create 3 identities and create DPNS name `testname` for each of them, found 0"
  ]

Why the gap exists

A confirming grep under packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/ returns zero matches for dpns/domain/contested.

Proposal — create_data_for_dpns_voting

Extend create_sdk_test_data with a fourth sibling seeder. New module:

packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/dpns.rs

Function signature mirrors the existing siblings:

pub(super) fn create_data_for_dpns_voting(
    &self,
    block_info: &BlockInfo,
    transaction: TransactionArg,
    platform_version: &PlatformVersion,
) -> Result<(), Error>

Wire it from …/test/mod.rs::create_sdk_test_data after the three existing calls.

What it materializes at genesis

  • 3 fresh identities — proTxHashes [0x11; 32], [0x12; 32], [0x13; 32] (distinct from the token-test identities at tokens.rs:48-50).
  • Funding — Drive::add_to_system_credits per identity using the existing pub CREDITS_PER_IDENTITY constant from tokens.rs.
  • 5 DPNS domain documents via Drive::add_contested_document_for_contract:
    • 2 filler labels (alice, bobby) — one contender each — so contested_resources.fetch_many() returns ≥ 3 distinct entries.
    • 3 contenders racing on testname — fulfilling the 3-way contest requirement.

Implementation references

Concern File Notes
Wire new seeder + call packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/mod.rs Add mod dpns; and add a fourth call to create_data_for_dpns_voting
New seeder module packages/rs-drive-abci/.../test/dpns.rs To create
Identity-registration template packages/rs-drive-abci/.../test/tokens.rs CREDITS_PER_IDENTITY already pub
Load-bearing call packages/rs-drive/src/drive/document/insert_contested/add_contested_document_for_contract/mod.rs Drive::add_contested_document_for_contract
Vote-poll struct packages/rs-drive/src/drive/votes/resolved/vote_polls/contested_document_resource_vote_poll/mod.rs ContestedDocumentResourceVotePoll
System contract loader packages/rs-drive/src/cache/system_contracts.rs:157 load_dpns()
Document schema (incl. parentNameAndLabel contested index) packages/dpns-contract/schema/v1/dpns-contract-documents.json
DPNS-document construction reference packages/rs-drive-abci/tests/strategy_tests/test_cases/voting_tests.rs:99-130 Existing pattern in strategy tests

Risks / open questions

  1. Auto-init of vote-tally storage tree. Whether add_contested_document_for_contract auto-creates the vote-tally tree for the poll, or whether the seeder must explicitly pass Some(ContestedDocumentVotePollStoredInfo::default()) for the first contender of each poll. Resolve by reading add_contested_document_for_contract/v0/mod.rs before implementing — this decides whether DocumentsAndVoteTally queries return contenders.
  2. Single-contender filler polls. If the contested-resources enumeration only surfaces polls with ≥2 contenders, the alice/bobby fillers must each get a second contender (trivial duplication; same 3 identities can be reused as second contenders).
  3. Idempotency on devnet restart. Genesis-only path so re-running with the same chain seed is naturally idempotent; verify with dashmate reset && SDK_TEST_DATA=true dashmate start.
  4. Network gate. Must remain cfg(create_sdk_test_data) AND assert network == Regtest (existing pattern).

Effort estimate

Medium, 6–10 developer-hours, including verification and lint. Dominant cost is figuring out the contested-document insertion contract (risks 1 and 2).

Test plan

After landing, on a freshly-built devnet with SDK_TEST_DATA=true:

  1. Lift the four #[ignore] attributes at tests/fetch/contested_resource.rs:31,68,148,290.
  2. Run:
    cd packages/rs-sdk
    ./scripts/connect_to_remote.sh <devnet>   # if remote
    cargo test -p dash-sdk --features generate-test-vectors fetch::contested_resource -- --nocapture
  3. Expect check_mn_voting_prerequisites to return Ok(()) and the three dependent tests to pass.

Origin of this issue

Surfaced during fix/rs-sdk-getdocuments-query-context (PR #3711) vector regeneration. Out of scope for that PR — separate follow-up to land on v3.1-dev. Architectural design report: /tmp/nagatha-dpns-seeding-design.md (Nagatha, 2026-05-21).


Co-authored by Claudius the Magnificent AI Agent

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

    enhancementrs-sdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions