walletStateFixture function

WalletState walletStateFixture({
  1. SyncStatus syncStatus = const SyncStatus.idle(),
  2. TorState tor = const TorState.off(),
  3. BalanceSnapshot? balance,
  4. int? tip,
  5. SyncStamp? lastSynced,
  6. bool everSynced = false,
  7. bool rescanRebuilding = false,
  8. int seq = 0,
})

A complete, neutral WalletState for tests — override only what a case cares about. PlatformInt64 is int on the host VM (web is out of scope for this SDK), so plain int literals construct the money fields.

tip defaults to what the core reports: a snapshot read at a completed pass (UpToDate) carries that pass's own tip; any other status, none. Pass it explicitly to model a read taken mid-pass (a newer tip recorded).

Implementation

WalletState walletStateFixture({
  SyncStatus syncStatus = const SyncStatus.idle(),
  TorState tor = const TorState.off(),
  BalanceSnapshot? balance,
  int? tip,
  SyncStamp? lastSynced,
  bool everSynced = false,
  bool rescanRebuilding = false,
  int seq = 0,
}) {
  return WalletState(
    balance: balance ?? balanceFixture(),
    syncStatus: syncStatus,
    tor: tor,
    tip:
        tip ??
        switch (syncStatus) {
          SyncStatus_UpToDate(:final tip) => tip,
          _ => null,
        },
    lastSynced: lastSynced,
    everSynced: everSynced,
    rescanRebuilding: rescanRebuilding,
    seq: seq,
  );
}