From 2d1ebf8bd47cad3df25633c3df47e9b900682f32 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Fri, 3 Jul 2026 23:48:12 -0400 Subject: [PATCH 1/6] fix(storage): guard prepare timestamp serialization Signed-off-by: Yordis Prieto --- .../TransactionLog/LogRecords/PrepareLogRecord.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EventStore.Core/TransactionLog/LogRecords/PrepareLogRecord.cs b/src/EventStore.Core/TransactionLog/LogRecords/PrepareLogRecord.cs index dadb5e77a..2f1ac5311 100644 --- a/src/EventStore.Core/TransactionLog/LogRecords/PrepareLogRecord.cs +++ b/src/EventStore.Core/TransactionLog/LogRecords/PrepareLogRecord.cs @@ -271,6 +271,7 @@ public override void WriteTo(ref BufferWriterSlim writer) CorrelationId.TryWriteBytes(buffer); writer.Advance(16); + Debug.Assert(TimeStamp.Kind == DateTimeKind.Utc); writer.WriteLittleEndian(TimeStamp.Ticks); _eventTypeSize ??= Encoding.UTF8.GetByteCount(EventType); From be4ddf829b6c31363f9beb38f0801863c1a5e799 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Sat, 4 Jul 2026 00:10:03 -0400 Subject: [PATCH 2/6] fix(storage): reject non-utc prepare timestamps Signed-off-by: Yordis Prieto --- .../LogRecords/PrepareLogRecordViewTests.cs | 21 +++++++++++++++++++ .../InMemory/SingleEventInMemoryStream.cs | 2 +- .../LogRecords/PrepareLogRecord.cs | 6 +++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/PrepareLogRecordViewTests.cs b/src/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/PrepareLogRecordViewTests.cs index 9d4ecbfee..e9a326065 100644 --- a/src/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/PrepareLogRecordViewTests.cs +++ b/src/EventStore.Core.XUnit.Tests/TransactionLog/LogRecords/PrepareLogRecordViewTests.cs @@ -71,6 +71,27 @@ public void should_have_correct_properties() Assert.Equal(Version, _prepare.Version); } + [Fact] + public void constructor_should_reject_non_utc_timestamp() + { + Assert.Throws(() => new PrepareLogRecord( + LogPosition, + _correlationId, + _eventId, + TransactionPosition, + TransactionOffset, + EventStreamId, + null, + ExpectedVersion, + DateTime.Now, + Flags, + EventType, + null, + _data, + _metadata, + Version)); + } + [Fact] public void parsed_record_should_preserve_utc_timestamp_kind() { diff --git a/src/EventStore.Core/Services/Storage/InMemory/SingleEventInMemoryStream.cs b/src/EventStore.Core/Services/Storage/InMemory/SingleEventInMemoryStream.cs index cff43e2bf..6ebf58ae3 100644 --- a/src/EventStore.Core/Services/Storage/InMemory/SingleEventInMemoryStream.cs +++ b/src/EventStore.Core/Services/Storage/InMemory/SingleEventInMemoryStream.cs @@ -149,7 +149,7 @@ public void Write(string eventType, ReadOnlyMemory data) eventStreamId: _streamName, eventStreamIdSize: null, expectedVersion: _eventNumber - 1, - timeStamp: DateTime.Now, + timeStamp: DateTime.UtcNow, flags: Flags, eventType: eventType, eventTypeSize: null, diff --git a/src/EventStore.Core/TransactionLog/LogRecords/PrepareLogRecord.cs b/src/EventStore.Core/TransactionLog/LogRecords/PrepareLogRecord.cs index 2f1ac5311..85b30052f 100644 --- a/src/EventStore.Core/TransactionLog/LogRecords/PrepareLogRecord.cs +++ b/src/EventStore.Core/TransactionLog/LogRecords/PrepareLogRecord.cs @@ -156,6 +156,11 @@ public PrepareLogRecord(long logPosition, throw new ArgumentOutOfRangeException("expectedVersion"); } + if (timeStamp.Kind != DateTimeKind.Utc) + { + throw new ArgumentException("Prepare log record timestamps must be UTC.", nameof(timeStamp)); + } + Flags = flags; TransactionPosition = transactionPosition; TransactionOffset = transactionOffset; @@ -271,7 +276,6 @@ public override void WriteTo(ref BufferWriterSlim writer) CorrelationId.TryWriteBytes(buffer); writer.Advance(16); - Debug.Assert(TimeStamp.Kind == DateTimeKind.Utc); writer.WriteLittleEndian(TimeStamp.Ticks); _eventTypeSize ??= Encoding.UTF8.GetByteCount(EventType); From 4a0263e96dbf4485860f7596597913616bbf1551 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Sat, 4 Jul 2026 00:33:52 -0400 Subject: [PATCH 3/6] fix(storage): normalize scavenge fixture timestamps Signed-off-by: Yordis Prieto --- .../Scavenging/Helpers/TFChunkDbCreationHelper.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/EventStore.Core.Tests/TransactionLog/Scavenging/Helpers/TFChunkDbCreationHelper.cs b/src/EventStore.Core.Tests/TransactionLog/Scavenging/Helpers/TFChunkDbCreationHelper.cs index 74ab6efd9..3ade90d7c 100644 --- a/src/EventStore.Core.Tests/TransactionLog/Scavenging/Helpers/TFChunkDbCreationHelper.cs +++ b/src/EventStore.Core.Tests/TransactionLog/Scavenging/Helpers/TFChunkDbCreationHelper.cs @@ -581,7 +581,9 @@ public Rec(RecType type, int transaction, string streamId, string eventType, Dat Transaction = transaction; StreamId = streamId; EventType = eventType ?? string.Empty; - TimeStamp = timestamp ?? DateTime.UtcNow; + TimeStamp = timestamp.HasValue + ? DateTime.SpecifyKind(timestamp.Value, DateTimeKind.Utc) + : DateTime.UtcNow; Version = version; EventNumber = eventNumber; Data = data; From 0a295dcc47149a6d3df8493caa674a4645c8bb12 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Sat, 4 Jul 2026 01:06:24 -0400 Subject: [PATCH 4/6] fix(storage): enforce scavenge fixture timestamp contract Signed-off-by: Yordis Prieto --- .../Scavenging/Helpers/TFChunkDbCreationHelper.cs | 9 ++++++--- .../Scavenge/Infrastructure/StreamMetadatas.cs | 9 +++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/EventStore.Core.Tests/TransactionLog/Scavenging/Helpers/TFChunkDbCreationHelper.cs b/src/EventStore.Core.Tests/TransactionLog/Scavenging/Helpers/TFChunkDbCreationHelper.cs index 3ade90d7c..49ce0e5d2 100644 --- a/src/EventStore.Core.Tests/TransactionLog/Scavenging/Helpers/TFChunkDbCreationHelper.cs +++ b/src/EventStore.Core.Tests/TransactionLog/Scavenging/Helpers/TFChunkDbCreationHelper.cs @@ -581,9 +581,12 @@ public Rec(RecType type, int transaction, string streamId, string eventType, Dat Transaction = transaction; StreamId = streamId; EventType = eventType ?? string.Empty; - TimeStamp = timestamp.HasValue - ? DateTime.SpecifyKind(timestamp.Value, DateTimeKind.Utc) - : DateTime.UtcNow; + if (timestamp.HasValue && timestamp.Value.Kind != DateTimeKind.Utc) + { + throw new ArgumentException("Scavenge fixture prepare timestamps must be UTC.", nameof(timestamp)); + } + + TimeStamp = timestamp ?? DateTime.UtcNow; Version = version; EventNumber = eventNumber; Data = data; diff --git a/src/EventStore.Core.XUnit.Tests/Scavenge/Infrastructure/StreamMetadatas.cs b/src/EventStore.Core.XUnit.Tests/Scavenge/Infrastructure/StreamMetadatas.cs index 9c8b02cab..e11489a53 100644 --- a/src/EventStore.Core.XUnit.Tests/Scavenge/Infrastructure/StreamMetadatas.cs +++ b/src/EventStore.Core.XUnit.Tests/Scavenge/Infrastructure/StreamMetadatas.cs @@ -27,15 +27,16 @@ public class StreamMetadatas new StreamMetadata(truncateBefore: EventNumber.DeletedStream); public static DateTime EffectiveNow { get; } = new DateTime(2022, 1, 5, 00, 00, 00); - public static DateTime Expired { get; } = EffectiveNow - TimeSpan.FromDays(3); - public static DateTime Cutoff { get; } = EffectiveNow - MaxAgeTimeSpan; - public static DateTime Active { get; } = EffectiveNow - TimeSpan.FromDays(1); + private static DateTime EffectiveNowRecordTimestamp { get; } = new DateTime(2022, 1, 5, 00, 00, 00, DateTimeKind.Utc); + public static DateTime Expired { get; } = EffectiveNowRecordTimestamp - TimeSpan.FromDays(3); + public static DateTime Cutoff { get; } = EffectiveNowRecordTimestamp - MaxAgeTimeSpan; + public static DateTime Active { get; } = EffectiveNowRecordTimestamp - TimeSpan.FromDays(1); public static Rec ScavengePointRec(int transaction, int threshold = 0, DateTime? timeStamp = null) => Rec.Write( transaction: transaction, stream: SystemStreams.ScavengePointsStream, eventType: SystemEventTypes.ScavengePoint, - timestamp: timeStamp ?? EffectiveNow, + timestamp: timeStamp ?? EffectiveNowRecordTimestamp, data: new ScavengePointPayload { Threshold = threshold, From 93b637f6713294ca1bc737216057ab87ace7f0d1 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Sat, 4 Jul 2026 02:17:49 -0400 Subject: [PATCH 5/6] fix(storage): use utc timestamps in storage fixtures Signed-off-by: Yordis Prieto --- .../Chaser/when_chaser_reads_commit_event.cs | 4 ++-- .../when_chaser_reads_committed_prepare_event.cs | 2 +- .../Chaser/when_chaser_reads_prepare_event.cs | 2 +- .../tfchunk_get_actual_raw_position_should.cs | 2 +- .../when_chasing_a_chunked_transaction_log.cs | 16 ++++++++-------- .../TransactionLog/when_closing_the_database.cs | 2 +- ...hen_writing_a_new_chunked_transaction_file.cs | 2 +- ...ing_chunked_transaction_file_with_checksum.cs | 2 +- ..._with_checksum_and_data_bigger_than_buffer.cs | 2 +- ...action_file_with_not_enough_space_in_chunk.cs | 6 +++--- .../when_writing_commit_record_to_file.cs | 4 ++-- .../when_writing_prepare_record_to_file.cs | 4 ++-- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_commit_event.cs b/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_commit_event.cs index b4c48160f..e59c7e604 100644 --- a/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_commit_event.cs +++ b/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_commit_event.cs @@ -31,7 +31,7 @@ public override async ValueTask When(CancellationToken token) transactionOffset: 0xBEEF, eventStreamId: streamId, expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.Data, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, @@ -45,7 +45,7 @@ public override async ValueTask When(CancellationToken token) logPosition: _logPosition, correlationId: _transactionId, transactionPosition: 0, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), firstEventNumber: 10); (written, _) = await Writer.Write(record2, token); diff --git a/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_committed_prepare_event.cs b/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_committed_prepare_event.cs index 36a787ed3..472f506cb 100644 --- a/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_committed_prepare_event.cs +++ b/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_committed_prepare_event.cs @@ -30,7 +30,7 @@ public override async ValueTask When(CancellationToken token) transactionOffset: 0xBEEF, eventStreamId: streamId, expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.IsCommitted | PrepareFlags.TransactionEnd, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, diff --git a/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_prepare_event.cs b/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_prepare_event.cs index 695fc9d0e..db223a6b6 100644 --- a/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_prepare_event.cs +++ b/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_prepare_event.cs @@ -30,7 +30,7 @@ public override async ValueTask When(CancellationToken token) transactionOffset: 0xBEEF, eventStreamId: streamId, expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.SingleWrite, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, diff --git a/src/EventStore.Core.Tests/TransactionLog/tfchunk_get_actual_raw_position_should.cs b/src/EventStore.Core.Tests/TransactionLog/tfchunk_get_actual_raw_position_should.cs index 98dbd6183..6a11bb29e 100644 --- a/src/EventStore.Core.Tests/TransactionLog/tfchunk_get_actual_raw_position_should.cs +++ b/src/EventStore.Core.Tests/TransactionLog/tfchunk_get_actual_raw_position_should.cs @@ -27,7 +27,7 @@ private IPrepareLogRecord CreateRecord(long logPosition, int dataSize { return LogRecord.Prepare(_recordFactory, logPosition, Guid.NewGuid(), Guid.NewGuid(), 0, 0, _streamId, 1, PrepareFlags.None, _eventTypeId, new byte[dataSize], Array.Empty(), - new DateTime(2000, 1, 1, 12, 0, 0)); + new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)); } private async ValueTask CreateChunk(int numEvents, bool completed, bool scavenged, diff --git a/src/EventStore.Core.Tests/TransactionLog/when_chasing_a_chunked_transaction_log.cs b/src/EventStore.Core.Tests/TransactionLog/when_chasing_a_chunked_transaction_log.cs index c96e03889..807251888 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_chasing_a_chunked_transaction_log.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_chasing_a_chunked_transaction_log.cs @@ -98,7 +98,7 @@ public async Task open_starts_from_the_latest_chaser_checkpoint() transactionOffset: 0, eventStreamId: streamId, expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, @@ -138,7 +138,7 @@ public async Task try_read_returns_record_when_writerchecksum_ahead() transactionOffset: 0, eventStreamId: streamId, expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, @@ -195,7 +195,7 @@ public async Task try_read_returns_record_when_record_bigger_than_internal_buffe transactionOffset: 0, eventStreamId: streamId, expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: eventTypeId, data: new byte[9000], @@ -239,7 +239,7 @@ public async Task try_read_returns_record_when_writerchecksum_equal() transactionOffset: 0, eventStreamId: streamId, expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, @@ -274,7 +274,7 @@ public void try_read_returns_false_when_writer_checksum_is_ahead_but_not_enough_ transactionPosition: 0, eventStreamId: "WorldEnding", expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: "type", data: new byte[] { 1, 2, 3, 4, 5 }, @@ -309,7 +309,7 @@ public void try_read_returns_false_when_writer_checksum_is_ahead_but_not_enough_ transactionPosition: 0, eventStreamId: "WorldEnding", expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: "type", data: new byte[] { 1, 2, 3, 4, 5 }, @@ -352,7 +352,7 @@ public void try_read_returns_properly_when_writer_is_written_to_while_chasing() transactionPosition: 0, eventStreamId: "WorldEnding", expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: "type", data: new byte[] { 1, 2, 3, 4, 5 }, @@ -377,7 +377,7 @@ public void try_read_returns_properly_when_writer_is_written_to_while_chasing() transactionPosition: 0, eventStreamId: "WorldEnding", expectedVersion: 4321, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: "type", data: new byte[] { 3, 2, 1 }, diff --git a/src/EventStore.Core.Tests/TransactionLog/when_closing_the_database.cs b/src/EventStore.Core.Tests/TransactionLog/when_closing_the_database.cs index 9c2110dfd..274920577 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_closing_the_database.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_closing_the_database.cs @@ -41,7 +41,7 @@ private static IPrepareLogRecord CreateRecord() transactionOffset: 0, eventStreamId: streamId, expectedVersion: -1, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.SingleWrite, eventType: eventTypeId, data: new byte[123], diff --git a/src/EventStore.Core.Tests/TransactionLog/when_writing_a_new_chunked_transaction_file.cs b/src/EventStore.Core.Tests/TransactionLog/when_writing_a_new_chunked_transaction_file.cs index d9085265a..6541ddb9b 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_writing_a_new_chunked_transaction_file.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_writing_a_new_chunked_transaction_file.cs @@ -41,7 +41,7 @@ public async Task a_record_can_be_written() transactionOffset: 0, eventStreamId: streamId, expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, diff --git a/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_checksum.cs b/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_checksum.cs index bb6d2e25c..57d296fad 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_checksum.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_checksum.cs @@ -52,7 +52,7 @@ public async Task a_record_can_be_written() transactionPos: 0, transactionOffset: 0, eventStreamId: streamId, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, diff --git a/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_checksum_and_data_bigger_than_buffer.cs b/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_checksum_and_data_bigger_than_buffer.cs index f72aceb76..a71d359c8 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_checksum_and_data_bigger_than_buffer.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_checksum_and_data_bigger_than_buffer.cs @@ -58,7 +58,7 @@ public async Task a_record_can_be_written() transactionOffset: 543, eventStreamId: streamId, expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.SingleWrite, eventType: eventTypeId, data: bytes, diff --git a/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_not_enough_space_in_chunk.cs b/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_not_enough_space_in_chunk.cs index 85ba79a14..549c135c0 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_not_enough_space_in_chunk.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_writing_an_existing_chunked_transaction_file_with_not_enough_space_in_chunk.cs @@ -55,7 +55,7 @@ public async Task a_record_is_not_written_at_first_but_written_on_second_try() transactionPos: 0, transactionOffset: 0, eventStreamId: streamId, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, @@ -72,7 +72,7 @@ public async Task a_record_is_not_written_at_first_but_written_on_second_try() transactionPos: pos, transactionOffset: 0, eventStreamId: streamId, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, @@ -89,7 +89,7 @@ public async Task a_record_is_not_written_at_first_but_written_on_second_try() transactionPos: pos, transactionOffset: 0, eventStreamId: streamId, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.None, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, diff --git a/src/EventStore.Core.Tests/TransactionLog/when_writing_commit_record_to_file.cs b/src/EventStore.Core.Tests/TransactionLog/when_writing_commit_record_to_file.cs index d68e9556f..c287161db 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_writing_commit_record_to_file.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_writing_commit_record_to_file.cs @@ -33,7 +33,7 @@ public async Task SetUp() _record = new CommitLogRecord(logPosition: 0, correlationId: _eventId, transactionPosition: 4321, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), firstEventNumber: 10); await _writer.Write(_record, CancellationToken.None); await _writer.Flush(CancellationToken.None); @@ -62,7 +62,7 @@ public async Task the_data_is_written() Assert.AreEqual(c.LogPosition, 0); Assert.AreEqual(c.CorrelationId, _eventId); Assert.AreEqual(c.TransactionPosition, 4321); - Assert.AreEqual(c.TimeStamp, new DateTime(2012, 12, 21)); + Assert.AreEqual(c.TimeStamp, new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc)); } [Test] diff --git a/src/EventStore.Core.Tests/TransactionLog/when_writing_prepare_record_to_file.cs b/src/EventStore.Core.Tests/TransactionLog/when_writing_prepare_record_to_file.cs index 3959eb5d0..47db7f34e 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_writing_prepare_record_to_file.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_writing_prepare_record_to_file.cs @@ -45,7 +45,7 @@ public async Task SetUp() transactionOffset: 0xBEEF, eventStreamId: streamId, expectedVersion: 1234, - timeStamp: new DateTime(2012, 12, 21), + timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), flags: PrepareFlags.SingleWrite, eventType: eventTypeId, data: new byte[] { 1, 2, 3, 4, 5 }, @@ -86,7 +86,7 @@ public async Task the_data_is_written() Assert.AreEqual(p.EventId, _eventId); Assert.AreEqual(p.EventStreamId, streamId); Assert.AreEqual(p.ExpectedVersion, 1234); - Assert.That(p.TimeStamp, Is.EqualTo(new DateTime(2012, 12, 21)).Within(7).Milliseconds); + Assert.That(p.TimeStamp, Is.EqualTo(new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc)).Within(7).Milliseconds); Assert.AreEqual(p.Flags, PrepareFlags.SingleWrite); Assert.AreEqual(p.EventType, eventTypeId); Assert.AreEqual(p.Data.Length, 5); From ce6899eca632985034449f3a3b5a124c0ed07a85 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Sat, 4 Jul 2026 02:35:01 -0400 Subject: [PATCH 6/6] fix(storage): keep commit timestamp fixtures scoped Signed-off-by: Yordis Prieto --- .../Storage/Chaser/when_chaser_reads_commit_event.cs | 2 +- .../TransactionLog/when_appending_past_end_of_a_tfchunk.cs | 3 ++- .../when_appending_to_a_tfchunk_and_flushing.cs | 3 ++- .../when_appending_to_a_tfchunk_without_flush.cs | 3 ++- .../TransactionLog/when_reading_from_a_cached_tfchunk.cs | 3 ++- .../TransactionLog/when_uncaching_a_tfchunk.cs | 3 ++- .../TransactionLog/when_writing_commit_record_to_file.cs | 4 ++-- .../when_writing_multiple_records_to_a_tfchunk.cs | 6 ++++-- 8 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_commit_event.cs b/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_commit_event.cs index e59c7e604..1316067b1 100644 --- a/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_commit_event.cs +++ b/src/EventStore.Core.Tests/Services/Storage/Chaser/when_chaser_reads_commit_event.cs @@ -45,7 +45,7 @@ public override async ValueTask When(CancellationToken token) logPosition: _logPosition, correlationId: _transactionId, transactionPosition: 0, - timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), + timeStamp: new DateTime(2012, 12, 21), firstEventNumber: 10); (written, _) = await Writer.Write(record2, token); diff --git a/src/EventStore.Core.Tests/TransactionLog/when_appending_past_end_of_a_tfchunk.cs b/src/EventStore.Core.Tests/TransactionLog/when_appending_past_end_of_a_tfchunk.cs index eb1bdd809..4532b9d62 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_appending_past_end_of_a_tfchunk.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_appending_past_end_of_a_tfchunk.cs @@ -25,7 +25,8 @@ public override async Task SetUp() var eventTypeId = LogFormatHelper.EventTypeId; var record = LogRecord.Prepare(recordFactory, 15556, _corrId, _eventId, 15556, 0, streamId, 1, - PrepareFlags.None, eventTypeId, new byte[12], new byte[15], new DateTime(2000, 1, 1, 12, 0, 0)); + PrepareFlags.None, eventTypeId, new byte[12], new byte[15], + new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)); _chunk = await TFChunkHelper.CreateNewChunk(Filename, 20); _written = (await _chunk.TryAppend(record, CancellationToken.None)).Success; } diff --git a/src/EventStore.Core.Tests/TransactionLog/when_appending_to_a_tfchunk_and_flushing.cs b/src/EventStore.Core.Tests/TransactionLog/when_appending_to_a_tfchunk_and_flushing.cs index 04138d82f..69de3bbb5 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_appending_to_a_tfchunk_and_flushing.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_appending_to_a_tfchunk_and_flushing.cs @@ -26,7 +26,8 @@ public override async Task TestFixtureSetUp() var streamId = LogFormatHelper.StreamId; var eventTypeId = LogFormatHelper.EventTypeId; _record = LogRecord.Prepare(recordFactory, 0, _corrId, _eventId, 0, 0, streamId, 1, - PrepareFlags.None, eventTypeId, new byte[12], new byte[15], new DateTime(2000, 1, 1, 12, 0, 0)); + PrepareFlags.None, eventTypeId, new byte[12], new byte[15], + new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)); _chunk = await TFChunkHelper.CreateNewChunk(Filename); _result = await _chunk.TryAppend(_record, CancellationToken.None); await _chunk.Flush(CancellationToken.None); diff --git a/src/EventStore.Core.Tests/TransactionLog/when_appending_to_a_tfchunk_without_flush.cs b/src/EventStore.Core.Tests/TransactionLog/when_appending_to_a_tfchunk_without_flush.cs index d983bfa99..9f4f7a4a3 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_appending_to_a_tfchunk_without_flush.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_appending_to_a_tfchunk_without_flush.cs @@ -27,7 +27,8 @@ public override async Task TestFixtureSetUp() var eventTypeId = LogFormatHelper.EventTypeId; _record = LogRecord.Prepare(recordFactory, 0, _corrId, _eventId, 0, 0, streamId, 1, - PrepareFlags.None, eventTypeId, new byte[12], new byte[15], new DateTime(2000, 1, 1, 12, 0, 0)); + PrepareFlags.None, eventTypeId, new byte[12], new byte[15], + new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)); _chunk = await TFChunkHelper.CreateNewChunk(Filename); _result = await _chunk.TryAppend(_record, CancellationToken.None); } diff --git a/src/EventStore.Core.Tests/TransactionLog/when_reading_from_a_cached_tfchunk.cs b/src/EventStore.Core.Tests/TransactionLog/when_reading_from_a_cached_tfchunk.cs index caf7d1e7d..a41c5b188 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_reading_from_a_cached_tfchunk.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_reading_from_a_cached_tfchunk.cs @@ -31,7 +31,8 @@ public override async Task TestFixtureSetUp() var eventTypeId = LogFormatHelper.EventTypeId; _record = LogRecord.Prepare(recordFactory, 0, _corrId, _eventId, 0, 0, streamId, 1, - PrepareFlags.None, eventTypeId, new byte[12], new byte[15], new DateTime(2000, 1, 1, 12, 0, 0)); + PrepareFlags.None, eventTypeId, new byte[12], new byte[15], + new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)); _chunk = await TFChunkHelper.CreateNewChunk(Filename); _result = await _chunk.TryAppend(_record, CancellationToken.None); await _chunk.Flush(CancellationToken.None); diff --git a/src/EventStore.Core.Tests/TransactionLog/when_uncaching_a_tfchunk.cs b/src/EventStore.Core.Tests/TransactionLog/when_uncaching_a_tfchunk.cs index 90881f742..966642375 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_uncaching_a_tfchunk.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_uncaching_a_tfchunk.cs @@ -31,7 +31,8 @@ public override async Task TestFixtureSetUp() var eventTypeId = LogFormatHelper.EventTypeId; _record = LogRecord.Prepare(recordFactory, 0, _corrId, _eventId, 0, 0, streamId, 1, - PrepareFlags.None, eventTypeId, new byte[12], new byte[15], new DateTime(2000, 1, 1, 12, 0, 0)); + PrepareFlags.None, eventTypeId, new byte[12], new byte[15], + new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)); _chunk = await TFChunkHelper.CreateNewChunk(Filename); _result = await _chunk.TryAppend(_record, CancellationToken.None); await _chunk.Flush(CancellationToken.None); diff --git a/src/EventStore.Core.Tests/TransactionLog/when_writing_commit_record_to_file.cs b/src/EventStore.Core.Tests/TransactionLog/when_writing_commit_record_to_file.cs index c287161db..d68e9556f 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_writing_commit_record_to_file.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_writing_commit_record_to_file.cs @@ -33,7 +33,7 @@ public async Task SetUp() _record = new CommitLogRecord(logPosition: 0, correlationId: _eventId, transactionPosition: 4321, - timeStamp: new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc), + timeStamp: new DateTime(2012, 12, 21), firstEventNumber: 10); await _writer.Write(_record, CancellationToken.None); await _writer.Flush(CancellationToken.None); @@ -62,7 +62,7 @@ public async Task the_data_is_written() Assert.AreEqual(c.LogPosition, 0); Assert.AreEqual(c.CorrelationId, _eventId); Assert.AreEqual(c.TransactionPosition, 4321); - Assert.AreEqual(c.TimeStamp, new DateTime(2012, 12, 21, 0, 0, 0, DateTimeKind.Utc)); + Assert.AreEqual(c.TimeStamp, new DateTime(2012, 12, 21)); } [Test] diff --git a/src/EventStore.Core.Tests/TransactionLog/when_writing_multiple_records_to_a_tfchunk.cs b/src/EventStore.Core.Tests/TransactionLog/when_writing_multiple_records_to_a_tfchunk.cs index 10091d475..2ab86b831 100644 --- a/src/EventStore.Core.Tests/TransactionLog/when_writing_multiple_records_to_a_tfchunk.cs +++ b/src/EventStore.Core.Tests/TransactionLog/when_writing_multiple_records_to_a_tfchunk.cs @@ -34,13 +34,15 @@ public override async Task TestFixtureSetUp() var eventTypeId2 = LogFormatHelper.EventTypeId2; _prepare1 = LogRecord.Prepare(recordFactory, 0, _corrId, _eventId, 0, 0, streamId1, 1, - PrepareFlags.None, eventTypeId1, new byte[12], new byte[15], new DateTime(2000, 1, 1, 12, 0, 0)); + PrepareFlags.None, eventTypeId1, new byte[12], new byte[15], + new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)); var r1 = await _chunk.TryAppend(_prepare1, CancellationToken.None); _written1 = r1.Success; _position1 = r1.OldPosition; _prepare2 = LogRecord.Prepare(recordFactory, r1.NewPosition, _corrId, _eventId, 0, 0, streamId2, 2, - PrepareFlags.None, eventTypeId2, new byte[12], new byte[15], new DateTime(2000, 1, 1, 12, 0, 0)); + PrepareFlags.None, eventTypeId2, new byte[12], new byte[15], + new DateTime(2000, 1, 1, 12, 0, 0, DateTimeKind.Utc)); var r2 = await _chunk.TryAppend(_prepare2, CancellationToken.None); _written2 = r2.Success; _position2 = r2.OldPosition;