Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tapdb: fix time zone issue with timestamps #532

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tapdb/assets_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ func (a *AssetStore) LeaseCoins(ctx context.Context, leaseOwner [32]byte,
err = q.UpdateUTXOLease(ctx, UpdateUTXOLease{
LeaseOwner: leaseOwner[:],
LeaseExpiry: sql.NullTime{
Time: expiry,
Time: expiry.UTC(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for doing this at the lowest level.

Valid: true,
},
Outpoint: outpoint,
Expand Down Expand Up @@ -1991,7 +1991,7 @@ func insertAssetTransferInput(ctx context.Context, q ActiveAssetsStore,
return q.UpdateUTXOLease(ctx, UpdateUTXOLease{
LeaseOwner: finalLeaseOwner[:],
LeaseExpiry: sql.NullTime{
Time: finalLeaseExpiry,
Time: finalLeaseExpiry.UTC(),
Valid: true,
},
Outpoint: anchorPointBytes,
Expand Down
6 changes: 3 additions & 3 deletions tapdb/assets_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ func TestUTXOLeases(t *testing.T) {
// Now we lease the first asset for 1 hour. This will cause the second
// one also to be leased, since it's on the same anchor transaction.
leaseOwner := fn.ToArray[[32]byte](test.RandBytes(32))
leaseExpiry := time.Now().Add(time.Hour).UTC()
leaseExpiry := time.Now().Add(time.Hour)
err = assetsStore.LeaseCoins(
ctx, leaseOwner, leaseExpiry, assetGen.anchorPoints[0],
)
Expand All @@ -825,7 +825,7 @@ func TestUTXOLeases(t *testing.T) {
require.Len(t, selectedAssets, 1)

// Let's now update the lease.
leaseExpiry = time.Now().Add(2 * time.Hour).UTC()
leaseExpiry = time.Now().Add(2 * time.Hour)
err = assetsStore.LeaseCoins(
ctx, leaseOwner, leaseExpiry, assetGen.anchorPoints[0],
)
Expand Down Expand Up @@ -853,7 +853,7 @@ func TestUTXOLeases(t *testing.T) {

// Update the lease again, but into the past, so that it should be
// removed upon cleanup.
leaseExpiry = time.Now().Add(-time.Hour).UTC()
leaseExpiry = time.Now().Add(-time.Hour)
err = assetsStore.LeaseCoins(
ctx, leaseOwner, leaseExpiry, assetGen.anchorPoints[0],
)
Expand Down