diff --git a/.woodpecker/.test.yml b/.woodpecker/.test.yml index c6031e103..fd8c9d075 100644 --- a/.woodpecker/.test.yml +++ b/.woodpecker/.test.yml @@ -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} diff --git a/composer.json b/composer.json index a68e1655e..6cbddbde7 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/tests/danog/MadelineProto/DataCenterTest.php b/tests/danog/MadelineProto/DataCenterTest.php index 9bdedeab3..41ef3690f 100644 --- a/tests/danog/MadelineProto/DataCenterTest.php +++ b/tests/danog/MadelineProto/DataCenterTest.php @@ -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; diff --git a/vendor-bin/leproxy/composer.json b/vendor-bin/leproxy/composer.json new file mode 100644 index 000000000..d466b198a --- /dev/null +++ b/vendor-bin/leproxy/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "leproxy/leproxy": "dev-main" + } +} diff --git a/vendor-bin/leproxy/proxy.php b/vendor-bin/leproxy/proxy.php new file mode 100644 index 000000000..e01f9cb54 --- /dev/null +++ b/vendor-bin/leproxy/proxy.php @@ -0,0 +1,13 @@ +listen('127.0.0.1:0', false); + +echo $proxySocket->getAddress().PHP_EOL; + +Loop::run(); \ No newline at end of file