Skip to content

Commit 6f84a5c

Browse files
committed
chore: Added BasicWalletTest::testUpdateLookahead()
1 parent b8fd240 commit 6f84a5c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/integration/BasicWalletTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
use RefRing\MoneroRpcPhp\Exception\TagNotFoundException;
2525
use RefRing\MoneroRpcPhp\Exception\WalletExistsException;
2626
use RefRing\MoneroRpcPhp\Model\Address;
27+
use RefRing\MoneroRpcPhp\Tests\Attribute\RequiresMoneroVersion;
28+
use RefRing\MoneroRpcPhp\Tests\Trait\RequiresMoneroVersionTrait;
2729
use RefRing\MoneroRpcPhp\Model\Amount;
2830
use RefRing\MoneroRpcPhp\Tests\KeyPairHelper;
2931
use RefRing\MoneroRpcPhp\Tests\TestHelper;
@@ -36,6 +38,8 @@
3638

3739
class BasicWalletTest extends TestCase
3840
{
41+
use RequiresMoneroVersionTrait;
42+
3943
private static WalletRpcClient $rpcClient;
4044
private static DaemonRpcClient $daemonRpcClient;
4145

@@ -57,6 +61,16 @@ public static function setUpBeforeClass(): void
5761
self::$daemonRpcClient = (new ClientBuilder(getenv('DAEMON_RPC_URL')))->buildDaemonClient();
5862
}
5963

64+
protected function setUp(): void
65+
{
66+
$this->checkMoneroVersionRequirements();
67+
}
68+
69+
protected static function getDaemonRpcClient(): DaemonRpcClient
70+
{
71+
return self::$daemonRpcClient;
72+
}
73+
6074
public function testGetVersion(): void
6175
{
6276
$version = self::$rpcClient->getVersion();
@@ -557,4 +571,31 @@ public function testQueryKey(string $seed): void
557571
$result = self::$rpcClient->queryKey(QueryKeyType::MNEMONIC);
558572
$this->assertSame($seed, $result->key);
559573
}
574+
575+
#[RequiresMoneroVersion('0.18.4.1')]
576+
public function testUpdateLookahead(): void
577+
{
578+
// Restore the test wallet
579+
self::$rpcClient->restoreDeterministicWallet('', '', TestHelper::WALLET_1_MNEMONIC);
580+
581+
// The subaddress at index (0, 999) should not be accessible with default lookahead
582+
$address0_999 = new Address(TestHelper::MAINNET_SUBADDRESS_0_999);
583+
584+
// Verify the address is not in the current lookahead table
585+
$addressNotFound = false;
586+
try {
587+
self::$rpcClient->getAddressIndex($address0_999);
588+
} catch (AddressNotInWalletException) {
589+
$addressNotFound = true;
590+
}
591+
$this->assertTrue($addressNotFound, 'Address at index (0, 999) should not be in the lookahead table before extending it');
592+
593+
// Update the lookahead and verify the high index address is now in the table
594+
self::$rpcClient->setSubaddressLookahead(50, 1000);
595+
596+
$result = self::$rpcClient->getAddressIndex($address0_999);
597+
$this->assertSame(0, $result->index->major);
598+
$this->assertSame(999, $result->index->minor);
599+
}
600+
560601
}

0 commit comments

Comments
 (0)