Skip to content

Commit

Permalink
[release-v1.3] blockchain: Avoid deployment expiration in tests.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
davecgh committed Sep 12, 2018
1 parent 5bb4840 commit 0fe5649
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions blockchain/agendas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package blockchain

import (
"math"
"testing"
"time"

Expand All @@ -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"
Expand Down

0 comments on commit 0fe5649

Please sign in to comment.