lnwire: extend RawFeatureVector with helper methods

This commit is contained in:
Wilmer Paulino
2021-07-12 17:41:50 -07:00
committed by Olaoluwa Osuntokun
parent 5a9f499dd5
commit 031d7b1d55
3 changed files with 86 additions and 7 deletions

View File

@@ -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())
}