From 8c2125dbaf865f71c60f0830a4648f6a78df1078 Mon Sep 17 00:00:00 2001 From: Christopher Tarry Date: Wed, 18 Sep 2024 23:35:48 -0400 Subject: [PATCH] fix timestamps for reflect.DeepEqual --- api/api_test.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/api/api_test.go b/api/api_test.go index 37dba100..d6fd1b8f 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -439,7 +439,13 @@ func TestAPI(t *testing.T) { if err != nil { t.Fatal(err) } - check(t, "network", cm.TipState().Network, resp) + + // fix because reflect.DeepEqual can't compare timestamps + n := cm.TipState().Network + n.HardforkOak.GenesisTimestamp = n.HardforkOak.GenesisTimestamp.UTC() + resp.HardforkOak.GenesisTimestamp = resp.HardforkOak.GenesisTimestamp.UTC() + + check(t, "network", n, resp) } { @@ -449,6 +455,15 @@ func TestAPI(t *testing.T) { } cs := cm.TipState() check(t, "index", cs.Index, resp.Index) + + // fix timestamps again + for i := range cs.PrevTimestamps { + cs.PrevTimestamps[i] = cs.PrevTimestamps[i].UTC() + } + for i := range resp.PrevTimestamps { + resp.PrevTimestamps[i] = resp.PrevTimestamps[i].UTC() + } + check(t, "previous timestamps", cs.PrevTimestamps, resp.PrevTimestamps) check(t, "depth", cs.Depth, resp.Depth) check(t, "child target", cs.ChildTarget, resp.ChildTarget) @@ -518,8 +533,8 @@ func TestAPI(t *testing.T) { } check(t, "height", tip.Height, resp.Height) check(t, "parent ID", parentIndex.ID, resp.ParentID) - check(t, "parent ID", b2.Nonce, resp.Nonce) - check(t, "parent ID", b2.Timestamp, resp.Timestamp) + check(t, "nonce", b2.Nonce, resp.Nonce) + check(t, "timestamp", b2.Timestamp.UTC(), resp.Timestamp.UTC()) check(t, "miner payout address", b2.MinerPayouts[0].Address, resp.MinerPayouts[0].SiacoinOutput.Address) check(t, "miner payout value", b2.MinerPayouts[0].Value, resp.MinerPayouts[0].SiacoinOutput.Value) check(t, "miner payout source", explorer.SourceMinerPayout, resp.MinerPayouts[0].Source)