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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user