summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/test/mtproto.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-09-29 14:24:23 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-09-29 19:04:02 +0300
commit8e36edeef44005c24fa574fbb90556442a6a516f (patch)
treee4766ace481283264e172b243b3026c26f47bd89 /protocols/Telegram/tdlib/td/test/mtproto.cpp
parent55793991ad8b130f5146c1b72bfa0d126ce13456 (diff)
TDLIB: copyright updates & code cleaning
Diffstat (limited to 'protocols/Telegram/tdlib/td/test/mtproto.cpp')
-rw-r--r--protocols/Telegram/tdlib/td/test/mtproto.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/protocols/Telegram/tdlib/td/test/mtproto.cpp b/protocols/Telegram/tdlib/td/test/mtproto.cpp
index 614e153e6f..72d1af5d73 100644
--- a/protocols/Telegram/tdlib/td/test/mtproto.cpp
+++ b/protocols/Telegram/tdlib/td/test/mtproto.cpp
@@ -1,14 +1,13 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/telegram/ConfigManager.h"
-#include "td/telegram/net/DcId.h"
-#include "td/telegram/net/PublicRsaKeyShared.h"
-#include "td/telegram/net/Session.h"
+#include "td/telegram/net/PublicRsaKeySharedMain.h"
#include "td/telegram/NotificationManager.h"
+#include "td/telegram/telegram_api.h"
#include "td/mtproto/AuthData.h"
#include "td/mtproto/DhCallback.h"
@@ -34,6 +33,7 @@
#include "td/utils/BufferedFd.h"
#include "td/utils/common.h"
#include "td/utils/crypto.h"
+#include "td/utils/HttpDate.h"
#include "td/utils/logging.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/port/IPAddress.h"
@@ -46,6 +46,8 @@
#include "td/utils/tests.h"
#include "td/utils/Time.h"
+#include <memory>
+
TEST(Mtproto, GetHostByNameActor) {
int threads_n = 1;
td::ConcurrentScheduler sched(threads_n, 0);
@@ -194,7 +196,7 @@ TEST(Mtproto, encrypted_config) {
"FnWWdEV+BPJeOTk+ARHcNkuJBt0CqnfcVCoDOpKqGyq0U31s2MOpQvHgAG+Tlpg02syuH0E4dCGRw5CbJPARiynteb9y5fT5x/"
"kmdp6BMR5tWQSQF0liH16zLh8BDSIdiMsikdcwnAvBwdNhRqQBqGx9MTh62MDmlebjtczE9Gz0z5cscUO2yhzGdphgIy6SP+"
"bwaqLWYF0XdPGjKLMUEJW+rou6fbL1t/EUXPtU0XmQAnO0Fh86h+AqDMOe30N4qKrPQ== ";
- auto config = td::decode_config(data).move_as_ok();
+ td::telegram_api::object_ptr<td::telegram_api::help_configSimple> config = td::decode_config(data).move_as_ok();
}
class TestPingActor final : public td::Actor {
@@ -300,11 +302,11 @@ class HandshakeContext final : public td::mtproto::AuthKeyHandshakeContext {
return nullptr;
}
td::mtproto::PublicRsaKeyInterface *get_public_rsa_key_interface() final {
- return &public_rsa_key;
+ return public_rsa_key_.get();
}
private:
- td::PublicRsaKeyShared public_rsa_key{td::DcId::empty(), true};
+ std::shared_ptr<td::mtproto::PublicRsaKeyInterface> public_rsa_key_ = td::PublicRsaKeySharedMain::create(true);
};
class HandshakeTestActor final : public td::Actor {
@@ -365,11 +367,11 @@ class HandshakeTestActor final : public td::Actor {
10.0,
td::PromiseCreator::lambda(
[actor_id = actor_id(this)](td::Result<td::unique_ptr<td::mtproto::RawConnection>> raw_connection) {
- td::send_closure(actor_id, &HandshakeTestActor::got_connection, std::move(raw_connection), 1);
+ td::send_closure(actor_id, &HandshakeTestActor::on_connection, std::move(raw_connection), 1);
}),
td::PromiseCreator::lambda(
[actor_id = actor_id(this)](td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> handshake) {
- td::send_closure(actor_id, &HandshakeTestActor::got_handshake, std::move(handshake), 1);
+ td::send_closure(actor_id, &HandshakeTestActor::on_handshake, std::move(handshake), 1);
}))
.release();
wait_for_raw_connection_ = true;
@@ -377,7 +379,7 @@ class HandshakeTestActor final : public td::Actor {
}
}
- void got_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_raw_connection, bool dummy) {
+ void on_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_raw_connection, bool dummy) {
CHECK(wait_for_raw_connection_);
wait_for_raw_connection_ = false;
if (r_raw_connection.is_ok()) {
@@ -390,7 +392,7 @@ class HandshakeTestActor final : public td::Actor {
loop();
}
- void got_handshake(td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> r_handshake, bool dummy) {
+ void on_handshake(td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> r_handshake, bool dummy) {
CHECK(wait_for_handshake_);
wait_for_handshake_ = false;
CHECK(r_handshake.is_ok());
@@ -553,16 +555,16 @@ class FastPingTestActor final : public td::Actor {
"HandshakeActor", std::move(handshake), std::move(raw_connection), td::make_unique<HandshakeContext>(), 10.0,
td::PromiseCreator::lambda(
[actor_id = actor_id(this)](td::Result<td::unique_ptr<td::mtproto::RawConnection>> raw_connection) {
- td::send_closure(actor_id, &FastPingTestActor::got_connection, std::move(raw_connection), 1);
+ td::send_closure(actor_id, &FastPingTestActor::on_connection, std::move(raw_connection), 1);
}),
td::PromiseCreator::lambda(
[actor_id = actor_id(this)](td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> handshake) {
- td::send_closure(actor_id, &FastPingTestActor::got_handshake, std::move(handshake), 1);
+ td::send_closure(actor_id, &FastPingTestActor::on_handshake, std::move(handshake), 1);
}))
.release();
}
- void got_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_raw_connection, bool dummy) {
+ void on_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_raw_connection, bool dummy) {
if (r_raw_connection.is_error()) {
*result_ = r_raw_connection.move_as_error();
LOG(INFO) << "Receive " << *result_ << " instead of a connection";
@@ -572,7 +574,7 @@ class FastPingTestActor final : public td::Actor {
loop();
}
- void got_handshake(td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> r_handshake, bool dummy) {
+ void on_handshake(td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> r_handshake, bool dummy) {
if (r_handshake.is_error()) {
*result_ = r_handshake.move_as_error();
LOG(INFO) << "Receive " << *result_ << " instead of a handshake";
@@ -582,7 +584,7 @@ class FastPingTestActor final : public td::Actor {
loop();
}
- void got_raw_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_connection) {
+ void on_raw_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_connection) {
if (r_connection.is_error()) {
*result_ = r_connection.move_as_error();
LOG(INFO) << "Receive " << *result_ << " instead of a handshake";
@@ -619,7 +621,7 @@ class FastPingTestActor final : public td::Actor {
td::Slice(), std::move(connection_), std::move(auth_data),
td::PromiseCreator::lambda(
[actor_id = actor_id(this)](td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_raw_connection) {
- td::send_closure(actor_id, &FastPingTestActor::got_raw_connection, std::move(r_raw_connection));
+ td::send_closure(actor_id, &FastPingTestActor::on_raw_connection, std::move(r_raw_connection));
}),
td::ActorShared<>());
}