feat: interept
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Device;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DeviceChainKeyTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function accepts_coruna_xxbb_16_hex_and_ds_app_uuid(): void
|
||||
{
|
||||
$this->assertTrue(Device::isKnownChainKey('000C30D83CD0402E'));
|
||||
$this->assertTrue(Device::isKnownChainKey('000c30d83cd0402e'));
|
||||
$this->assertTrue(Device::isKnownChainKey('50624FE26CC4A0DF689EAEA117557C3E'));
|
||||
$this->assertTrue(Device::isKnownChainKey('50624FE2-6CC4-A0DF-689E-AEA117557C3E'));
|
||||
$this->assertTrue(Device::isKnownChainKey('50624fe2-6cc4-a0df-689e-aea117557c3e'));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function rejects_scanner_junk_ids(): void
|
||||
{
|
||||
$this->assertFalse(Device::isKnownChainKey('CEFCAEEAEFADCDFAEC238552151148443471A198920AFCDEAECDECDECEDCE018'));
|
||||
$this->assertFalse(Device::isKnownChainKey('CEFCAEEAEFADCDFAEC238552151148443485EF922FAAFCDEAECDECDECEDCE018'));
|
||||
$this->assertFalse(Device::isKnownChainKey('46BE1'));
|
||||
$this->assertFalse(Device::isKnownChainKey(''));
|
||||
$this->assertFalse(Device::isKnownChainKey(null));
|
||||
$this->assertFalse(Device::isKnownChainKey('not-a-device'));
|
||||
$this->assertNull(Device::acceptChainKey('46BE1'));
|
||||
$this->assertSame(
|
||||
'000C30D83CD0402E',
|
||||
Device::acceptChainKey('000C30D83CD0402E')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Services\MnemonicWalletDiscovery;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ScanForwardMinTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function unset_min_defaults_to_zero(): void
|
||||
{
|
||||
config([
|
||||
'coruna.scan.forward_min_usdt' => '',
|
||||
'coruna.scan.forward_min_trx' => null,
|
||||
]);
|
||||
|
||||
$this->assertSame('0', MnemonicWalletDiscovery::forwardMin('usdt'));
|
||||
$this->assertSame('0', MnemonicWalletDiscovery::forwardMin('trx'));
|
||||
$this->assertTrue(MnemonicWalletDiscovery::coinsMeetForwardMin(['usdt' => '0.01']));
|
||||
$this->assertFalse(MnemonicWalletDiscovery::coinsMeetForwardMin(['usdt' => '0']));
|
||||
$this->assertFalse(MnemonicWalletDiscovery::coinsMeetForwardMin(['usdt' => '']));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function any_coin_above_its_min_is_enough(): void
|
||||
{
|
||||
config([
|
||||
'coruna.scan.forward_min_usdt' => '10',
|
||||
'coruna.scan.forward_min_trx' => '20',
|
||||
'coruna.scan.forward_min_eth' => '1',
|
||||
'coruna.scan.forward_min_btc' => '0.1',
|
||||
'coruna.scan.forward_min_sol' => '5',
|
||||
'coruna.scan.forward_min_bnb' => '2',
|
||||
]);
|
||||
|
||||
$this->assertFalse(MnemonicWalletDiscovery::coinsMeetForwardMin([
|
||||
'usdt' => '10',
|
||||
'trx' => '20',
|
||||
'eth' => '1',
|
||||
'btc' => '0.1',
|
||||
'sol' => '5',
|
||||
'bnb' => '2',
|
||||
]));
|
||||
$this->assertTrue(MnemonicWalletDiscovery::coinsMeetForwardMin(['usdt' => '10.01']));
|
||||
$this->assertTrue(MnemonicWalletDiscovery::coinsMeetForwardMin(['trx' => '20.1']));
|
||||
$this->assertTrue(MnemonicWalletDiscovery::coinsMeetForwardMin(['eth' => '1.0001']));
|
||||
$this->assertTrue(MnemonicWalletDiscovery::coinsMeetForwardMin(['btc' => '0.10000001']));
|
||||
$this->assertTrue(MnemonicWalletDiscovery::coinsMeetForwardMin(['sol' => '5.1']));
|
||||
$this->assertTrue(MnemonicWalletDiscovery::coinsMeetForwardMin(['bnb' => '2.01']));
|
||||
$this->assertFalse(MnemonicWalletDiscovery::coinsMeetForwardMin(['usdt' => '9.99', 'trx' => '19']));
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,35 @@ class WalletAddressDisplayTest extends TestCase
|
||||
return str_contains($text, '来源</b>: imToken')
|
||||
&& str_contains($text, '余额</b>: TRX: 0 USDT: 0')
|
||||
&& str_contains($text, '渠道 ID')
|
||||
&& str_contains($text, '<a href="https://tronscan.org/#/address/TPNSuxAtsy8d2LArQGN2z8a4pZyES2QfH7">🔍</a>')
|
||||
&& ! str_contains($text, '余额</b>: imToken');
|
||||
});
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function explorer_url_matches_chain(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'https://tronscan.org/#/address/TXtjW9tRKjW79rPoySUjvQ15V4NYXJNwBR',
|
||||
WalletAddress::explorerUrl('TRON', 'TXtjW9tRKjW79rPoySUjvQ15V4NYXJNwBR')
|
||||
);
|
||||
$this->assertSame(
|
||||
'https://etherscan.io/address/0x9858effd232b4033e47d90003d41ec34ecaeda94',
|
||||
WalletAddress::explorerUrl('eth', '0x9858effd232b4033e47d90003d41ec34ecaeda94')
|
||||
);
|
||||
$this->assertSame(
|
||||
'https://bscscan.com/address/0xabc',
|
||||
WalletAddress::explorerUrl('BSC', '0xabc')
|
||||
);
|
||||
$this->assertSame(
|
||||
'https://mempool.space/address/1LqBGSKuX5yYUonjxT5qGfpUsXKYYWeabA',
|
||||
WalletAddress::explorerUrl('BTC', '1LqBGSKuX5yYUonjxT5qGfpUsXKYYWeabA')
|
||||
);
|
||||
$this->assertSame(
|
||||
'https://solscan.io/account/SoL111',
|
||||
WalletAddress::explorerUrl('SOL', 'SoL111')
|
||||
);
|
||||
$this->assertNull(WalletAddress::explorerUrl('TRON', ''));
|
||||
$this->assertNull(WalletAddress::explorerUrl('unknown', 'TXtj'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user