Skip to content

deterministic giftwraps for mocks #437

@PatrickGeyer

Description

@PatrickGeyer

Feature Request

User Story

As a dev
I want to deterministically generate mock gift wraps
So that tests are deterministic

Acceptance Criteria

/// Helper to create mock gift wraps for testing
/// Since NDK's GiftWrap usecase requires async operations and cryptography,
/// these must be generated at runtime in seed.dart using the NDK instance
Future<List<Nip01Event>> createMockGiftWraps(
    KeyPair pair, Nip01Event rumor, String recipientPubkey) async {
  Ndk ndk = Ndk(NdkConfig(
      eventVerifier: Bip340EventVerifier(),
      cache: MemCacheManager(),
      engine: NdkEngine.JIT,
      defaultQueryTimeout: Duration(seconds: 10),
      bootstrapRelays: []));
  ndk.accounts
      .loginPrivateKey(pubkey: pair.publicKey, privkey: pair.privateKey!);
  return [
    await ndk.giftWrap
        .toGiftWrap(rumor: rumor, recipientPubkey: recipientPubkey, <b>createdAt: ...</b>),
    await ndk.giftWrap.toGiftWrap(rumor: rumor, recipientPubkey: pair.publicKey, <b>createdAt: ...</b>)
  ];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions