Files
breeze/tests/telegram_entry_protocol_zi_test.sh
waozi ef0de86e02
Cloudflare Pages / Build and verify the site (push) Successful in 3m29s
Integrate Breeze desktop, Android, and app updates
Use the verified dependency lock across native hosts and bundled apps. Preserve saved styles, local app reactivation, and offline packages while integrating the latest practice, Habits, Lumi, and figure preview updates.
2026-11-20 02:24:34 -03:00

55 lines
2.3 KiB
Bash
Executable File

#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
compiler=${1:-"$root/build/packages/ziran/build/bin/ziran"}
liboqs=${2:-"$root/vendor-builds/linux/x86_64/inbe-liboqs/lib/liboqs.a"}
work=$(mktemp -d /tmp/inbe-telegram-entry-protocol.XXXXXX)
trap 'rm -rf "$work"' EXIT HUP INT TERM
unset DISPLAY WAYLAND_DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS
export YUE_DESKTOP_RECOVERY=0
cd "$root"
"$compiler" build --project --offline ${PACKAGE_FLAGS:-} --target=c --define PLATFORM_DESKTOP --root "$root/tests" \
--entry telegram_entry_protocol_behavior:Check -o "$work/generated" \
"$root/tests/telegram_entry_protocol_behavior.zi" "$root/tests/sync_test_host.zi"
cat > "$work/generated/main.c" <<'C'
#include "telegram_entry_protocol_behavior.h"
#include <stdint.h>
#include <stdio.h>
#include <time.h>
static int64_t fixture_clock = 1700000000;
static int64_t signing_delay;
void EntryTestSetClock(int64_t now) { fixture_clock = now; signing_delay = 0; }
void EntryTestSetSigningDelay(int64_t delay) { signing_delay = delay; }
time_t __wrap_time(time_t *out)
{
time_t value = (time_t)fixture_clock;
if (out) *out = value;
return value;
}
void __real_crypto_ed25519_sign(uint8_t *, const uint8_t *, const uint8_t *, size_t);
void __wrap_crypto_ed25519_sign(uint8_t *signature, const uint8_t *key,
const uint8_t *message, size_t length)
{
__real_crypto_ed25519_sign(signature, key, message, length);
fixture_clock += signing_delay;
}
int main(void)
{
int result = Check();
if (result) fprintf(stderr, "Telegram entry protocol check failed: %d\n", result);
return result ? 1 : 0;
}
C
monocypher=$root/build/packages/monocypher/src
"${CC:-cc}" -std=c11 -O0 -ffunction-sections -fdata-sections \
-I"$root/build/packages/ziran/include" -I"$work/generated" \
-I"$root/vendor-builds/sqlite" -I"$root/vendor-builds/linux/x86_64/inbe-liboqs/include" \
-I"$monocypher" -I"$monocypher/optional" \
"$work/generated"/*.c "$root/vendor-builds/sqlite/sqlite3.c" \
"$monocypher/monocypher.c" "$monocypher/optional/monocypher-ed25519.c" \
"$liboqs" -Wl,--gc-sections -Wl,--wrap=time -Wl,--wrap=crypto_ed25519_sign \
-ldl -lpthread -lz -lm -o "$work/test"
APP_DATA_ROOT="$work/data" "$work/test"
printf '%s\n' 'Telegram entry strict parsing, canonical digest, real Ed25519 proofs and fresh clock checks passed'