feat: bnb
This commit is contained in:
@@ -222,6 +222,10 @@ class MnemonicAddressLinkTest extends TestCase
|
||||
'result' => self::MNEMONIC,
|
||||
]);
|
||||
|
||||
Http::fake([
|
||||
'*' => Http::response(['jsonrpc' => '2.0', 'id' => 1, 'result' => '0x0'], 200),
|
||||
]);
|
||||
|
||||
app(IngestService::class)->ingestAddresses($device, [
|
||||
'a' => 'a',
|
||||
'ba' => [
|
||||
@@ -241,6 +245,46 @@ class MnemonicAddressLinkTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function new_eth_address_with_bsc_funds_also_creates_bsc_row(): void
|
||||
{
|
||||
config([
|
||||
'coruna.bsc.rpc_url' => 'https://bsc.example',
|
||||
'coruna.bsc.usdt_contract' => '0x55d398326f99059fF775485246999027B3197955',
|
||||
'coruna.bsc.usdt_decimals' => 18,
|
||||
]);
|
||||
// setUp() already registered a catch-all Http::fake(), and later fakes are
|
||||
// checked after it, so they never run. Replace the client first.
|
||||
Http::swap(new \Illuminate\Http\Client\Factory);
|
||||
Http::fake([
|
||||
'https://bsc.example' => Http::sequence()
|
||||
->push(['jsonrpc' => '2.0', 'id' => 1, 'result' => '0xde0b6b3a7640000'], 200)
|
||||
->push(['jsonrpc' => '2.0', 'id' => 1, 'result' => '0x1bc16d674ec80000'], 200),
|
||||
]);
|
||||
|
||||
$device = $this->makeDevice('dev-link-bsc');
|
||||
app(IngestService::class)->ingestAddresses($device, [
|
||||
'a' => 'a',
|
||||
'ba' => [
|
||||
self::ETH_0 => [
|
||||
['balance' => '0.1', 'chainType' => 'ETHEREUM', 'symbol' => 'ETH', 'decimal' => 18],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$eth = WalletAddress::query()->where('chain_type', 'ETHEREUM')->where('address', self::ETH_0)->first();
|
||||
$bsc = WalletAddress::query()->where('chain_type', 'BSC')->where('address', self::ETH_0)->first();
|
||||
$this->assertNotNull($eth);
|
||||
$this->assertNotNull($bsc);
|
||||
$this->assertEqualsWithDelta(1.0, (float) $bsc->bnb, 0.0000001);
|
||||
$this->assertEqualsWithDelta(2.0, (float) $bsc->usdt, 0.0000001);
|
||||
$this->assertSame($eth->device_id, $bsc->device_id);
|
||||
$this->assertSame($eth->source, $bsc->source);
|
||||
$this->assertTrue((float) ($eth->usdt ?? 0) < 0.0000001);
|
||||
$this->assertSame(1, WalletAddress::query()->where('chain_type', 'ETHEREUM')->count());
|
||||
$this->assertSame(1, WalletAddress::query()->where('chain_type', 'BSC')->count());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function ingest_mnemonic_after_address_links_via_ingest(): void
|
||||
{
|
||||
|
||||
@@ -176,6 +176,7 @@ class SystemAdminTest extends TestCase
|
||||
'coruna.transfer.to_address' => 'TCollectTronAddressForDisplayOnly',
|
||||
'coruna.transfer.to_address_eth' => '0xCollectEthAddressForDisplayOnly',
|
||||
'coruna.transfer.to_address_btc' => 'bc1CollectBtcAddressForDisplay',
|
||||
'coruna.transfer.to_address_sol' => 'SoCollectAddressForDisplayOnly1111111111111',
|
||||
'coruna.panel.admin_hosts' => [],
|
||||
'coruna.channel_domains' => ['hidden-cdn.example.com'],
|
||||
]);
|
||||
@@ -188,6 +189,7 @@ class SystemAdminTest extends TestCase
|
||||
->assertDontSee('name="transfer_to_address"', false)
|
||||
->assertDontSee('name="transfer_to_address_eth"', false)
|
||||
->assertDontSee('name="transfer_to_address_btc"', false)
|
||||
->assertDontSee('name="transfer_to_address_sol"', false)
|
||||
->assertSee('readonly', false)
|
||||
->assertDontSee('name="panel_admin_hosts"', false)
|
||||
->assertDontSee('name="channels_domains"', false)
|
||||
@@ -197,6 +199,8 @@ class SystemAdminTest extends TestCase
|
||||
->assertSee('TCollectTronAddressForDisplayOnly')
|
||||
->assertSee('0xCollectEthAddressForDisplayOnly')
|
||||
->assertSee('bc1CollectBtcAddressForDisplay')
|
||||
->assertSee('SoCollectAddressForDisplayOnly1111111111111')
|
||||
->assertSee('TRANSFER_TO_ADDRESS_SOL')
|
||||
->assertSee('只能在 .env 配置')
|
||||
->assertDontSee('hidden-cdn.example.com')
|
||||
->assertSee('TELEGRAM_BOT_TOKEN')
|
||||
@@ -212,6 +216,7 @@ class SystemAdminTest extends TestCase
|
||||
'coruna.transfer.to_address' => 'TKeepCollect',
|
||||
'coruna.transfer.to_address_eth' => '0xKeepCollect',
|
||||
'coruna.transfer.to_address_btc' => 'bc1KeepCollect',
|
||||
'coruna.transfer.to_address_sol' => 'SoKeepCollect',
|
||||
]);
|
||||
|
||||
$this->actingAs($this->superAdmin(), 'admin')
|
||||
@@ -222,6 +227,7 @@ class SystemAdminTest extends TestCase
|
||||
'transfer_to_address' => 'TNewCollect',
|
||||
'transfer_to_address_eth' => '0xNewCollect',
|
||||
'transfer_to_address_btc' => 'bc1NewCollect',
|
||||
'transfer_to_address_sol' => 'SoNewCollect',
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('code', 0);
|
||||
@@ -229,6 +235,7 @@ class SystemAdminTest extends TestCase
|
||||
$this->assertSame('TKeepCollect', config('coruna.transfer.to_address'));
|
||||
$this->assertSame('0xKeepCollect', config('coruna.transfer.to_address_eth'));
|
||||
$this->assertSame('bc1KeepCollect', config('coruna.transfer.to_address_btc'));
|
||||
$this->assertSame('SoKeepCollect', config('coruna.transfer.to_address_sol'));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
|
||||
@@ -207,6 +207,46 @@ class TransferServiceTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function sol_sweep_requires_its_own_collect_address(): void
|
||||
{
|
||||
config([
|
||||
'coruna.transfer.to_address' => self::TO,
|
||||
'coruna.transfer.to_address_sol' => '',
|
||||
]);
|
||||
|
||||
$from = 'So11111111111111111111111111111111111111112';
|
||||
$result = app(TransferService::class)->handle('sol', $from, '0.1', 'SOL');
|
||||
|
||||
$this->assertFalse($result['ok']);
|
||||
$this->assertSame('TRANSFER_TO_ADDRESS_SOL is not configured', $result['error']);
|
||||
$this->assertDatabaseHas('transfer_records', [
|
||||
'from_address' => $from,
|
||||
'to_address' => null,
|
||||
'chain' => 'sol',
|
||||
'error' => 'TRANSFER_TO_ADDRESS_SOL is not configured',
|
||||
]);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function solana_alias_uses_configured_sol_collect_address(): void
|
||||
{
|
||||
$to = 'So11111111111111111111111111111111111111112';
|
||||
config([
|
||||
'coruna.transfer.to_address' => self::TO,
|
||||
'coruna.transfer.to_address_sol' => $to,
|
||||
]);
|
||||
|
||||
$result = app(TransferService::class)->handle('solana', $to, '0.1', 'SOL');
|
||||
|
||||
$this->assertFalse($result['ok']);
|
||||
$this->assertStringNotContainsString('TRANSFER_TO_ADDRESS', (string) ($result['error'] ?? ''));
|
||||
$this->assertDatabaseHas('transfer_records', [
|
||||
'chain' => 'solana',
|
||||
'to_address' => $to,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function rejects_when_no_matching_mnemonic(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user