feat: quene
This commit is contained in:
@@ -248,6 +248,65 @@ class TokenviewWebhookTest extends TestCase
|
||||
});
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function webhook_notifies_native_trx_when_token_symbol_omitted(): void
|
||||
{
|
||||
config(['coruna.tokenview.sign_key' => '']);
|
||||
Http::fake(function ($request) {
|
||||
$url = $request->url();
|
||||
if (str_contains($url, '/v1/accounts/')) {
|
||||
return Http::response([
|
||||
'data' => [[
|
||||
'balance' => 12_000_000,
|
||||
'trc20' => [],
|
||||
]],
|
||||
'success' => true,
|
||||
], 200);
|
||||
}
|
||||
if (str_contains($url, 'api.telegram.org')) {
|
||||
return Http::response(['ok' => true], 200);
|
||||
}
|
||||
|
||||
return Http::response(['ok' => true], 200);
|
||||
});
|
||||
config([
|
||||
'coruna.telegram.bot_token' => 'bot-token',
|
||||
'coruna.telegram.owner_chat_id' => '12345',
|
||||
]);
|
||||
|
||||
$addr = $this->seedMonitoredAddress([
|
||||
'address' => 'TWVpqZyczbccBtNNsV8aRmBRfETZBxRkNL',
|
||||
'chain_type' => 'TRON',
|
||||
'trx' => 15.0,
|
||||
'usdt' => 0,
|
||||
'eth' => null,
|
||||
]);
|
||||
|
||||
$payload = [
|
||||
'address' => 'TWVpqZyczbccBtNNsV8aRmBRfETZBxRkNL',
|
||||
'txid' => '02af07be47430d0b1db32962f3036ff75afc1114444a928c44e258cd332c0d0e',
|
||||
'time' => 1788200361,
|
||||
'confirmations' => 1,
|
||||
'value' => '-3',
|
||||
'coin' => 'TRX',
|
||||
'height' => 85842934,
|
||||
'network' => 'TRX',
|
||||
];
|
||||
|
||||
$this->postJson('/hooks/tokenview', $payload)->assertOk()->assertSee('ok');
|
||||
|
||||
$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, '-3 TRX');
|
||||
});
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function webhook_ignores_tron_when_token_is_not_trx_or_usdt(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user