Keep Tokenview and Telegram running when log files are not writable.
Daily logs created by root cron were blocking www from appending, which aborted webhook ingest and bot pushes. File channels now use 0664 plus exception-safe stacks, and writes go through SafeLog. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -356,6 +356,47 @@ class TokenviewWebhookTest extends TestCase
|
||||
$this->assertSame(0, TokenviewEvent::query()->count());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function webhook_notifies_when_tokenview_log_is_unwritable(): void
|
||||
{
|
||||
config(['coruna.tokenview.sign_key' => '']);
|
||||
Http::fake([
|
||||
'api.telegram.org/*' => Http::response(['ok' => true], 200),
|
||||
]);
|
||||
config([
|
||||
'coruna.telegram.bot_token' => 'bot-token',
|
||||
'coruna.telegram.owner_chat_id' => '12345',
|
||||
]);
|
||||
|
||||
$dir = $this->forceLogChannelUnwritable('tokenview');
|
||||
$addr = $this->seedMonitoredAddress();
|
||||
$payload = [
|
||||
'address' => $addr->address,
|
||||
'txid' => '0xlog-denied-'.str_repeat('a', 50),
|
||||
'coin' => 'ETH',
|
||||
'value' => '0.25',
|
||||
];
|
||||
|
||||
try {
|
||||
$this->postJson('/hooks/tokenview', $payload)->assertOk()->assertSee('ok');
|
||||
} finally {
|
||||
$this->restoreWritableLogDir($dir);
|
||||
}
|
||||
|
||||
$addr->refresh();
|
||||
$this->assertEqualsWithDelta(1.25, (float) $addr->eth, 0.0000001);
|
||||
$this->assertSame(1, TokenviewEvent::query()->count());
|
||||
Http::assertSent(function ($request) {
|
||||
if (! str_contains($request->url(), 'api.telegram.org')) {
|
||||
return false;
|
||||
}
|
||||
$text = (string) ($request->data()['text'] ?? '');
|
||||
|
||||
return str_contains($text, '余额入账')
|
||||
&& str_contains($text, '+0.25 ETH');
|
||||
});
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function monitor_toggle_calls_tokenview_add_and_remove(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user