@@ -60,6 +60,29 @@ void bannedIpV4Node() {
60
60
assertIterableEquals (expected , selectedNodes );
61
61
}
62
62
63
+ @ Test
64
+ void bannedIpV4NodeWrongPort () {
65
+ String bannedAddress = "123.456.890.123" ;
66
+
67
+ var hardcodedNodes = List .of (
68
+ new BtcNodes .BtcNode (null , "alice.onion" , null ,
69
+ BtcNodes .BtcNode .DEFAULT_PORT , "@alice" ),
70
+ new BtcNodes .BtcNode (null , null , bannedAddress , 4567 , "@bob" ),
71
+ new BtcNodes .BtcNode (null , "charlie.onion" , null ,
72
+ BtcNodes .BtcNode .DEFAULT_PORT , "@charlie" )
73
+ );
74
+
75
+ List <BtcNodes .BtcNode > mutableHardcodedList = new ArrayList <>(hardcodedNodes );
76
+ List <String > filterProvidedBtcNodes = Collections .emptyList ();
77
+ String bannedFullAddress = bannedAddress + ":" + 1234 ;
78
+ List <String > bannedBtcNodes = List .of (bannedFullAddress );
79
+
80
+ List <BtcNodes .BtcNode > selectedNodes = FederatedBtcNodeProvider
81
+ .getNodes (mutableHardcodedList , filterProvidedBtcNodes , bannedBtcNodes );
82
+
83
+ assertIterableEquals (hardcodedNodes , selectedNodes );
84
+ }
85
+
63
86
@ Test
64
87
void bannedIpV6Node () {
65
88
String bannedAddress = "2001:db8:85a3:8d3:1319:8a2e:370" ;
@@ -90,20 +113,45 @@ void bannedIpV6Node() {
90
113
assertIterableEquals (expected , selectedNodes );
91
114
}
92
115
116
+ @ Test
117
+ void bannedIpV6NodeWrongPort () {
118
+ String bannedAddress = "2001:db8:85a3:8d3:1319:8a2e:370" ;
119
+
120
+ var hardcodedNodes = List .of (
121
+ new BtcNodes .BtcNode (null , "alice.onion" , null ,
122
+ BtcNodes .BtcNode .DEFAULT_PORT , "@alice" ),
123
+ new BtcNodes .BtcNode (null , null , bannedAddress , 7348 , "@bob" ),
124
+ new BtcNodes .BtcNode (null , "charlie.onion" , null ,
125
+ BtcNodes .BtcNode .DEFAULT_PORT , "@charlie" )
126
+ );
127
+
128
+ List <BtcNodes .BtcNode > mutableHardcodedList = new ArrayList <>(hardcodedNodes );
129
+ List <String > filterProvidedBtcNodes = Collections .emptyList ();
130
+ String bannedFullAddress = "[" + bannedAddress + "]" + ":" + 1234 ;
131
+ List <String > bannedBtcNodes = List .of (bannedFullAddress );
132
+
133
+ List <BtcNodes .BtcNode > selectedNodes = FederatedBtcNodeProvider
134
+ .getNodes (mutableHardcodedList , filterProvidedBtcNodes , bannedBtcNodes );
135
+
136
+ assertIterableEquals (hardcodedNodes , selectedNodes );
137
+ }
138
+
93
139
@ Test
94
140
void bannedHostNameNode () {
141
+ String bannedHostName = "btc1.dnsalias.net" ;
142
+ int port = 5678 ;
143
+
95
144
var hardcodedNodes = List .of (
96
145
new BtcNodes .BtcNode (null , "alice.onion" , null ,
97
146
BtcNodes .BtcNode .DEFAULT_PORT , "@alice" ),
98
- new BtcNodes .BtcNode (null , "btc1.dnsalias.net" , null ,
99
- 5678 , "@bob" ),
147
+ new BtcNodes .BtcNode (null , bannedHostName , null , port , "@bob" ),
100
148
new BtcNodes .BtcNode (null , "charlie.onion" , null ,
101
149
BtcNodes .BtcNode .DEFAULT_PORT , "@charlie" )
102
150
);
103
151
104
152
List <BtcNodes .BtcNode > mutableHardcodedList = new ArrayList <>(hardcodedNodes );
105
153
List <String > filterProvidedBtcNodes = Collections .emptyList ();
106
- List <String > bannedBtcNodes = List .of ("btc1.dnsalias.net:5678" );
154
+ List <String > bannedBtcNodes = List .of (bannedHostName + ":" + port );
107
155
108
156
List <BtcNodes .BtcNode > selectedNodes = FederatedBtcNodeProvider
109
157
.getNodes (mutableHardcodedList , filterProvidedBtcNodes , bannedBtcNodes );
@@ -117,20 +165,44 @@ void bannedHostNameNode() {
117
165
assertIterableEquals (expected , selectedNodes );
118
166
}
119
167
168
+ @ Test
169
+ void bannedHostNameNodeWrongPort () {
170
+ String bannedHostName = "btc1.dnsalias.net" ;
171
+
172
+ var hardcodedNodes = List .of (
173
+ new BtcNodes .BtcNode (null , "alice.onion" , null ,
174
+ BtcNodes .BtcNode .DEFAULT_PORT , "@alice" ),
175
+ new BtcNodes .BtcNode (null , bannedHostName , null , 5678 , "@bob" ),
176
+ new BtcNodes .BtcNode (null , "charlie.onion" , null ,
177
+ BtcNodes .BtcNode .DEFAULT_PORT , "@charlie" )
178
+ );
179
+
180
+ List <BtcNodes .BtcNode > mutableHardcodedList = new ArrayList <>(hardcodedNodes );
181
+ List <String > filterProvidedBtcNodes = Collections .emptyList ();
182
+ List <String > bannedBtcNodes = List .of (bannedHostName + ":" + 1234 );
183
+
184
+ List <BtcNodes .BtcNode > selectedNodes = FederatedBtcNodeProvider
185
+ .getNodes (mutableHardcodedList , filterProvidedBtcNodes , bannedBtcNodes );
186
+
187
+ assertIterableEquals (hardcodedNodes , selectedNodes );
188
+ }
189
+
120
190
@ Test
121
191
void bannedOnionNode () {
192
+ String bannedOnionAddress = "bob.onion" ;
193
+
122
194
var hardcodedNodes = List .of (
123
195
new BtcNodes .BtcNode (null , "alice.onion" , null ,
124
196
BtcNodes .BtcNode .DEFAULT_PORT , "@alice" ),
125
- new BtcNodes .BtcNode (null , "bob.onion" , null ,
197
+ new BtcNodes .BtcNode (null , bannedOnionAddress , null ,
126
198
BtcNodes .BtcNode .DEFAULT_PORT , "@bob" ),
127
199
new BtcNodes .BtcNode (null , "charlie.onion" , null ,
128
200
BtcNodes .BtcNode .DEFAULT_PORT , "@charlie" )
129
201
);
130
202
131
203
List <BtcNodes .BtcNode > mutableHardcodedList = new ArrayList <>(hardcodedNodes );
132
204
List <String > filterProvidedBtcNodes = Collections .emptyList ();
133
- List <String > bannedBtcNodes = List .of ("bob.onion:8333" );
205
+ List <String > bannedBtcNodes = List .of (bannedOnionAddress + ":" + BtcNodes . BtcNode . DEFAULT_PORT );
134
206
135
207
List <BtcNodes .BtcNode > selectedNodes = FederatedBtcNodeProvider
136
208
.getNodes (mutableHardcodedList , filterProvidedBtcNodes , bannedBtcNodes );
@@ -143,4 +215,27 @@ void bannedOnionNode() {
143
215
);
144
216
assertIterableEquals (expected , selectedNodes );
145
217
}
218
+
219
+ @ Test
220
+ void bannedOnionNodeWrongPort () {
221
+ String bannedOnionAddress = "bob.onion" ;
222
+
223
+ var hardcodedNodes = List .of (
224
+ new BtcNodes .BtcNode (null , "alice.onion" , null ,
225
+ BtcNodes .BtcNode .DEFAULT_PORT , "@alice" ),
226
+ new BtcNodes .BtcNode (null , bannedOnionAddress , null ,
227
+ BtcNodes .BtcNode .DEFAULT_PORT , "@bob" ),
228
+ new BtcNodes .BtcNode (null , "charlie.onion" , null ,
229
+ BtcNodes .BtcNode .DEFAULT_PORT , "@charlie" )
230
+ );
231
+
232
+ List <BtcNodes .BtcNode > mutableHardcodedList = new ArrayList <>(hardcodedNodes );
233
+ List <String > filterProvidedBtcNodes = Collections .emptyList ();
234
+ List <String > bannedBtcNodes = List .of (bannedOnionAddress + ":" + 1234 );
235
+
236
+ List <BtcNodes .BtcNode > selectedNodes = FederatedBtcNodeProvider
237
+ .getNodes (mutableHardcodedList , filterProvidedBtcNodes , bannedBtcNodes );
238
+
239
+ assertIterableEquals (hardcodedNodes , selectedNodes );
240
+ }
146
241
}
0 commit comments