lnwire: replace all wire msg tests with a single property-based test
This commit does away with all the old manual message equality tests and replace it with a single property-based test that uses the testing/quick package. This test uses a single scenario which MUST hold for all the messages type and all possible messages generated for those types. As a result we are able to do away with all the prior manually generated test data as the fuzzer to scan the input space looking for a message that violates the scenario.
This commit is contained in:
23 files changed
+583
-853
No files matched your search
@@ -72,6 +72,11 @@ func TestOptionalFeature(t *testing.T) {
|
||||
t.Fatal("locally feature was set but remote peer notified us" +
|
||||
" that it don't have it")
|
||||
}
|
||||
|
||||
// A feature with a non-existent name shouldn't be active.
|
||||
if shared.IsActive("nothere") {
|
||||
t.Fatal("non-existent feature shouldn't be active")
|
||||
}
|
||||
}
|
||||
|
||||
// TestSetRequireAfterInit checks that we can change the feature flag after
|
||||
@@ -117,3 +122,21 @@ func TestDecodeEncodeFeaturesVector(t *testing.T) {
|
||||
"%v", spew.Sdump(f), spew.Sdump(nf))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFeatureFlagString(t *testing.T) {
|
||||
if OptionalFlag.String() != "optional" {
|
||||
t.Fatalf("incorrect string, expected optional got %v",
|
||||
OptionalFlag.String())
|
||||
}
|
||||
|
||||
if RequiredFlag.String() != "required" {
|
||||
t.Fatalf("incorrect string, expected required got %v",
|
||||
OptionalFlag.String())
|
||||
}
|
||||
|
||||
fakeFlag := featureFlag(9)
|
||||
if fakeFlag.String() != "<unknown>" {
|
||||
t.Fatalf("incorrect string, expected <unknown> got %v",
|
||||
fakeFlag.String())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user