[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.
This commit is contained in:
Dave Collins 2018-09-12 17:33:10 -05:00
parent 5bb4840673
commit 0fe564967f
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2

View File

@ -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"