mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 06:59:01 +01:00
Add handshake test
This commit is contained in:
parent
7619a035a5
commit
9c6adbd24a
@ -35,4 +35,5 @@ steps:
|
||||
- TAG=${CI_COMMIT_TAG}
|
||||
commands:
|
||||
- apk add bash
|
||||
- php tests/handshake.php
|
||||
- tests/test.sh
|
@ -51,7 +51,7 @@
|
||||
"danog/ipc": "^1",
|
||||
"amphp/log": "^2",
|
||||
"danog/loop": "^1",
|
||||
"phpseclib/phpseclib": "^3",
|
||||
"phpseclib/phpseclib": "^3.0.22",
|
||||
"amphp/redis": "^2",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/log": "^3",
|
||||
@ -79,7 +79,8 @@
|
||||
"ext-pdo": "Install the pdo extension to store session data on MySQL",
|
||||
"ext-openssl": "Install the openssl extension for faster crypto",
|
||||
"ext-uv": "Install the uv extension to greatly speed up MadelineProto!",
|
||||
"ext-gmp": "Install the gmp extension to speed up authorization"
|
||||
"ext-gmp": "Install the gmp extension to speed up authorization",
|
||||
"ext-bcmath": "Install the bcmath extension to speed up authorization"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
|
@ -542,20 +542,6 @@ final class MTProto implements TLCallback, LoggerGetter
|
||||
$this->startLoops();
|
||||
$this->datacenter->currentDatacenter = $this->settings->getConnection()->getTestMode() ? 10002 : 2;
|
||||
$this->getConfig();
|
||||
if ((!isset($this->authorization['user']['bot']) || !$this->authorization['user']['bot']) && $this->datacenter->getDataCenterConnection($this->datacenter->currentDatacenter)->hasTempAuthKey()) {
|
||||
try {
|
||||
$nearest_dc = $this->methodCallAsyncRead('help.getNearestDc', []);
|
||||
$this->logger->logger(\sprintf(Lang::$current_lang['nearest_dc'], $nearest_dc['country'], $nearest_dc['nearest_dc']), Logger::NOTICE);
|
||||
if ($nearest_dc['nearest_dc'] != $nearest_dc['this_dc']) {
|
||||
$this->authorized_dc = $this->datacenter->currentDatacenter = (int) $nearest_dc['nearest_dc'];
|
||||
}
|
||||
} catch (RPCErrorException $e) {
|
||||
if ($e->rpc !== 'BOT_METHOD_INVALID') {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->getConfig();
|
||||
$this->startUpdateSystem(true);
|
||||
$this->v = self::V;
|
||||
|
||||
|
17
tests/handshake.php
Normal file
17
tests/handshake.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use danog\MadelineProto\API;
|
||||
use danog\MadelineProto\Settings\AppInfo;
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
$settings = new AppInfo;
|
||||
|
||||
// Published test API ID from https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java#L29
|
||||
// Can only be used for a handshake, login won't work, get your own @ my.telegram.org.
|
||||
|
||||
$settings->setApiId(4)->setApiHash('014b35b6184100b085b0d0572f9b5103');
|
||||
|
||||
$test = new API('/tmp/handshake_'.random_int(0, PHP_INT_MAX).'.madeline', $settings);
|
||||
var_dump($test->help->getConfig([], ['datacenter' => 4]));
|
||||
$test->logout();
|
Loading…
Reference in New Issue
Block a user