feat: 查看钱包优化,地址增加链上查询
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Models\WalletAddress;
|
||||
use App\Models\WalletMnemonic;
|
||||
use App\Services\Chain\TronDriver;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
@@ -18,6 +19,12 @@ class MnemonicWalletsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Cache::flush();
|
||||
}
|
||||
|
||||
private function storeMnemonic(Device $device, string $source = 'imToken'): WalletMnemonic
|
||||
{
|
||||
$row = new WalletMnemonic([
|
||||
@@ -173,6 +180,7 @@ class MnemonicWalletsTest extends TestCase
|
||||
]],
|
||||
'success' => true,
|
||||
], 200),
|
||||
'*' => Http::response([], 404),
|
||||
]);
|
||||
|
||||
$admin = Admin::query()->create(['username' => 'admin', 'password' => 'admin123']);
|
||||
@@ -222,6 +230,16 @@ class MnemonicWalletsTest extends TestCase
|
||||
->getJson(route('admin.mnemonics.wallets', $mnemonic))
|
||||
->assertOk()
|
||||
->assertJsonPath('code', 0)
|
||||
->assertJsonPath('data.updating', true)
|
||||
->assertJsonPath('data.addresses.0.persisted', false);
|
||||
|
||||
$this->assertSame(0, WalletAddress::query()->where('mnemonic_id', $mnemonic->id)->count());
|
||||
|
||||
$this->actingAs($admin, 'admin')
|
||||
->postJson(route('admin.mnemonics.wallets.refresh', $mnemonic))
|
||||
->assertOk()
|
||||
->assertJsonPath('code', 0)
|
||||
->assertJsonPath('data.updating', false)
|
||||
->assertJsonPath('data.addresses.0.address', 'TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH')
|
||||
->assertJsonPath('data.addresses.0.chain_type', 'TRON')
|
||||
->assertJsonPath('data.addresses.0.trx', '5')
|
||||
@@ -256,7 +274,7 @@ class MnemonicWalletsTest extends TestCase
|
||||
$mnemonic = $this->storeMnemonic($device);
|
||||
|
||||
$this->actingAs($admin, 'admin')
|
||||
->getJson(route('admin.mnemonics.wallets', $mnemonic))
|
||||
->postJson(route('admin.mnemonics.wallets.refresh', $mnemonic))
|
||||
->assertOk()
|
||||
->assertJsonPath('code', 0)
|
||||
->assertJsonPath('data.addresses.0.address', $tron2)
|
||||
@@ -290,10 +308,13 @@ class MnemonicWalletsTest extends TestCase
|
||||
$this->actingAs($admin, 'admin')
|
||||
->getJson(route('admin.mnemonics.wallets', $mnemonic))
|
||||
->assertOk()
|
||||
->assertJsonPath('code', 0)
|
||||
->assertJsonPath('data.addresses.0.active', false)
|
||||
->assertJsonPath('data.addresses.0.persisted', false)
|
||||
->assertJsonCount(3, 'data.addresses');
|
||||
->assertJsonPath('data.updating', true)
|
||||
->assertJsonPath('data.addresses.0.persisted', false);
|
||||
|
||||
$this->actingAs($admin, 'admin')
|
||||
->postJson(route('admin.mnemonics.wallets.refresh', $mnemonic))
|
||||
->assertOk()
|
||||
->assertJsonPath('code', 0);
|
||||
|
||||
$this->assertSame(0, WalletAddress::query()->where('mnemonic_id', $mnemonic->id)->count());
|
||||
$this->assertDatabaseMissing('wallet_addresses', [
|
||||
@@ -323,10 +344,10 @@ class MnemonicWalletsTest extends TestCase
|
||||
->assertJsonPath('data.addresses.1.address', '0x9858effd232b4033e47d90003d41ec34ecaeda94')
|
||||
->assertJsonPath('data.addresses.1.chain_type', 'ETH')
|
||||
->assertJsonPath('data.addresses.1.active', false)
|
||||
->assertJsonPath('data.addresses.2.address', '1LqBGSKuX5yYUonjxT5qGfpUsXKYYWeabA')
|
||||
->assertJsonPath('data.addresses.2.chain_type', 'BTC')
|
||||
->assertJsonPath('data.addresses.2.active', false)
|
||||
->assertJsonCount(3, 'data.addresses');
|
||||
->assertJsonPath('data.addresses.2.chain_type', 'BSC')
|
||||
->assertJsonPath('data.addresses.3.address', '1LqBGSKuX5yYUonjxT5qGfpUsXKYYWeabA')
|
||||
->assertJsonPath('data.addresses.3.chain_type', 'BTC')
|
||||
->assertJsonPath('data.addresses.3.active', false);
|
||||
|
||||
$this->assertSame(0, WalletAddress::query()->where('device_id', $device->id)->count());
|
||||
$this->assertSame(0, WalletAddress::query()->where('mnemonic_id', $mnemonic->id)->count());
|
||||
|
||||
Reference in New Issue
Block a user