Path: redb/redb.Tests.Integration/Tests/Unit/RedbHashHeaderCanonTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Unit/RedbHashHeaderCanonTests.cs
----
using redb.Core.Models.Entities;
using redb.Core.Utils;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.Unit;
///
/// Full-object-hash plan (2026-09-11): _hash covers the header of the row, not only the
/// Props. What is in and what is out is a contract, pinned here without a database:
/// every header column takes part; the audit trio (date_create, date_modify, who_change) and the
/// identity (id, scheme id) do not - they are stamped outside the hash computation and a hash
/// that carried them could never be reproduced from a reloaded row; header dates canonicalise
/// at second precision in UTC, so a value survives the round trip through any of the three
/// databases.
///
public sealed class RedbHashHeaderCanonTests
{
private static RedbObject Baseline() => new()
{
id = 42, scheme_id = 7, parent_id = 3, owner_id = 1, who_change_id = 1,
name = "n", note = "note", key = 5,
value_long = 1, value_string = "s", value_guid = Guid.Parse("11111111-1111-1111-1111-111111111111"),
value_bool = true, value_double = 1.5, value_numeric = 2.25m,
value_datetime = new DateTimeOffset(2026, 9, 11, 12, 0, 0, TimeSpan.Zero),
value_bytes = [1, 2, 3], value_unique = "K-1",
date_begin = new DateTimeOffset(2026, 1, 1, 0, 0, 0, TimeSpan.Zero),
date_complete = new DateTimeOffset(2026, 2, 1, 0, 0, 0, TimeSpan.Zero),
date_create = new DateTimeOffset(2026, 9, 1, 0, 0, 0, TimeSpan.Zero),
date_modify = new DateTimeOffset(2026, 9, 2, 0, 0, 0, TimeSpan.Zero),
Props = new SimpleProps { Title = "p", Count = 1 }
};
private static Guid HashOf(Action> mutate)
{
var obj = Baseline();
mutate(obj);
return RedbHash.ComputeFor(obj)!.Value;
}
public static IEnumerable