From 0fe564967f03160b9dbe0a147420d8aa13371d12 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 12 Sep 2018 17:33:10 -0500 Subject: [PATCH] [release-v1.3] blockchain: Avoid deployment expiration in tests. This modifies the test code which deals with testing feature deployments to clone the parameters and modify them such that the deployment being tested never expires. --- blockchain/agendas_test.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/blockchain/agendas_test.go b/blockchain/agendas_test.go index b65a5ab8..316c8861 100644 --- a/blockchain/agendas_test.go +++ b/blockchain/agendas_test.go @@ -5,6 +5,7 @@ package blockchain import ( + "math" "testing" "time" @@ -22,18 +23,24 @@ func testLNFeaturesDeployment(t *testing.T, params *chaincfg.Params, deploymentV const baseConsensusScriptVerifyFlags = txscript.ScriptVerifyCleanStack | txscript.ScriptVerifyCheckLockTimeVerify - // Find the correct deployment for the LN features agenda. - var deployment chaincfg.ConsensusDeployment + // Find the correct deployment for the LN features agenda and ensure it + // never expires to prevent test failures when the real expiration time + // passes. Also, clone the provided parameters first to avoid mutating + // them. + params = cloneParams(params) + var deployment *chaincfg.ConsensusDeployment deployments := params.Deployments[deploymentVer] - for _, depl := range deployments { + for deploymentID, depl := range deployments { if depl.Vote.Id == chaincfg.VoteIDLNFeatures { - deployment = depl + deployment = &deployments[deploymentID] + break } } - if deployment.Vote.Id != chaincfg.VoteIDLNFeatures { + if deployment == nil { t.Fatalf("Unable to find consensus deployement for %s", chaincfg.VoteIDLNFeatures) } + deployment.ExpireTime = math.MaxUint64 // Never expires. // Find the correct choice for the yes vote. const yesVoteID = "yes"