Skip to content

Commit 568d730

Browse files
test: add tests for single-descriptor wallets
1 parent 77c6e0a commit 568d730

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/src/test/kotlin/org/bitcoindevkit/CreatingWalletTest.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ class CreatingWalletTest {
2929
)
3030
}
3131

32+
@Test
33+
fun `Create a wallet with a single descriptor`() {
34+
Wallet.createSingle(
35+
descriptor = TEST_BIP84_DESCRIPTOR,
36+
network = Network.TESTNET4,
37+
persister = conn
38+
)
39+
}
40+
3241
@Test
3342
fun `Create a wallet with a non-extended descriptor`() {
3443
Wallet(

lib/src/test/kotlin/org/bitcoindevkit/WalletTest.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,24 @@ class WalletTest {
4040
actual = wallet.balance().total.toSat()
4141
)
4242
}
43+
44+
// Single-descriptor wallets return an address on the external keychain even if a change descriptor is not provided
45+
// and the wallet.revealNextAddress(KeychainKind.INTERNAL) or wallet.peekAddress(KeychainKind.EXTERNAL, 0u) APIs are
46+
// used.
47+
@Test
48+
fun `Single-descriptor wallets can create addresses`() {
49+
val wallet: Wallet = Wallet.createSingle(
50+
descriptor = TEST_BIP84_DESCRIPTOR,
51+
network = Network.TESTNET4,
52+
persister = conn
53+
)
54+
val address1 = wallet.peekAddress(KeychainKind.EXTERNAL, 0u)
55+
val address2 = wallet.peekAddress(KeychainKind.INTERNAL, 0u)
56+
57+
assertEquals(
58+
expected = address1.address,
59+
actual = address2.address,
60+
message = "Addresses should be the same"
61+
)
62+
}
4363
}

0 commit comments

Comments
 (0)