mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 07:35:07 +02:00
lnwire: extend RawFeatureVector with helper methods
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
5a9f499dd5
commit
031d7b1d55
@@ -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