From 4a8fc58e67598c2c2b45dea2dafd4e5aebcdb3a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20=C5=BDivkovi=C4=87?= Date: Mon, 9 Dec 2024 15:06:04 +0100 Subject: [PATCH] Save seconds instead of ms for block timestamps --- backup/backup_test.go | 10 +++++----- backup/client/http/http.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backup/backup_test.go b/backup/backup_test.go index 8935be4..9d45741 100644 --- a/backup/backup_test.go +++ b/backup/backup_test.go @@ -112,7 +112,7 @@ func TestBackup_ExecuteBackup_FixedRange(t *testing.T) { return &client.Block{ Height: blockNum, - Timestamp: blockTime.Add(time.Duration(blockNum) * time.Minute).UnixMilli(), + Timestamp: blockTime.Add(time.Duration(blockNum) * time.Minute).Unix(), Txs: []std.Tx{exampleTx}, }, nil // 1 tx per block }, @@ -161,8 +161,8 @@ func TestBackup_ExecuteBackup_FixedRange(t *testing.T) { assert.Equal(t, exampleTx, txData.Tx) assert.Equal( t, - blockTime.Add(time.Duration(expectedBlock)*time.Minute).Local(), - time.UnixMilli(txData.Metadata.Timestamp), + blockTime.Add(time.Duration(expectedBlock)*time.Minute).Unix(), + txData.Metadata.Timestamp, ) expectedBlock++ @@ -214,7 +214,7 @@ func TestBackup_ExecuteBackup_Watch(t *testing.T) { return &client.Block{ Height: blockNum, - Timestamp: blockTime.Add(time.Duration(blockNum) * time.Minute).UnixMilli(), + Timestamp: blockTime.Add(time.Duration(blockNum) * time.Minute).Unix(), Txs: []std.Tx{exampleTx}, }, nil // 1 tx per block }, @@ -266,7 +266,7 @@ func TestBackup_ExecuteBackup_Watch(t *testing.T) { assert.Equal( t, blockTime.Add(time.Duration(expectedBlock)*time.Minute).Local(), - time.UnixMilli(txData.Metadata.Timestamp), + time.Unix(txData.Metadata.Timestamp, 0), ) expectedBlock++ diff --git a/backup/client/http/http.go b/backup/client/http/http.go index 636d132..57b2ce8 100644 --- a/backup/client/http/http.go +++ b/backup/client/http/http.go @@ -72,7 +72,7 @@ func (c *Client) GetBlock(blockNum uint64) (*client.Block, error) { } return &client.Block{ - Timestamp: block.Block.Time.UnixMilli(), + Timestamp: block.Block.Time.Unix(), Height: blockNum, Txs: txs, }, nil