using PrivaPub.Federation.Objects; using System.Text.Json.Nodes; namespace PrivaPub.Tests.Federation { public class ObjectRecordsTests { [Fact] public void An_object_larger_than_the_cap_keeps_only_its_hash() { var big = new JsonObject { ["content"] = new string('x', ObjectRecords.MaxRawBytes + 1) }; var (text, hash, bytes, truncated) = ObjectRecords.Capture(big); Assert.Null(text); Assert.True(truncated); Assert.True(bytes > ObjectRecords.MaxRawBytes); Assert.Equal(64, hash.Length); } [Fact] public void A_small_object_is_kept_whole_with_its_hash() { var small = new JsonObject { ["type"] = "Note", ["content"] = "hi" }; var (text, hash, bytes, truncated) = ObjectRecords.Capture(small); Assert.Equal(small.ToJsonString(), text); Assert.False(truncated); Assert.Equal(text.Length, bytes); Assert.Equal(64, hash.Length); Assert.Equal(default, ObjectRecords.Capture(default)); } } }