Fix TlsTransport test.

GitOrigin-RevId: bc5da0b5077558ac80d7ce736ef1063c2392ce05
This commit is contained in:
levlam 2019-07-07 03:35:30 +03:00
parent e300208960
commit 8a94ce1458

View File

@ -599,29 +599,36 @@ TEST(Mtproto, Grease) {
} }
} }
TEST(Mtproto, TlsObfusaction) { TEST(Mtproto, TlsTransport) {
std::string domain = "www.google.com";
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(ERROR)); SET_VERBOSITY_LEVEL(VERBOSITY_NAME(ERROR));
ConcurrentScheduler sched; ConcurrentScheduler sched;
int threads_n = 1; int threads_n = 1;
sched.init(threads_n); sched.init(threads_n);
{ {
auto guard = sched.get_main_guard(); auto guard = sched.get_main_guard();
class Callback : public TransparentProxy::Callback { class RunTest : public Actor {
public: private:
void set_result(Result<SocketFd> result) override { void start_up() override {
CHECK(result.is_error() && result.error().message() == "Response hash mismatch"); class Callback : public TransparentProxy::Callback {
Scheduler::instance()->finish(); public:
} void set_result(Result<SocketFd> result) override {
void on_connected() override { CHECK(result.is_error() && result.error().message() == "Response hash mismatch");
Scheduler::instance()->finish();
}
void on_connected() override {
}
};
const std::string domain = "www.google.com";
IPAddress ip_address;
ip_address.init_host_port(domain, 443).ensure();
SocketFd fd = SocketFd::open(ip_address).move_as_ok();
create_actor<TlsInit>("TlsInit", std::move(fd), IPAddress(), domain, "0123456789secret",
make_unique<Callback>(), ActorShared<>(), Clocks::system() - Time::now())
.release();
} }
}; };
IPAddress ip_address; create_actor<RunTest>("RunTest").release();
ip_address.init_host_port(domain, 443).ensure();
SocketFd fd = SocketFd::open(ip_address).move_as_ok();
create_actor<TlsInit>("TlsInit", std::move(fd), IPAddress(), domain, "0123456789secret", make_unique<Callback>(),
ActorShared<>(), Clocks::system() - Time::now())
.release();
} }
sched.start(); sched.start();