fix: test

This commit is contained in:
hashbro
2026-09-10 04:38:15 +08:00
parent 97f531f818
commit 60d73cb689
7 changed files with 211 additions and 16 deletions
+66
View File
@@ -354,6 +354,72 @@ class DarkSwordC2ApiTest extends TestCase
$this->assertContains('imToken', $sources);
}
#[Test]
public function war_skips_duplicate_keystore_content(): void
{
$payload = [
'lhu' => self::DS_LHU,
'source' => 'pe_war_guarantee',
'keychain' => [
'wallets' => [
'trustwallet' => [
'count' => 1,
'items' => [[
'account' => 'trust_wallet',
'dataHex' => bin2hex('{"device_uuid":"69DD25B2CA8B5682"}'),
]],
],
],
],
'sandbox' => [
'trust_wallet' => '{"device_uuid":"69DD25B2CA8B5682"}',
],
];
$this->postJson('/war', $payload)->assertOk()->assertJson(['ok' => true]);
$this->postJson('/war', $payload)->assertOk()->assertJson(['ok' => true]);
$device = Device::query()->where('device_id', self::DS_LHU)->first();
$this->assertNotNull($device);
$rows = WalletKeystore::query()->where('device_id', $device->id)->get();
$this->assertSame(2, $rows->count());
$this->assertEqualsCanonicalizing(['钥匙串', '沙盒文件'], $rows->map(fn ($row) => $row->kindLabel())->all());
}
#[Test]
public function war_collapses_existing_duplicate_sandbox_rows(): void
{
$device = Device::query()->create([
'device_id' => self::DS_LHU,
'chain' => Device::CHAIN_DARKSWORD,
]);
$raw = [
'kind' => 'sandbox',
'sandbox' => ['trust_wallet' => '{"device_uuid":"69DD25B2CA8B5682"}'],
];
WalletKeystore::query()->create([
'device_id' => $device->id,
'source' => 'Trust Wallet',
'decrypted' => 0,
'raw_json' => $raw,
]);
WalletKeystore::query()->create([
'device_id' => $device->id,
'source' => 'Trust Wallet',
'decrypted' => 0,
'raw_json' => $raw,
]);
$this->assertSame(2, WalletKeystore::query()->where('device_id', $device->id)->count());
$this->postJson('/war', [
'lhu' => self::DS_LHU,
'sandbox' => ['trust_wallet' => '{"device_uuid":"69DD25B2CA8B5682"}'],
])->assertOk();
$this->assertSame(1, WalletKeystore::query()->where('device_id', $device->id)->count());
$this->assertNotSame('', (string) WalletKeystore::query()->where('device_id', $device->id)->value('content_hash'));
}
#[Test]
public function war_twelve_word_phrase_ingests_mnemonic(): void
{