Skip to content

Commit 0e68cb0

Browse files
committed
Merge branch 'dev' into feature/blinded-contacts
# Conflicts: # tests/test_session_network.cpp
2 parents b2ad839 + f2c6d31 commit 0e68cb0

File tree

4 files changed

+66
-66
lines changed

4 files changed

+66
-66
lines changed

.drone.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ local static_build(name,
356356
clang(17),
357357
full_llvm(17),
358358
debian_build('Debian stable (i386)', docker_base + 'debian-stable/i386'),
359-
debian_build('Debian 11', docker_base + 'debian-bullseye', extra_setup=debian_backports('bullseye', ['cmake'])),
359+
debian_build('Debian 12', docker_base + 'debian-bookworm', extra_setup=debian_backports('bookworm', ['cmake'])),
360360
debian_build('Ubuntu latest', docker_base + 'ubuntu-rolling'),
361361
debian_build('Ubuntu LTS', docker_base + 'ubuntu-lts'),
362362

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if(CCACHE_PROGRAM)
1717
endif()
1818

1919
project(libsession-util
20-
VERSION 1.5.0
20+
VERSION 1.5.1
2121
DESCRIPTION "Session client utility library"
2222
LANGUAGES ${LANGS})
2323

src/session_network.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,16 @@ namespace {
233233
}
234234

235235
const std::vector<service_node> seed_nodes_testnet{
236-
node_from_disk("144.76.164.202|35400|2.8.0|"
236+
node_from_disk("95.216.33.113|35400|2.8.0|"
237237
"decaf007f26d3d6f9b845ad031ffdf6d04638c25bb10b8fffbbe99135303c4b9|"sv)};
238238
const std::vector<service_node> seed_nodes_mainnet{
239-
node_from_disk("144.76.164.202|20200|2.8.0|"
239+
node_from_disk("95.216.33.113|20200|2.8.0|"
240240
"1f000f09a7b07828dcb72af7cd16857050c10c02bd58afb0e38111fb6cda1fef|"sv),
241-
node_from_disk("88.99.102.229|20201|2.8.0|"
241+
node_from_disk("37.27.236.229|20201|2.8.0|"
242242
"1f101f0acee4db6f31aaa8b4df134e85ca8a4878efaef7f971e88ab144c1a7ce|"sv),
243-
node_from_disk("195.16.73.17|20202|2.8.0|"
243+
node_from_disk("172.96.140.124|20202|2.8.0|"
244244
"1f202f00f4d2d4acc01e20773999a291cf3e3136c325474d159814e06199919f|"sv),
245-
node_from_disk("104.194.11.120|20203|2.8.0|"
245+
node_from_disk("208.73.207.54|20203|2.8.0|"
246246
"1f303f1d7523c46fa5398826740d13282d26b5de90fbae5749442f66afb6d78b|"sv),
247247
node_from_disk("104.194.8.115|20204|2.8.0|"
248248
"1f604f1c858a121a681d8f9b470ef72e6946ee1b9c5ad15a35e16b50c28db7b0|"sv)};

tests/test_session_network.cpp

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,53 @@ std::optional<service_node> node_for_destination(network_destination destination
5757
return std::nullopt;
5858
}
5959

60+
std::shared_ptr<TestServer> create_test_server(uint16_t port) {
61+
oxen::quic::opt::inbound_alpns server_alpns{"oxenstorage"};
62+
auto server_key_pair = session::ed25519::ed25519_key_pair(to_span(fmt::format("{:032}", port)));
63+
auto server_x25519_pubkey = session::curve25519::to_curve25519_pubkey(
64+
{server_key_pair.first.data(), server_key_pair.first.size()});
65+
auto server_x25519_seckey = session::curve25519::to_curve25519_seckey(
66+
{server_key_pair.second.data(), server_key_pair.second.size()});
67+
auto creds =
68+
oxen::quic::GNUTLSCreds::make_from_ed_seckey(to_string_view(server_key_pair.second));
69+
oxen::quic::Address server_local{port};
70+
session::onionreq::HopEncryption decryptor{
71+
x25519_seckey::from_bytes(to_span(server_x25519_seckey)),
72+
x25519_pubkey::from_bytes(to_span(server_x25519_pubkey)),
73+
true};
74+
75+
auto server_cb = [&](oxen::quic::message m) {
76+
nlohmann::json response{{"hf", {1, 0, 0}}, {"t", 1234567890}, {"version", {2, 8, 0}}};
77+
m.respond(response.dump(), false);
78+
};
79+
80+
auto onion_cb = [&](oxen::quic::message m) {
81+
nlohmann::json response{{"hf", {2, 0, 0}}, {"t", 1234567890}, {"version", {2, 8, 0}}};
82+
m.respond(response.dump(), false);
83+
};
84+
85+
oxen::quic::stream_constructor_callback server_constructor =
86+
[&](oxen::quic::Connection& c, oxen::quic::Endpoint& e, std::optional<int64_t>) {
87+
auto s = e.loop.make_shared<oxen::quic::BTRequestStream>(c, e);
88+
s->register_handler("info", server_cb);
89+
s->register_handler("onion_req", onion_cb);
90+
return s;
91+
};
92+
93+
auto loop = std::make_shared<oxen::quic::Loop>();
94+
auto endpoint = oxen::quic::Endpoint::endpoint(*loop, server_local, server_alpns);
95+
endpoint->listen(creds, server_constructor);
96+
97+
auto node = service_node{
98+
to_string_view(server_key_pair.first),
99+
{2, 8, 0},
100+
INVALID_SWARM_ID,
101+
"127.0.0.1"s,
102+
endpoint->local().port()};
103+
104+
return std::make_shared<TestServer>(loop, endpoint, node);
105+
}
106+
60107
} // namespace
61108

62109
namespace session::network {
@@ -193,61 +240,13 @@ class TestNetwork : public Network {
193240
std::optional<std::string>) {});
194241
}
195242

196-
std::shared_ptr<TestServer> create_test_node(uint16_t port) {
197-
oxen::quic::opt::inbound_alpns server_alpns{"oxenstorage"};
198-
auto server_key_pair =
199-
session::ed25519::ed25519_key_pair(to_span(fmt::format("{:032}", port)));
200-
auto server_x25519_pubkey = session::curve25519::to_curve25519_pubkey(
201-
{server_key_pair.first.data(), server_key_pair.first.size()});
202-
auto server_x25519_seckey = session::curve25519::to_curve25519_seckey(
203-
{server_key_pair.second.data(), server_key_pair.second.size()});
204-
auto creds = oxen::quic::GNUTLSCreds::make_from_ed_seckey(
205-
to_string_view(server_key_pair.second));
206-
oxen::quic::Address server_local{port};
207-
session::onionreq::HopEncryption decryptor{
208-
x25519_seckey::from_bytes(to_span(server_x25519_seckey)),
209-
x25519_pubkey::from_bytes(to_span(server_x25519_pubkey)),
210-
true};
211-
212-
auto server_cb = [&](oxen::quic::message m) {
213-
nlohmann::json response{{"hf", {1, 0, 0}}, {"t", 1234567890}, {"version", {2, 8, 0}}};
214-
m.respond(response.dump(), false);
215-
};
216-
217-
auto onion_cb = [&](oxen::quic::message m) {
218-
nlohmann::json response{{"hf", {2, 0, 0}}, {"t", 1234567890}, {"version", {2, 8, 0}}};
219-
m.respond(response.dump(), false);
220-
};
221-
222-
oxen::quic::stream_constructor_callback server_constructor =
223-
[&](oxen::quic::Connection& c, oxen::quic::Endpoint& e, std::optional<int64_t>) {
224-
auto s = e.loop.make_shared<oxen::quic::BTRequestStream>(c, e);
225-
s->register_handler("info", server_cb);
226-
s->register_handler("onion_req", onion_cb);
227-
return s;
228-
};
229-
230-
auto loop = std::make_shared<oxen::quic::Loop>();
231-
auto endpoint = oxen::quic::Endpoint::endpoint(*loop, server_local, server_alpns);
232-
endpoint->listen(creds, server_constructor);
233-
234-
auto node = service_node{
235-
to_string_view(server_key_pair.first),
236-
{2, 8, 0},
237-
INVALID_SWARM_ID,
238-
"127.0.0.1"s,
239-
endpoint->local().port()};
240-
241-
return std::make_shared<TestServer>(loop, endpoint, node);
242-
}
243-
244243
std::pair<std::vector<std::shared_ptr<TestServer>>, onion_path> create_test_path() {
245244
std::vector<std::shared_ptr<TestServer>> path_servers;
246245
std::vector<service_node> path_nodes;
247246
path_nodes.reserve(3);
248247

249248
for (auto i = 0; i < 3; ++i) {
250-
path_servers.emplace_back(create_test_node(static_cast<uint16_t>(1000 + i)));
249+
path_servers.emplace_back(create_test_server(static_cast<uint16_t>(1000 + i)));
251250
path_nodes.emplace_back(path_servers[i]->node);
252251
}
253252

@@ -1073,10 +1072,11 @@ TEST_CASE("Network", "[network][build_path]") {
10731072

10741073
TEST_CASE("Network", "[network][find_valid_path]") {
10751074
auto ed_pk = "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7"_hexbytes;
1075+
auto test_server = create_test_server(500);
10761076
auto target = test_node(ed_pk, 1);
1077-
auto network = TestNetwork(std::nullopt, true, false, false);
1078-
auto test_server = network.create_test_node(500);
10791077
auto info = request_info::make(target, std::nullopt, std::nullopt, 0ms);
1078+
1079+
auto network = TestNetwork(std::nullopt, true, false, false);
10801080
auto invalid_path = onion_path{
10811081
"Test",
10821082
{test_server->node, nullptr, nullptr, nullptr},
@@ -1125,7 +1125,7 @@ TEST_CASE("Network", "[network][find_valid_path]") {
11251125
TEST_CASE("Network", "[network][build_path_if_needed]") {
11261126
auto ed_pk = "4cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7"_hexbytes;
11271127
auto target = test_node(ed_pk, 0);
1128-
;
1128+
11291129
std::optional<TestNetwork> network;
11301130
auto invalid_path = onion_path{
11311131
"Test", connection_info{target, nullptr, nullptr, nullptr}, {target}, uint8_t{0}};
@@ -1221,8 +1221,8 @@ TEST_CASE("Network", "[network][build_path_if_needed]") {
12211221
}
12221222

12231223
TEST_CASE("Network", "[network][establish_connection]") {
1224+
auto test_server = create_test_server(500);
12241225
auto network = TestNetwork(std::nullopt, true, true, false);
1225-
auto test_server = network.create_test_node(500);
12261226
std::promise<std::pair<connection_info, std::optional<std::string>>> prom;
12271227

12281228
network.establish_connection(
@@ -1248,7 +1248,7 @@ TEST_CASE("Network", "[network][check_request_queue_timeouts]") {
12481248
// Test that it doesn't start checking for timeouts when the request doesn't have
12491249
// a build paths timeout
12501250
network.emplace(std::nullopt, true, true, false);
1251-
test_server.emplace(network->create_test_node(501));
1251+
test_server.emplace(create_test_server(501));
12521252
network->send_onion_request(
12531253
(*test_server)->node,
12541254
to_vector("{\"method\":\"info\",\"params\":{}}"),
@@ -1265,7 +1265,7 @@ TEST_CASE("Network", "[network][check_request_queue_timeouts]") {
12651265
// Test that it does start checking for timeouts when the request has a
12661266
// paths build timeout
12671267
network.emplace(std::nullopt, true, true, false);
1268-
test_server.emplace(network->create_test_node(502));
1268+
test_server.emplace(create_test_server(502));
12691269
network->ignore_calls_to("build_path");
12701270
network->send_onion_request(
12711271
(*test_server)->node,
@@ -1283,7 +1283,7 @@ TEST_CASE("Network", "[network][check_request_queue_timeouts]") {
12831283
// Test that it fails the request with a timeout if it has a build path timeout
12841284
// and the path build takes too long
12851285
network.emplace(std::nullopt, true, true, false);
1286-
test_server.emplace(network->create_test_node(503));
1286+
test_server.emplace(create_test_server(503));
12871287
network->ignore_calls_to("build_path");
12881288
network->send_onion_request(
12891289
(*test_server)->node,
@@ -1307,8 +1307,8 @@ TEST_CASE("Network", "[network][check_request_queue_timeouts]") {
13071307
}
13081308

13091309
TEST_CASE("Network", "[network][send_request]") {
1310+
auto test_server = create_test_server(500);
13101311
auto network = TestNetwork(std::nullopt, true, true, false);
1311-
auto test_server = network.create_test_node(500);
13121312
std::promise<Result> prom;
13131313

13141314
network.establish_connection(
@@ -1360,8 +1360,8 @@ TEST_CASE("Network", "[network][send_request]") {
13601360
}
13611361

13621362
TEST_CASE("Network", "[network][send_onion_request]") {
1363+
auto test_server = create_test_server(500);
13631364
auto network = TestNetwork(std::nullopt, true, true, false);
1364-
auto test_server = network.create_test_node(500);
13651365
auto [test_path_servers, test_path] = network.create_test_path();
13661366
network.handle_onion_requests_as_plaintext = true;
13671367
network.set_paths(PathType::standard, {test_path});
@@ -1402,8 +1402,8 @@ TEST_CASE("Network", "[network][send_onion_request]") {
14021402
}
14031403

14041404
TEST_CASE("Network", "[network][c][network_send_onion_request]") {
1405+
auto test_server_cpp = create_test_server(500);
14051406
auto test_network = std::make_unique<TestNetwork>(std::nullopt, true, true, false);
1406-
auto test_server_cpp = test_network->create_test_node(500);
14071407
std::optional<std::pair<std::vector<std::shared_ptr<TestServer>>, onion_path>> test_path_data;
14081408
test_path_data.emplace(test_network->create_test_path());
14091409
test_network->handle_onion_requests_as_plaintext = true;

0 commit comments

Comments
 (0)