diff --git a/lnwallet/script_utils_test.go b/lnwallet/script_utils_test.go index f4890cdc..fabdcfc0 100644 --- a/lnwallet/script_utils_test.go +++ b/lnwallet/script_utils_test.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "testing" + "time" "github.com/btcsuite/fastsha256" "github.com/roasbeef/btcd/btcec" @@ -602,6 +603,7 @@ func TestCommitTxStateHint(t *testing.T) { var obsfucator [StateHintSize]byte copy(obsfucator[:], testHdSeed[:StateHintSize]) + timeYesterday := uint32(time.Now().Unix() - 24*60*60) for _, test := range stateHintTests { commitTx := wire.NewMsgTx(2) @@ -621,6 +623,25 @@ func TestCommitTxStateHint(t *testing.T) { t.Fatalf("Failed(%v): test should fail but did not", test.name) } + locktime := commitTx.LockTime + sequence := commitTx.TxIn[0].Sequence + + // Locktime should not be less than 500,000,000 and not larger + // than the time 24 hours ago. One day should provide a good + // enough buffer for the tests. + if locktime < 5e8 || locktime > timeYesterday { + if !test.shouldFail { + t.Fatalf("The value of locktime (%v) may cause the commitment "+ + "transaction to be unspendable", locktime) + } + } + + if sequence&wire.SequenceLockTimeDisabled == 0 { + if !test.shouldFail { + t.Fatalf("Sequence locktime is NOT disabled when it should be") + } + } + extractedStateNum := GetStateNumHint(commitTx, obsfucator) if extractedStateNum != stateNum && !test.shouldFail { t.Fatalf("state number mismatched, expected %v, got %v",