@@ -96,11 +96,86 @@ BOOST_AUTO_TEST_CASE(electrum__server_donation_address__jsonrpc_2__expected)
9696}
9797
9898// server.features
99+
100+ BOOST_AUTO_TEST_CASE (electrum__server_features__no_params__expected)
101+ {
102+ BOOST_REQUIRE (handshake (electrum::version::v1_2));
103+
104+ const auto response = get (R"( {"id":301,"method":"server.features"})" " \n " );
105+ REQUIRE_NO_THROW_TRUE (response.at (" dropped" ).as_bool ());
106+ }
107+
108+ BOOST_AUTO_TEST_CASE (electrum__server_features__extra_param__dropped)
109+ {
110+ BOOST_REQUIRE (handshake (electrum::version::v1_2));
111+
112+ const auto response = get (R"( {"id":302,"method":"server.features","params":["extra"]})" " \n " );
113+ REQUIRE_NO_THROW_TRUE (response.at (" dropped" ).as_bool ());
114+ }
115+
116+ BOOST_AUTO_TEST_CASE (electrum__server_features__default_hosts__expected)
117+ {
118+ BOOST_REQUIRE (handshake (electrum::version::v1_2));
119+
120+ const auto response = get (R"( {"id":300,"method":"server.features","params":[]})" " \n " );
121+ REQUIRE_NO_THROW_TRUE (response.at (" result" ).is_object ());
122+
123+ const auto & result = response.at (" result" ).as_object ();
124+ REQUIRE_NO_THROW_TRUE (result.at (" genesis_hash" ).is_string ());
125+ REQUIRE_NO_THROW_TRUE (result.at (" hash_function" ).is_string ());
126+ REQUIRE_NO_THROW_TRUE (result.at (" server_version" ).is_string ());
127+ REQUIRE_NO_THROW_TRUE (result.at (" protocol_min" ).is_string ());
128+ REQUIRE_NO_THROW_TRUE (result.at (" protocol_max" ).is_string ());
129+ REQUIRE_NO_THROW_TRUE (result.at (" pruning" ).is_null ());
130+ REQUIRE_NO_THROW_TRUE (result.at (" hosts" ).is_object ());
131+
132+ using namespace electrum ;
133+ const auto min = version_to_string (protocol_electrum_version::minimum);
134+ const auto max = version_to_string (protocol_electrum_version::maximum);
135+ const auto server_name = config_.server .electrum .server_name ;
136+ const auto genesis_hash = encode_hash (genesis.hash ());
137+ BOOST_REQUIRE_EQUAL (result.at (" genesis_hash" ).as_string (), genesis_hash);
138+ BOOST_REQUIRE_EQUAL (result.at (" hash_function" ).as_string (), " sha256" );
139+ BOOST_REQUIRE_EQUAL (result.at (" server_version" ).as_string (), server_name);
140+ BOOST_REQUIRE_EQUAL (result.at (" protocol_min" ).as_string (), min);
141+ BOOST_REQUIRE_EQUAL (result.at (" protocol_max" ).as_string (), max);
142+
143+ const auto & hosts = result.at (" hosts" ).as_object ();
144+ BOOST_REQUIRE_EQUAL (hosts.size (), 1u );
145+ REQUIRE_NO_THROW_TRUE (hosts.at (" " ).is_object ());
146+
147+ const auto & host = hosts.at (" " ).as_object ();
148+ REQUIRE_NO_THROW_TRUE (host.at (" tcp_port" ).is_null ());
149+ REQUIRE_NO_THROW_TRUE (host.at (" ssl_port" ).is_null ());
150+ }
151+
152+ BOOST_AUTO_TEST_CASE (electrum__server_features__hosts__expected)
153+ {
154+ config_.server .electrum .advertise_binds .emplace_back (" tcp.com:80" );
155+ config_.server .electrum .advertise_safes .emplace_back (" ssl.com:443" );
156+ BOOST_REQUIRE (handshake (electrum::version::v1_0));
157+
158+ const auto response = get (R"( {"id":300,"method":"server.features","params":[]})" " \n " );
159+ REQUIRE_NO_THROW_TRUE (response.at (" result" ).is_object ());
160+
161+ const auto & result = response.at (" result" ).as_object ();
162+ REQUIRE_NO_THROW_TRUE (result.at (" hosts" ).is_object ());
163+
164+ const auto & hosts = result.at (" hosts" ).as_object ();
165+ REQUIRE_NO_THROW_TRUE (hosts.at (" tcp.com" ).is_object ());
166+ REQUIRE_NO_THROW_TRUE (hosts.at (" ssl.com" ).is_object ());
167+
168+ const auto & tcp = hosts.at (" tcp.com" ).as_object ();
169+ const auto & ssl = hosts.at (" ssl.com" ).as_object ();
170+ BOOST_REQUIRE_EQUAL (tcp.at (" tcp_port" ).as_int64 (), 80 );
171+ BOOST_REQUIRE_EQUAL (ssl.at (" ssl_port" ).as_int64 (), 443 );
172+ }
173+
99174// server.peers.subscribe
100175
101176// server.ping
102177
103- BOOST_AUTO_TEST_CASE (electrum__server_ping__null )
178+ BOOST_AUTO_TEST_CASE (electrum__server_ping__always__null )
104179{
105180 BOOST_REQUIRE (handshake (electrum::version::v1_2));
106181
0 commit comments