lnwire: extend RawFeatureVector with helper methods
This commit is contained in:
1 parent
5a9f499dd5
commit
031d7b1d55
3 files changed
+86
-7
No files matched your search
@@ -353,3 +353,47 @@ func TestFeatures(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRawFeatureVectorOnlyContains(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
features := []FeatureBit{
|
||||
StaticRemoteKeyOptional,
|
||||
AnchorsZeroFeeHtlcTxOptional,
|
||||
ExplicitChannelTypeRequired,
|
||||
}
|
||||
fv := NewRawFeatureVector(features...)
|
||||
require.True(t, fv.OnlyContains(features...))
|
||||
require.False(t, fv.OnlyContains(features[:1]...))
|
||||
}
|
||||
|
||||
func TestEqualRawFeatureVectors(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
a := NewRawFeatureVector(
|
||||
StaticRemoteKeyOptional,
|
||||
AnchorsZeroFeeHtlcTxOptional,
|
||||
ExplicitChannelTypeRequired,
|
||||
)
|
||||
b := a.Clone()
|
||||
require.True(t, a.Equals(b))
|
||||
|
||||
b.Unset(ExplicitChannelTypeRequired)
|
||||
require.False(t, a.Equals(b))
|
||||
|
||||
b.Set(ExplicitChannelTypeOptional)
|
||||
require.False(t, a.Equals(b))
|
||||
}
|
||||
|
||||
func TestIsEmptyFeatureVector(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
fv := NewRawFeatureVector()
|
||||
require.True(t, fv.IsEmpty())
|
||||
|
||||
fv.Set(StaticRemoteKeyOptional)
|
||||
require.False(t, fv.IsEmpty())
|
||||
|
||||
fv.Unset(StaticRemoteKeyOptional)
|
||||
require.True(t, fv.IsEmpty())
|
||||
}
|
||||
Reference in new issue
Block a user