From 8e440cd448670b6fd468d8dabe262745730858a1 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Mon, 8 Jul 2024 14:14:51 +0000 Subject: [PATCH] fix tests --- mixing/mixpool/mixpool.go | 2 +- mixing/mixpool/mixpool_test.go | 3 ++- mixing/mixpool/orphans_test.go | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mixing/mixpool/mixpool.go b/mixing/mixpool/mixpool.go index 55c8599d5..ace14154a 100644 --- a/mixing/mixpool/mixpool.go +++ b/mixing/mixpool/mixpool.go @@ -1396,7 +1396,7 @@ func (p *Pool) checkAcceptKE(ke *wire.MsgMixKeyExchange) error { } keEpoch := time.Unix(int64(ke.Epoch), 0) - if time.Now().Add(-earlyKEDuration).Before(keEpoch) { + if keEpoch.Add(earlyKEDuration).Before(time.Now()) { err := fmt.Errorf("KE received too early for stated epoch") return ruleError(err) } diff --git a/mixing/mixpool/mixpool_test.go b/mixing/mixpool/mixpool_test.go index 1baa29ac1..bdfb5a814 100644 --- a/mixing/mixpool/mixpool_test.go +++ b/mixing/mixpool/mixpool_test.go @@ -14,6 +14,7 @@ import ( "math/big" "os" "testing" + "time" "decred.org/cspp/v2/solverrpc" "github.com/davecgh/go-spew/spew" @@ -255,7 +256,7 @@ func TestAccept(t *testing.T) { var ( seenPRs = []chainhash.Hash{pr.Hash()} - epoch uint64 = 0 + epoch uint64 = uint64(time.Now().Unix()) sid [32]byte = mixing.SortPRsForSession([]*wire.MsgMixPairReq{pr}, epoch) run uint32 = 0 pos uint32 = 0 diff --git a/mixing/mixpool/orphans_test.go b/mixing/mixpool/orphans_test.go index fb6bc0151..48ffd7917 100644 --- a/mixing/mixpool/orphans_test.go +++ b/mixing/mixpool/orphans_test.go @@ -8,6 +8,7 @@ import ( "errors" "reflect" "testing" + "time" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" @@ -65,7 +66,7 @@ func TestOrphans(t *testing.T) { pr.WriteHash(h) prs := []*wire.MsgMixPairReq{pr} - epoch := uint64(1704067200) + epoch := uint64(time.Now().Unix()) sid := mixing.SortPRsForSession(prs, epoch) ke := &wire.MsgMixKeyExchange{ Identity: id,