@@ -39,7 +39,7 @@ class FeaturesSpec extends AnyFunSuite {
39
39
}
40
40
41
41
test(" 'initial_routing_sync', 'data_loss_protect' and 'variable_length_onion' features" ) {
42
- val features = Features (Set ( ActivatedFeature ( InitialRoutingSync , Optional ), ActivatedFeature ( OptionDataLossProtect , Optional ), ActivatedFeature ( VariableLengthOnion , Mandatory )) )
42
+ val features = Features (InitialRoutingSync -> Optional , OptionDataLossProtect -> Optional , VariableLengthOnion -> Mandatory )
43
43
assert(features.toByteVector == hex " 010a " )
44
44
assert(features.hasFeature(OptionDataLossProtect ))
45
45
assert(features.hasFeature(InitialRoutingSync , None ))
@@ -114,87 +114,87 @@ class FeaturesSpec extends AnyFunSuite {
114
114
),
115
115
TestCase (
116
116
Features .empty,
117
- Features (Set ( ActivatedFeature ( InitialRoutingSync , Optional ), ActivatedFeature ( VariableLengthOnion , Optional )) ),
117
+ Features (InitialRoutingSync -> Optional , VariableLengthOnion -> Optional ),
118
118
oursSupportTheirs = true ,
119
119
theirsSupportOurs = true ,
120
120
compatible = true
121
121
),
122
122
TestCase (
123
123
Features .empty,
124
- Features (Set .empty, Set (UnknownFeature (101 ), UnknownFeature (103 ))),
124
+ Features (activated = Map .empty, Set (UnknownFeature (101 ), UnknownFeature (103 ))),
125
125
oursSupportTheirs = true ,
126
126
theirsSupportOurs = true ,
127
127
compatible = true
128
128
),
129
129
// Same feature set
130
130
TestCase (
131
- Features (Set ( ActivatedFeature ( InitialRoutingSync , Optional ), ActivatedFeature ( VariableLengthOnion , Mandatory )) ),
132
- Features (Set ( ActivatedFeature ( InitialRoutingSync , Optional ), ActivatedFeature ( VariableLengthOnion , Mandatory )) ),
131
+ Features (InitialRoutingSync -> Optional , VariableLengthOnion -> Mandatory ),
132
+ Features (InitialRoutingSync -> Optional , VariableLengthOnion -> Mandatory ),
133
133
oursSupportTheirs = true ,
134
134
theirsSupportOurs = true ,
135
135
compatible = true
136
136
),
137
137
// Many optional features
138
138
TestCase (
139
- Features (Set ( ActivatedFeature ( InitialRoutingSync , Optional ), ActivatedFeature ( VariableLengthOnion , Optional ), ActivatedFeature ( ChannelRangeQueries , Optional ), ActivatedFeature ( PaymentSecret , Optional )) ),
140
- Features (Set ( ActivatedFeature ( VariableLengthOnion , Optional ), ActivatedFeature ( ChannelRangeQueries , Optional ), ActivatedFeature ( ChannelRangeQueriesExtended , Optional )) ),
139
+ Features (InitialRoutingSync -> Optional , VariableLengthOnion -> Optional , ChannelRangeQueries -> Optional , PaymentSecret -> Optional ),
140
+ Features (VariableLengthOnion -> Optional , ChannelRangeQueries -> Optional , ChannelRangeQueriesExtended -> Optional ),
141
141
oursSupportTheirs = true ,
142
142
theirsSupportOurs = true ,
143
143
compatible = true
144
144
),
145
145
// We support their mandatory features
146
146
TestCase (
147
- Features (Set ( ActivatedFeature ( VariableLengthOnion , Optional )) ),
148
- Features (Set ( ActivatedFeature ( InitialRoutingSync , Optional ), ActivatedFeature ( VariableLengthOnion , Mandatory )) ),
147
+ Features (VariableLengthOnion -> Optional ),
148
+ Features (InitialRoutingSync -> Optional , VariableLengthOnion -> Mandatory ),
149
149
oursSupportTheirs = true ,
150
150
theirsSupportOurs = true ,
151
151
compatible = true
152
152
),
153
153
// They support our mandatory features
154
154
TestCase (
155
- Features (Set ( ActivatedFeature ( VariableLengthOnion , Mandatory )) ),
156
- Features (Set ( ActivatedFeature ( InitialRoutingSync , Optional ), ActivatedFeature ( VariableLengthOnion , Optional )) ),
155
+ Features (VariableLengthOnion -> Mandatory ),
156
+ Features (InitialRoutingSync -> Optional , VariableLengthOnion -> Optional ),
157
157
oursSupportTheirs = true ,
158
158
theirsSupportOurs = true ,
159
159
compatible = true
160
160
),
161
161
// They have unknown optional features
162
162
TestCase (
163
- Features (Set ( ActivatedFeature ( VariableLengthOnion , Optional )) ),
164
- Features (Set ( ActivatedFeature ( VariableLengthOnion , Optional ) ), Set (UnknownFeature (141 ))),
163
+ Features (VariableLengthOnion -> Optional ),
164
+ Features (Map [ Feature , FeatureSupport ]( VariableLengthOnion -> Optional ), Set (UnknownFeature (141 ))),
165
165
oursSupportTheirs = true ,
166
166
theirsSupportOurs = true ,
167
167
compatible = true
168
168
),
169
169
// They have unknown mandatory features
170
170
TestCase (
171
- Features (Set ( ActivatedFeature ( VariableLengthOnion , Optional )) ),
172
- Features (Set ( ActivatedFeature ( VariableLengthOnion , Optional ) ), Set (UnknownFeature (142 ))),
171
+ Features (VariableLengthOnion -> Optional ),
172
+ Features (Map [ Feature , FeatureSupport ]( VariableLengthOnion -> Optional ), Set (UnknownFeature (142 ))),
173
173
oursSupportTheirs = false ,
174
174
theirsSupportOurs = true ,
175
175
compatible = false
176
176
),
177
177
// We don't support one of their mandatory features
178
178
TestCase (
179
- Features (Set ( ActivatedFeature ( ChannelRangeQueries , Optional )) ),
180
- Features (Set ( ActivatedFeature ( ChannelRangeQueries , Mandatory ), ActivatedFeature ( VariableLengthOnion , Mandatory )) ),
179
+ Features (ChannelRangeQueries -> Optional ),
180
+ Features (ChannelRangeQueries -> Mandatory , VariableLengthOnion -> Mandatory ),
181
181
oursSupportTheirs = false ,
182
182
theirsSupportOurs = true ,
183
183
compatible = false
184
184
),
185
185
// They don't support one of our mandatory features
186
186
TestCase (
187
- Features (Set ( ActivatedFeature ( VariableLengthOnion , Mandatory ), ActivatedFeature ( PaymentSecret , Mandatory )) ),
188
- Features (Set ( ActivatedFeature ( VariableLengthOnion , Optional )) ),
187
+ Features (VariableLengthOnion -> Mandatory , PaymentSecret -> Mandatory ),
188
+ Features (VariableLengthOnion -> Optional ),
189
189
oursSupportTheirs = true ,
190
190
theirsSupportOurs = false ,
191
191
compatible = false
192
192
),
193
193
// nonreg testing of future features (needs to be updated with every new supported mandatory bit)
194
- TestCase (Features .empty, Features (Set .empty, Set (UnknownFeature (22 ))), oursSupportTheirs = false , theirsSupportOurs = true , compatible = false ),
195
- TestCase (Features .empty, Features (Set .empty, Set (UnknownFeature (23 ))), oursSupportTheirs = true , theirsSupportOurs = true , compatible = true ),
196
- TestCase (Features .empty, Features (Set .empty, Set (UnknownFeature (24 ))), oursSupportTheirs = false , theirsSupportOurs = true , compatible = false ),
197
- TestCase (Features .empty, Features (Set .empty, Set (UnknownFeature (25 ))), oursSupportTheirs = true , theirsSupportOurs = true , compatible = true )
194
+ TestCase (Features .empty, Features (Map .empty[ Feature , FeatureSupport ] , Set (UnknownFeature (22 ))), oursSupportTheirs = false , theirsSupportOurs = true , compatible = false ),
195
+ TestCase (Features .empty, Features (Map .empty[ Feature , FeatureSupport ] , Set (UnknownFeature (23 ))), oursSupportTheirs = true , theirsSupportOurs = true , compatible = true ),
196
+ TestCase (Features .empty, Features (Map .empty[ Feature , FeatureSupport ] , Set (UnknownFeature (24 ))), oursSupportTheirs = false , theirsSupportOurs = true , compatible = false ),
197
+ TestCase (Features .empty, Features (Map .empty[ Feature , FeatureSupport ] , Set (UnknownFeature (25 ))), oursSupportTheirs = true , theirsSupportOurs = true , compatible = true )
198
198
)
199
199
200
200
for (testCase <- testCases) {
@@ -207,10 +207,10 @@ class FeaturesSpec extends AnyFunSuite {
207
207
test(" features to bytes" ) {
208
208
val testCases = Map (
209
209
hex " " -> Features .empty,
210
- hex " 0100 " -> Features (Set ( ActivatedFeature ( VariableLengthOnion , Mandatory )) ),
211
- hex " 028a8a " -> Features (Set ( ActivatedFeature ( OptionDataLossProtect , Optional ), ActivatedFeature ( InitialRoutingSync , Optional ), ActivatedFeature ( ChannelRangeQueries , Optional ), ActivatedFeature ( VariableLengthOnion , Optional ), ActivatedFeature ( ChannelRangeQueriesExtended , Optional ), ActivatedFeature ( PaymentSecret , Optional ), ActivatedFeature ( BasicMultiPartPayment , Optional )) ),
212
- hex " 09004200 " -> Features (Set ( ActivatedFeature ( VariableLengthOnion , Optional ), ActivatedFeature ( PaymentSecret , Mandatory ) ), Set (UnknownFeature (24 ), UnknownFeature (27 ))),
213
- hex " 52000000 " -> Features (Set .empty, Set (UnknownFeature (25 ), UnknownFeature (28 ), UnknownFeature (30 )))
210
+ hex " 0100 " -> Features (VariableLengthOnion -> Mandatory ),
211
+ hex " 028a8a " -> Features (OptionDataLossProtect -> Optional , InitialRoutingSync -> Optional , ChannelRangeQueries -> Optional , VariableLengthOnion -> Optional , ChannelRangeQueriesExtended -> Optional , PaymentSecret -> Optional , BasicMultiPartPayment -> Optional ),
212
+ hex " 09004200 " -> Features (Map [ Feature , FeatureSupport ]( VariableLengthOnion -> Optional , PaymentSecret -> Mandatory ), Set (UnknownFeature (24 ), UnknownFeature (27 ))),
213
+ hex " 52000000 " -> Features (Map .empty[ Feature , FeatureSupport ] , Set (UnknownFeature (25 ), UnknownFeature (28 ), UnknownFeature (30 )))
214
214
)
215
215
216
216
for ((bin, features) <- testCases) {
0 commit comments