mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-26 17:04:39 +01:00
Improve tests
This commit is contained in:
parent
47eac0ac20
commit
7394ecfa79
@ -29,6 +29,25 @@ steps:
|
||||
event:
|
||||
- tag
|
||||
- push
|
||||
secrets:
|
||||
- API_ID
|
||||
- API_HASH
|
||||
- BOT_TOKEN
|
||||
- DEST
|
||||
environment:
|
||||
- PHP_VERSION=${php}
|
||||
- PLATFORM=${platform}
|
||||
- TAG=${CI_COMMIT_TAG}
|
||||
commands:
|
||||
- apk add bash
|
||||
- tests/test.sh
|
||||
- php tests/handshake.php
|
||||
- composer test
|
||||
test_pr:
|
||||
group: test
|
||||
image: danog/madelineproto:next
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
environment:
|
||||
- PHP_VERSION=${php}
|
||||
|
@ -110,7 +110,8 @@
|
||||
"build": [
|
||||
"@docs",
|
||||
"@docs-fix",
|
||||
"@cs-fix"
|
||||
"@cs-fix",
|
||||
"@psalm"
|
||||
],
|
||||
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php -d pcre.jit=0 vendor/bin/php-cs-fixer fix -v",
|
||||
"psalm": "psalm --no-cache --threads=10",
|
||||
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace danog\MadelineProto\Test;
|
||||
|
||||
use Amp\Process\Process;
|
||||
use Amp\Socket\InternetAddress;
|
||||
use danog\MadelineProto\API;
|
||||
use danog\MadelineProto\Logger;
|
||||
@ -27,6 +28,7 @@ use React\EventLoop\Loop;
|
||||
use React\Socket\ServerInterface;
|
||||
use Throwable;
|
||||
|
||||
use function Amp\ByteStream\splitLines;
|
||||
use function Amp\delay;
|
||||
|
||||
\define('MADELINEPROTO_TEST', 'pony');
|
||||
@ -36,8 +38,7 @@ final class DataCenterTest extends TestCase
|
||||
{
|
||||
private static API $main;
|
||||
private static API $test;
|
||||
private static LeProxyServer $proxy;
|
||||
private static ServerInterface $proxySocket;
|
||||
private static Process $proxy;
|
||||
private static InternetAddress $proxyEndpoint;
|
||||
|
||||
private static function getBaseSettings(bool $test): Settings
|
||||
@ -61,9 +62,11 @@ final class DataCenterTest extends TestCase
|
||||
if (isset(self::$proxy)) {
|
||||
return;
|
||||
}
|
||||
self::$proxy = new LeProxyServer(Loop::get());
|
||||
self::$proxySocket = self::$proxy->listen('127.0.0.1:0', false);
|
||||
self::$proxyEndpoint = InternetAddress::fromString(str_replace('tcp://', '', self::$proxySocket->getAddress()));
|
||||
self::$proxy = Process::start([PHP_BINARY, __DIR__.'/../../../vendor-bin/leproxy/proxy.php']);
|
||||
foreach (splitLines(self::$proxy->getStdout()) as $addr) {
|
||||
break;
|
||||
}
|
||||
self::$proxyEndpoint = InternetAddress::fromString(str_replace('tcp://', '', $addr));
|
||||
|
||||
self::$main = new API(
|
||||
sys_get_temp_dir().'/testing_datacenter_main.madeline',
|
||||
@ -137,7 +140,8 @@ final class DataCenterTest extends TestCase
|
||||
}
|
||||
|
||||
$testedProxies = false;
|
||||
foreach ([WssStream::class, DefaultStream::class, WsStream::class] as $transport) {
|
||||
//foreach ([WssStream::class, DefaultStream::class, WsStream::class] as $transport) {
|
||||
foreach ([DefaultStream::class] as $transport) {
|
||||
foreach ([true, false] as $obfuscated) {
|
||||
if ($transport !== DefaultStream::class && !$obfuscated) {
|
||||
continue;
|
||||
|
5
vendor-bin/leproxy/composer.json
Normal file
5
vendor-bin/leproxy/composer.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"require": {
|
||||
"leproxy/leproxy": "dev-main"
|
||||
}
|
||||
}
|
13
vendor-bin/leproxy/proxy.php
Normal file
13
vendor-bin/leproxy/proxy.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
use LeProxy\LeProxy\LeProxyServer;
|
||||
use React\EventLoop\Loop;
|
||||
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
$proxy = new LeProxyServer(Loop::get());
|
||||
$proxySocket = $proxy->listen('127.0.0.1:0', false);
|
||||
|
||||
echo $proxySocket->getAddress().PHP_EOL;
|
||||
|
||||
Loop::run();
|
Loading…
Reference in New Issue
Block a user