mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-29 03:01:52 +01:00
lnwire: modify TestLightningWireProtocol to use sub-tests
This way, it's possible to run induvidual tests to target failures.
This commit is contained in:
parent
78f31da2fb
commit
681f44fd16
@ -887,7 +887,7 @@ func TestLightningWireProtocol(t *testing.T) {
|
|||||||
v[0] = reflect.ValueOf(ks)
|
v[0] = reflect.ValueOf(ks)
|
||||||
},
|
},
|
||||||
MsgCommitSig: func(v []reflect.Value, r *rand.Rand) {
|
MsgCommitSig: func(v []reflect.Value, r *rand.Rand) {
|
||||||
req := NewCommitSig()
|
req := &CommitSig{}
|
||||||
if _, err := r.Read(req.ChanID[:]); err != nil {
|
if _, err := r.Read(req.ChanID[:]); err != nil {
|
||||||
t.Fatalf("unable to generate chan id: %v", err)
|
t.Fatalf("unable to generate chan id: %v", err)
|
||||||
return
|
return
|
||||||
@ -1653,22 +1653,28 @@ func TestLightningWireProtocol(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
var config *quick.Config
|
t.Run(test.msgType.String(), func(t *testing.T) {
|
||||||
|
var config *quick.Config
|
||||||
|
|
||||||
// If the type defined is within the custom type gen map above,
|
// If the type defined is within the custom type gen
|
||||||
// then we'll modify the default config to use this Value
|
// map above, then we'll modify the default config to
|
||||||
// function that knows how to generate the proper types.
|
// use this Value function that knows how to generate
|
||||||
if valueGen, ok := customTypeGen[test.msgType]; ok {
|
// the proper types.
|
||||||
config = &quick.Config{
|
if valueGen, ok := customTypeGen[test.msgType]; ok {
|
||||||
Values: valueGen,
|
config = &quick.Config{
|
||||||
|
Values: valueGen,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Running fuzz tests for msgType=%v", test.msgType)
|
t.Logf("Running fuzz tests for msgType=%v",
|
||||||
if err := quick.Check(test.scenario, config); err != nil {
|
test.msgType)
|
||||||
t.Fatalf("fuzz checks for msg=%v failed: %v",
|
|
||||||
test.msgType, err)
|
err := quick.Check(test.scenario, config)
|
||||||
}
|
if err != nil {
|
||||||
|
t.Fatalf("fuzz checks for msg=%v failed: %v",
|
||||||
|
test.msgType, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user