feat: bnb

This commit is contained in:
hashbro
2026-09-26 12:27:12 +08:00
parent 534b36a2d2
commit ad09fdff88
23 changed files with 475 additions and 82 deletions
+10 -2
View File
@@ -63,13 +63,17 @@ class WalletBalanceServiceTest extends TestCase
$eth = \Mockery::mock(\App\Services\Chain\EthDriver::class);
$eth->shouldReceive('getNativeBalance')->once()->andReturn('1.25');
$eth->shouldReceive('getTokenBalance')->twice()->andReturn('9.5', '2.5');
$eth->shouldReceive('getTokenBalance')->once()->andReturn('9.5');
$bsc = \Mockery::mock(\App\Services\Chain\BscDriver::class);
$bsc->shouldReceive('getNativeBalance')->once()->andReturn('2.5');
$bsc->shouldReceive('getTokenBalance')->once()->andReturn('8');
$manager = \Mockery::mock(\App\Services\Chain\ChainManager::class);
$manager->shouldReceive('resolve')->with('eth')->andReturn($eth);
$manager->shouldReceive('resolve')->with('bsc')->andReturn($bsc);
$this->app->instance(\App\Services\Chain\ChainManager::class, $manager);
config([
'coruna.eth.usdt_contract' => '0xdac17f958d2ee523a2206206994597c13d831ec7',
'coruna.eth.bnb_contract' => '0xb8c77482e45f1f44de1745f52c74426c631bdd52',
'coruna.bsc.usdt_contract' => '0x55d398326f99059ff775485246999027b3197955',
]);
$device = Device::query()->create([
@@ -92,6 +96,10 @@ class WalletBalanceServiceTest extends TestCase
$this->assertEqualsWithDelta(1.25, (float) $addr->eth, 0.0000001);
$this->assertEqualsWithDelta(9.5, (float) $addr->usdt, 0.0000001);
$this->assertEqualsWithDelta(2.5, (float) $addr->bnb, 0.0000001);
$bscRow = WalletAddress::query()->where('chain_type', 'BSC')->where('device_id', $device->id)->first();
$this->assertNotNull($bscRow);
$this->assertEqualsWithDelta(2.5, (float) $bscRow->bnb, 0.0000001);
$this->assertEqualsWithDelta(8.0, (float) $bscRow->usdt, 0.0000001);
}
#[Test]