mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-05 17:05:50 +02:00
lnwire: Add upfront shutdown messages and feature bit
This commit adds the feature bit and additional fields required in `open_channel` and `accept_channel` wire messages for `option_upfront_shutdown_script`.
This commit is contained in:
@@ -67,6 +67,15 @@ func randRawKey() ([33]byte, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func randDeliveryAddress(r *rand.Rand) (DeliveryAddress, error) {
|
||||
// Generate size minimum one. Empty scripts should be tested specifically.
|
||||
size := r.Intn(deliveryAddressMaxSize) + 1
|
||||
da := DeliveryAddress(make([]byte, size))
|
||||
|
||||
_, err := r.Read(da)
|
||||
return da, err
|
||||
}
|
||||
|
||||
func randRawFeatureVector(r *rand.Rand) *RawFeatureVector {
|
||||
featureVec := NewRawFeatureVector()
|
||||
for i := 0; i < 10000; i++ {
|
||||
@@ -241,6 +250,9 @@ func TestEmptyMessageUnknownType(t *testing.T) {
|
||||
// TestLightningWireProtocol uses the testing/quick package to create a series
|
||||
// of fuzz tests to attempt to break a primary scenario which is implemented as
|
||||
// property based testing scenario.
|
||||
//
|
||||
// Debug help: when the message payload can reach a size larger than the return
|
||||
// value of MaxPayloadLength, the test can panic without a helpful message.
|
||||
func TestLightningWireProtocol(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -353,6 +365,17 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
// 1/2 chance empty upfront shutdown script.
|
||||
if r.Intn(2) == 0 {
|
||||
req.UpfrontShutdownScript, err = randDeliveryAddress(r)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate delivery address: %v", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
req.UpfrontShutdownScript = []byte{}
|
||||
}
|
||||
|
||||
v[0] = reflect.ValueOf(req)
|
||||
},
|
||||
MsgAcceptChannel: func(v []reflect.Value, r *rand.Rand) {
|
||||
@@ -403,6 +426,17 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
// 1/2 chance empty upfront shutdown script.
|
||||
if r.Intn(2) == 0 {
|
||||
req.UpfrontShutdownScript, err = randDeliveryAddress(r)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate delivery address: %v", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
req.UpfrontShutdownScript = []byte{}
|
||||
}
|
||||
|
||||
v[0] = reflect.ValueOf(req)
|
||||
},
|
||||
MsgFundingCreated: func(v []reflect.Value, r *rand.Rand) {
|
||||
|
Reference in New Issue
Block a user