Skip to content

test(db): add SHA-256 known-vector tests #443

Description

@GaspardKirira

Summary

Add known-vector and incremental-update tests for the internal SHA-256 implementation used by migration checksums.

Checksum correctness is required to reliably detect modified migration files.

Current behavior

The module includes a self-contained SHA-256 implementation with:

  • reset support;
  • incremental updates;
  • binary updates;
  • digest generation;
  • hexadecimal encoding;
  • the sha256_hex() convenience function.

No automated tests currently validate the implementation.

Expected behavior

The implementation must match standard SHA-256 test vectors and produce identical results regardless of input chunking.

Scope

  • Test the empty string.
  • Test "abc".
  • Test a longer standard vector.
  • Test incremental single-byte updates.
  • Test updates split into different chunk sizes.
  • Test binary input containing zero bytes.
  • Test hexadecimal output length.
  • Test reset and hasher reuse.
  • Preserve the existing public API.

Suggested files

  • modules/db/tests/sha256_test.cpp
  • modules/db/src/Sha256.cpp

Acceptance criteria

  • All expected digests use published SHA-256 values.
  • Incremental and one-shot hashing produce identical digests.
  • Binary data is handled correctly.
  • Reusing a reset hasher produces correct results.
  • Hexadecimal output contains exactly 64 lowercase characters.
  • Existing public APIs remain unchanged.

Non-goals

This issue does not include:

  • replacing SHA-256 with an external crypto library;
  • adding other hash algorithms;
  • benchmarking hash performance.

Suggested labels

  • scope:db
  • type:ci
  • tests
  • good first issue
  • status:ready

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersscope:dbDatabase driversstatus:readyIssue is fully specified and ready for implementationtestsTests, CI coverage and validationtype:ciCI, tests, or tooling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions