fix: link memo
This commit is contained in:
@@ -152,10 +152,31 @@ class MnemonicAddressLinkTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function derive_index_beyond_four_is_not_linked(): void
|
||||
public function derive_index_nine_is_linked(): void
|
||||
{
|
||||
$device = $this->makeDevice('dev-link-4a');
|
||||
$tron = (new TronDriver)->deriveAddress(self::MNEMONIC, 9);
|
||||
|
||||
$addr = WalletAddress::query()->create([
|
||||
'device_id' => $device->id,
|
||||
'address' => $tron,
|
||||
'chain_type' => 'TRON',
|
||||
'source' => 'imToken',
|
||||
'monitor' => 0,
|
||||
]);
|
||||
$mnemonic = $this->storeMnemonic($device);
|
||||
|
||||
$this->assertTrue(app(MnemonicAddressLinker::class)->linkAddress($addr));
|
||||
$addr->refresh();
|
||||
$this->assertSame($mnemonic->id, $addr->mnemonic_id);
|
||||
$this->assertSame(9, $addr->derive_index);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function derive_index_beyond_nine_is_not_linked(): void
|
||||
{
|
||||
$device = $this->makeDevice('dev-link-4');
|
||||
$tron = (new TronDriver)->deriveAddress(self::MNEMONIC, 5);
|
||||
$tron = (new TronDriver)->deriveAddress(self::MNEMONIC, 10);
|
||||
|
||||
$addr = WalletAddress::query()->create([
|
||||
'device_id' => $device->id,
|
||||
@@ -278,7 +299,7 @@ class MnemonicAddressLinkTest extends TestCase
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function backfill_derives_index_zero_when_mnemonic_has_no_addresses(): void
|
||||
public function backfill_skips_inactive_derived_addresses(): void
|
||||
{
|
||||
$device = Device::query()->create(['device_id' => 'dev-backfill-derive']);
|
||||
$mnemonic = new WalletMnemonic([
|
||||
@@ -289,20 +310,10 @@ class MnemonicAddressLinkTest extends TestCase
|
||||
$mnemonic->save();
|
||||
|
||||
$this->artisan('coruna:link-mnemonics')
|
||||
->expectsOutputToContain('linked=0 discovered=3')
|
||||
->expectsOutputToContain('linked=0 discovered=0')
|
||||
->assertSuccessful();
|
||||
|
||||
$rows = WalletAddress::query()
|
||||
->where('mnemonic_id', $mnemonic->id)
|
||||
->orderBy('id')
|
||||
->get();
|
||||
$this->assertCount(3, $rows);
|
||||
$this->assertSame(['TRON', 'ETH', 'BTC'], $rows->pluck('chain_type')->all());
|
||||
$this->assertSame([
|
||||
self::TRON_0,
|
||||
self::ETH_0,
|
||||
'1LqBGSKuX5yYUonjxT5qGfpUsXKYYWeabA',
|
||||
], $rows->pluck('address')->all());
|
||||
$this->assertSame([0, 0, 0], $rows->pluck('derive_index')->all());
|
||||
$this->assertSame(0, WalletAddress::query()->where('mnemonic_id', $mnemonic->id)->count());
|
||||
$this->assertSame(0, WalletAddress::query()->where('device_id', $device->id)->count());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user