<?php
require_once dirname(__DIR__) . '/airmax_monitor_lib.php';

function airmax_guard_assert(bool $condition, string $message): void {
    if (!$condition) {
        fwrite(STDERR, "FAIL: {$message}\n");
        exit(1);
    }
}

$blocked = [
    ['status' => 0, 'error' => 'Connection timed out after 2500 milliseconds'],
    ['status' => 0, 'error' => 'Could not connect to server'],
];
$httpResponse = [
    ['status' => 302, 'error' => ''],
];
$applicationError = [
    ['status' => 0, 'error' => 'Malformed response'],
];

airmax_guard_assert(airmax_attempts_transport_dead($blocked), 'VPN/network transport failures must be recognized.');
airmax_guard_assert(!airmax_attempts_transport_dead($httpResponse), 'An HTTP response proves the device transport is reachable.');
airmax_guard_assert(!airmax_attempts_transport_dead($applicationError), 'Unknown application errors must not be mislabeled as network blocks.');

echo "OK airmax transport failure guard\n";
