feat: bnb

This commit is contained in:
hashbro
2026-09-25 13:10:34 +08:00
parent 13aa587099
commit 534b36a2d2
24 changed files with 242 additions and 33 deletions
+41
View File
@@ -247,6 +247,47 @@ class TelegramBotTest extends TestCase
$this->assertStringContainsString('deadbeef', $last['text'] ?? '');
}
#[Test]
public function admin_transfer_accepts_bnb_on_eth_address(): void
{
$from = '0x9858EfFD232B4033E47d90003D41EC34EcaEda94';
$mock = Mockery::mock(TransferService::class);
$mock->shouldReceive('handle')
->once()
->withArgs(function (...$args) use ($from) {
return ($args[0] ?? null) === 'eth'
&& strcasecmp((string) ($args[1] ?? ''), $from) === 0
&& ($args[2] ?? null) === '1.5'
&& ($args[3] ?? null) === 'BNB';
})
->andReturn([
'ok' => true,
'txid' => '0xbnbtx',
'from' => $from,
'to' => '0x0000000000000000000000000000000000000001',
'amount' => '1.5',
'asset' => 'BNB',
]);
$this->app->instance(TransferService::class, $mock);
/** @var FakeNutgram $bot */
$bot = app(Nutgram::class);
$bot->willReceivePartial([
'status' => ChatMemberStatus::CREATOR->value,
'user' => ['id' => self::USER_ID, 'is_bot' => false, 'first_name' => 'Owner'],
]);
$bot->hearMessage([
'text' => '/transfer '.$from.' BNB 1.5',
'chat' => ['id' => self::OWNER_CHAT, 'type' => ChatType::SUPERGROUP->value],
'from' => ['id' => self::USER_ID, 'is_bot' => false, 'first_name' => 'Owner'],
])->reply();
$bot->assertCalled('sendMessage', 2);
$history = $bot->getRequestHistory();
$last = FakeNutgram::getActualData(array_values($history[array_key_last($history)])[0]);
$this->assertStringContainsString('0xbnbtx', $last['text'] ?? '');
}
#[Test]
public function admin_data_reports_dashboard_stats(): void
{