@@ -1014,14 +1014,16 @@ public void callingWithBannedNodeidsOptionWithInvalidValuesMustDisplayError() {
1014
1014
}
1015
1015
1016
1016
@ Test
1017
- public void p2pHostAndPortOptionsAreRespected () {
1017
+ public void p2pHostAndPortOptionsAreRespectedAndNotLeaked () {
1018
1018
1019
1019
final String host = "1.2.3.4" ;
1020
1020
final int port = 1234 ;
1021
1021
parseCommand ("--p2p-host" , host , "--p2p-port" , String .valueOf (port ));
1022
1022
1023
1023
verify (mockRunnerBuilder ).p2pAdvertisedHost (stringArgumentCaptor .capture ());
1024
1024
verify (mockRunnerBuilder ).p2pListenPort (intArgumentCaptor .capture ());
1025
+ verify (mockRunnerBuilder ).metricsConfiguration (metricsConfigArgumentCaptor .capture ());
1026
+ verify (mockRunnerBuilder ).jsonRpcConfiguration (jsonRpcConfigArgumentCaptor .capture ());
1025
1027
verify (mockRunnerBuilder ).build ();
1026
1028
1027
1029
assertThat (stringArgumentCaptor .getValue ()).isEqualTo (host );
@@ -1030,11 +1032,47 @@ public void p2pHostAndPortOptionsAreRespected() {
1030
1032
assertThat (commandOutput .toString (UTF_8 )).isEmpty ();
1031
1033
assertThat (commandErrorOutput .toString (UTF_8 )).isEmpty ();
1032
1034
1033
- // rpc host should remain default ie 127.0.0.1
1035
+ // all other port values remain default
1036
+ assertThat (metricsConfigArgumentCaptor .getValue ().getPort ()).isEqualTo (9545 );
1037
+ assertThat (metricsConfigArgumentCaptor .getValue ().getPushPort ()).isEqualTo (9001 );
1038
+ assertThat (jsonRpcConfigArgumentCaptor .getValue ().getPort ()).isEqualTo (8545 );
1039
+
1040
+ // all other host values remain default
1041
+ final String defaultHost = "127.0.0.1" ;
1042
+ assertThat (metricsConfigArgumentCaptor .getValue ().getHost ()).isEqualTo (defaultHost );
1043
+ assertThat (metricsConfigArgumentCaptor .getValue ().getPushHost ()).isEqualTo (defaultHost );
1044
+ assertThat (jsonRpcConfigArgumentCaptor .getValue ().getHost ()).isEqualTo (defaultHost );
1045
+ }
1046
+
1047
+ @ Test
1048
+ public void p2pHostAndPortOptionsAreRespectedAndNotLeakedWithMetricsEnabled () {
1049
+
1050
+ final String host = "1.2.3.4" ;
1051
+ final int port = 1234 ;
1052
+ parseCommand ("--p2p-host" , host , "--p2p-port" , String .valueOf (port ), "--metrics-enabled" );
1053
+
1054
+ verify (mockRunnerBuilder ).p2pAdvertisedHost (stringArgumentCaptor .capture ());
1055
+ verify (mockRunnerBuilder ).p2pListenPort (intArgumentCaptor .capture ());
1056
+ verify (mockRunnerBuilder ).metricsConfiguration (metricsConfigArgumentCaptor .capture ());
1034
1057
verify (mockRunnerBuilder ).jsonRpcConfiguration (jsonRpcConfigArgumentCaptor .capture ());
1035
1058
verify (mockRunnerBuilder ).build ();
1036
1059
1037
- assertThat (jsonRpcConfigArgumentCaptor .getValue ().getHost ()).isEqualTo ("127.0.0.1" );
1060
+ assertThat (stringArgumentCaptor .getValue ()).isEqualTo (host );
1061
+ assertThat (intArgumentCaptor .getValue ()).isEqualTo (port );
1062
+
1063
+ assertThat (commandOutput .toString (UTF_8 )).isEmpty ();
1064
+ assertThat (commandErrorOutput .toString (UTF_8 )).isEmpty ();
1065
+
1066
+ // all other port values remain default
1067
+ assertThat (metricsConfigArgumentCaptor .getValue ().getPort ()).isEqualTo (9545 );
1068
+ assertThat (metricsConfigArgumentCaptor .getValue ().getPushPort ()).isEqualTo (9001 );
1069
+ assertThat (jsonRpcConfigArgumentCaptor .getValue ().getPort ()).isEqualTo (8545 );
1070
+
1071
+ // all other host values remain default
1072
+ final String defaultHost = "127.0.0.1" ;
1073
+ assertThat (metricsConfigArgumentCaptor .getValue ().getHost ()).isEqualTo (defaultHost );
1074
+ assertThat (metricsConfigArgumentCaptor .getValue ().getPushHost ()).isEqualTo (defaultHost );
1075
+ assertThat (jsonRpcConfigArgumentCaptor .getValue ().getHost ()).isEqualTo (defaultHost );
1038
1076
}
1039
1077
1040
1078
@ Test
@@ -2285,7 +2323,7 @@ public void staticNodesFileOptionFileDoesNotExistMessage() {
2285
2323
}
2286
2324
2287
2325
@ Test
2288
- public void staticNodesFileOptionValidParamenter () throws IOException {
2326
+ public void staticNodesFileOptionValidParameter () throws IOException {
2289
2327
final Path staticNodeTempFile =
2290
2328
createTempFile (
2291
2329
"static-nodes-goodformat.json" ,
0 commit comments