From 3b89af5a6e14292e49e7011ecd1a28212300bb78 Mon Sep 17 00:00:00 2001 From: thunderbiscuit Date: Mon, 24 Jun 2024 10:15:46 -0400 Subject: [PATCH] test: update tests for alpha 13 release --- bdk-android/justfile | 2 +- .../org/bitcoindevkit/LiveTxBuilderTest.kt | 23 +++++------ .../org/bitcoindevkit/LiveWalletTest.kt | 28 ++++++------- .../org/bitcoindevkit/OfflineWalletTest.kt | 20 +++------- .../bitcoindevkit/LiveElectrumClientTest.kt | 22 +++++----- .../org/bitcoindevkit/LiveMemoryWalletTest.kt | 36 ++++++++--------- .../org/bitcoindevkit/LiveTransactionTests.kt | 18 ++++++--- .../org/bitcoindevkit/LiveTxBuilderTest.kt | 24 ++++++----- .../org/bitcoindevkit/LiveWalletTest.kt | 29 ++++++++------ .../org/bitcoindevkit/OfflineWalletTest.kt | 26 ++++++------ bdk-python/tests/test_live_tx_builder.py | 25 ++++++------ bdk-python/tests/test_live_wallet.py | 35 ++++++++-------- bdk-python/tests/test_offline_wallet.py | 27 ++++++------- .../LiveElectrumClientTests.swift | 25 +++++++----- .../LiveMemoryWalletTests.swift | 38 ++++++++---------- .../LiveTransactionTests.swift | 23 ++++++----- .../LiveTxBuilderTests.swift | 26 ++++++------ .../BitcoinDevKitTests/LiveWalletTests.swift | 40 +++++++++---------- .../OfflineWalletTests.swift | 29 +++++++------- 19 files changed, 245 insertions(+), 251 deletions(-) diff --git a/bdk-android/justfile b/bdk-android/justfile index 2e9a44af..b5522ff0 100644 --- a/bdk-android/justfile +++ b/bdk-android/justfile @@ -17,4 +17,4 @@ test: ./gradlew connectedAndroidTest test-specific TEST: - ./gradlew test --tests {{TEST}} \ No newline at end of file + ./gradlew test --tests {{TEST}} diff --git a/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveTxBuilderTest.kt b/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveTxBuilderTest.kt index d1bc7807..02e076bd 100644 --- a/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveTxBuilderTest.kt +++ b/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveTxBuilderTest.kt @@ -13,8 +13,9 @@ private const val TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud" @RunWith(AndroidJUnit4::class) class LiveTxBuilderTest { - private val persistenceFilePath = InstrumentationRegistry - .getInstrumentation().targetContext.filesDir.path + "/bdk_persistence3.sqlite" + private val persistenceFilePath = InstrumentationRegistry.getInstrumentation().targetContext.filesDir.path + "/bdk_persistence3.sqlite" + private val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.SIGNET) + private val changeDescriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", Network.SIGNET) @AfterTest fun cleanup() { @@ -26,16 +27,14 @@ class LiveTxBuilderTest { @Test fun testTxBuilder() { - val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.SIGNET) - val wallet = Wallet(descriptor, null, persistenceFilePath, Network.SIGNET) + val wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val esploraClient: EsploraClient = EsploraClient(SIGNET_ESPLORA_URL) val fullScanRequest: FullScanRequest = wallet.startFullScan() val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL) wallet.applyUpdate(update) - wallet.commit() - println("Balance: ${wallet.getBalance().total.toSat()}") + println("Balance: ${wallet.balance().total.toSat()}") - assert(wallet.getBalance().total.toSat() > 0uL) { + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } @@ -51,17 +50,15 @@ class LiveTxBuilderTest { @Test fun complexTxBuilder() { - val externalDescriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.SIGNET) - val changeDescriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", Network.SIGNET) - val wallet = Wallet(externalDescriptor, changeDescriptor, persistenceFilePath, Network.SIGNET) + val wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val esploraClient: EsploraClient = EsploraClient(SIGNET_ESPLORA_URL) val fullScanRequest: FullScanRequest = wallet.startFullScan() val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL) wallet.applyUpdate(update) - wallet.commit() - println("Balance: ${wallet.getBalance().total.toSat()}") - assert(wallet.getBalance().total.toSat() > 0uL) { + println("Balance: ${wallet.balance().total.toSat()}") + + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } diff --git a/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveWalletTest.kt b/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveWalletTest.kt index db8e38aa..76061b68 100644 --- a/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveWalletTest.kt +++ b/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveWalletTest.kt @@ -15,6 +15,8 @@ private const val TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud" class LiveWalletTest { private val persistenceFilePath = InstrumentationRegistry .getInstrumentation().targetContext.filesDir.path + "/bdk_persistence2.sqlite" + private val descriptor: Descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.SIGNET) + private val changeDescriptor: Descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", Network.SIGNET) @AfterTest fun cleanup() { @@ -26,18 +28,16 @@ class LiveWalletTest { @Test fun testSyncedBalance() { - val descriptor: Descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.SIGNET) - val wallet: Wallet = Wallet(descriptor, null, persistenceFilePath, Network.SIGNET) + val wallet: Wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val esploraClient: EsploraClient = EsploraClient(SIGNET_ESPLORA_URL) val fullScanRequest: FullScanRequest = wallet.startFullScan() val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL) wallet.applyUpdate(update) - wallet.commit() - println("Balance: ${wallet.getBalance().total.toSat()}") - val balance: Balance = wallet.getBalance() + println("Balance: ${wallet.balance().total.toSat()}") + val balance: Balance = wallet.balance() println("Balance: $balance") - assert(wallet.getBalance().total.toSat() > 0uL) { + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } @@ -45,7 +45,7 @@ class LiveWalletTest { val transactions = wallet.transactions().take(3) for (tx in transactions) { val sentAndReceived = wallet.sentAndReceived(tx.transaction) - println("Transaction: ${tx.transaction.txid()}") + println("Transaction: ${tx.transaction.computeTxid()}") println("Sent ${sentAndReceived.sent}") println("Received ${sentAndReceived.received}") } @@ -53,16 +53,14 @@ class LiveWalletTest { @Test fun testBroadcastTransaction() { - val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.SIGNET) - val wallet = Wallet(descriptor, null, persistenceFilePath, Network.SIGNET) + val wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val esploraClient = EsploraClient(SIGNET_ESPLORA_URL) val fullScanRequest: FullScanRequest = wallet.startFullScan() val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL) wallet.applyUpdate(update) - wallet.commit() - println("Balance: ${wallet.getBalance().total.toSat()}") + println("Balance: ${wallet.balance().total.toSat()}") - assert(wallet.getBalance().total.toSat() > 0uL) { + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } @@ -80,10 +78,10 @@ class LiveWalletTest { assertTrue(walletDidSign) val tx: Transaction = psbt.extractTx() - println("Txid is: ${tx.txid()}") + println("Txid is: ${tx.computeTxid()}") - val txFee: ULong = wallet.calculateFee(tx) - println("Tx fee is: $txFee") + val txFee: Amount = wallet.calculateFee(tx) + println("Tx fee is: ${txFee.toSat()}") val feeRate: FeeRate = wallet.calculateFeeRate(tx) println("Tx fee rate is: ${feeRate.toSatPerVbCeil()} sat/vB") diff --git a/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/OfflineWalletTest.kt b/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/OfflineWalletTest.kt index c51a4291..98e3674f 100644 --- a/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/OfflineWalletTest.kt +++ b/bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/OfflineWalletTest.kt @@ -14,6 +14,8 @@ import kotlin.test.AfterTest class OfflineWalletTest { private val persistenceFilePath = InstrumentationRegistry .getInstrumentation().targetContext.filesDir.path + "/bdk_persistence1.sqlite" + private val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET) + private val changeDescriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", Network.TESTNET) @AfterTest fun cleanup() { @@ -34,14 +36,9 @@ class OfflineWalletTest { @Test fun testNewAddress() { - val descriptor: Descriptor = Descriptor( - "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", - Network.TESTNET - ) val wallet: Wallet = Wallet( descriptor, - null, - persistenceFilePath, + changeDescriptor, Network.TESTNET ) val addressInfo: AddressInfo = wallet.revealNextAddress(KeychainKind.EXTERNAL) @@ -52,27 +49,22 @@ class OfflineWalletTest { assertFalse(addressInfo.address.isValidForNetwork(Network.BITCOIN), "Address is valid for bitcoin network, but it shouldn't be") assertEquals( - expected = "tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e", + expected = "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", actual = addressInfo.address.toString() ) } @Test fun testBalance() { - val descriptor: Descriptor = Descriptor( - "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", - Network.TESTNET - ) val wallet: Wallet = Wallet( descriptor, - null, - persistenceFilePath, + changeDescriptor, Network.TESTNET ) assertEquals( expected = 0uL, - actual = wallet.getBalance().total.toSat() + actual = wallet.balance().total.toSat() ) } } diff --git a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveElectrumClientTest.kt b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveElectrumClientTest.kt index 1da72553..fbabd7cc 100644 --- a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveElectrumClientTest.kt +++ b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveElectrumClientTest.kt @@ -5,21 +5,25 @@ import kotlin.test.Test private const val SIGNET_ELECTRUM_URL = "ssl://mempool.space:60602" class LiveElectrumClientTest { + private val descriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + Network.SIGNET + ) + private val changeDescriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + Network.SIGNET + ) + @Test fun testSyncedBalance() { - val descriptor: Descriptor = Descriptor( - "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - Network.SIGNET - ) - val wallet: Wallet = Wallet.newNoPersist(descriptor, null, Network.SIGNET) + val wallet: Wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val electrumClient: ElectrumClient = ElectrumClient(SIGNET_ELECTRUM_URL) val fullScanRequest: FullScanRequest = wallet.startFullScan() val update = electrumClient.fullScan(fullScanRequest, 10uL, 10uL, false) wallet.applyUpdate(update) - wallet.commit() - println("Balance: ${wallet.getBalance().total.toSat()}") + println("Balance: ${wallet.balance().total.toSat()}") - assert(wallet.getBalance().total.toSat() > 0uL) { + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } @@ -27,7 +31,7 @@ class LiveElectrumClientTest { val transactions = wallet.transactions().take(3) for (tx in transactions) { val sentAndReceived = wallet.sentAndReceived(tx.transaction) - println("Transaction: ${tx.transaction.txid()}") + println("Transaction: ${tx.transaction.computeTxid()}") println("Sent ${sentAndReceived.sent.toSat()}") println("Received ${sentAndReceived.received.toSat()}") } diff --git a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveMemoryWalletTest.kt b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveMemoryWalletTest.kt index 20387532..a99c09dd 100644 --- a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveMemoryWalletTest.kt +++ b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveMemoryWalletTest.kt @@ -6,6 +6,14 @@ private const val SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net" private const val TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud" class LiveMemoryWalletTest { + private val descriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + Network.SIGNET + ) + private val changeDescriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + Network.SIGNET + ) @Test fun testSyncedBalance() { @@ -13,15 +21,14 @@ class LiveMemoryWalletTest { "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.SIGNET ) - val wallet: Wallet = Wallet.newNoPersist(descriptor, null, Network.SIGNET) + val wallet: Wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val esploraClient: EsploraClient = EsploraClient(SIGNET_ESPLORA_URL) val fullScanRequest: FullScanRequest = wallet.startFullScan() val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL) wallet.applyUpdate(update) - wallet.commit() - println("Balance: ${wallet.getBalance().total.toSat()}") + println("Balance: ${wallet.balance().total.toSat()}") - assert(wallet.getBalance().total.toSat() > 0uL) { + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } @@ -29,7 +36,7 @@ class LiveMemoryWalletTest { val transactions = wallet.transactions().take(3) for (tx in transactions) { val sentAndReceived = wallet.sentAndReceived(tx.transaction) - println("Transaction: ${tx.transaction.txid()}") + println("Transaction: ${tx.transaction.computeTxid()}") println("Sent ${sentAndReceived.sent.toSat()}") println("Received ${sentAndReceived.received.toSat()}") } @@ -37,15 +44,7 @@ class LiveMemoryWalletTest { @Test fun testScriptInspector() { - val descriptor: Descriptor = Descriptor( - "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - Network.SIGNET - ) - val changeDescriptor: Descriptor = Descriptor( - "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", - Network.SIGNET - ) - val wallet: Wallet = Wallet.newNoPersist(descriptor, changeDescriptor, Network.SIGNET) + val wallet: Wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val esploraClient: EsploraClient = EsploraClient(SIGNET_ESPLORA_URL) val scriptInspector: FullScriptInspector = FullScriptInspector() @@ -53,19 +52,16 @@ class LiveMemoryWalletTest { val update = esploraClient.fullScan(fullScanRequest, 21uL, 1uL) wallet.applyUpdate(update) - wallet.commit() - println("Balance: ${wallet.getBalance().total.toSat()}") + println("Balance: ${wallet.balance().total.toSat()}") - assert(wallet.getBalance().total.toSat() > 0uL) { + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } - } - } class FullScriptInspector: FullScanScriptInspector { override fun inspect(keychain: KeychainKind, index: UInt, script: Script){ println("Inspecting index $index for keychain $keychain") } -} \ No newline at end of file +} diff --git a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveTransactionTests.kt b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveTransactionTests.kt index a43216e7..5227a46d 100644 --- a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveTransactionTests.kt +++ b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveTransactionTests.kt @@ -6,27 +6,35 @@ private const val SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net" private const val TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud" class LiveTransactionTests { + private val descriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + Network.SIGNET + ) + private val changeDescriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + Network.SIGNET + ) + @Test fun testSyncedBalance() { val descriptor: Descriptor = Descriptor( "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.SIGNET ) - val wallet: Wallet = Wallet.newNoPersist(descriptor, null, Network.SIGNET) + val wallet: Wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val esploraClient: EsploraClient = EsploraClient(SIGNET_ESPLORA_URL) val fullScanRequest: FullScanRequest = wallet.startFullScan() val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL) wallet.applyUpdate(update) - wallet.commit() - println("Wallet balance: ${wallet.getBalance().total.toSat()}") + println("Wallet balance: ${wallet.balance().total.toSat()}") - assert(wallet.getBalance().total.toSat() > 0uL) { + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } val transaction: Transaction = wallet.transactions().first().transaction println("First transaction:") - println("Txid: ${transaction.txid()}") + println("Txid: ${transaction.computeTxid()}") println("Version: ${transaction.version()}") println("Total size: ${transaction.totalSize()}") println("Vsize: ${transaction.vsize()}") diff --git a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveTxBuilderTest.kt b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveTxBuilderTest.kt index bd797156..ee3a1ed7 100644 --- a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveTxBuilderTest.kt +++ b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveTxBuilderTest.kt @@ -13,6 +13,14 @@ class LiveTxBuilderTest { val currentDirectory = System.getProperty("user.dir") "$currentDirectory/bdk_persistence.sqlite" } + private val descriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + Network.SIGNET + ) + private val changeDescriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + Network.SIGNET + ) @AfterTest fun cleanup() { @@ -25,15 +33,14 @@ class LiveTxBuilderTest { @Test fun testTxBuilder() { val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET) - val wallet = Wallet(descriptor, null, persistenceFilePath, Network.SIGNET) + val wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val esploraClient = EsploraClient(SIGNET_ESPLORA_URL) val fullScanRequest: FullScanRequest = wallet.startFullScan() val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL) wallet.applyUpdate(update) - wallet.commit() - println("Balance: ${wallet.getBalance().total.toSat()}") + println("Balance: ${wallet.balance().total.toSat()}") - assert(wallet.getBalance().total.toSat() > 0uL) { + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } @@ -50,17 +57,14 @@ class LiveTxBuilderTest { @Test fun complexTxBuilder() { - val externalDescriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET) - val changeDescriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", Network.TESTNET) - val wallet = Wallet(externalDescriptor, changeDescriptor, persistenceFilePath, Network.SIGNET) + val wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val esploraClient = EsploraClient(SIGNET_ESPLORA_URL) val fullScanRequest: FullScanRequest = wallet.startFullScan() val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL) wallet.applyUpdate(update) - wallet.commit() - println("Balance: ${wallet.getBalance().total.toSat()}") + println("Balance: ${wallet.balance().total.toSat()}") - assert(wallet.getBalance().total.toSat() > 0uL) { + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } diff --git a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveWalletTest.kt b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveWalletTest.kt index 03e42958..9c8152b4 100644 --- a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveWalletTest.kt +++ b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveWalletTest.kt @@ -13,6 +13,14 @@ class LiveWalletTest { val currentDirectory = System.getProperty("user.dir") "$currentDirectory/bdk_persistence.sqlite" } + private val descriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + Network.SIGNET + ) + private val changeDescriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + Network.SIGNET + ) @AfterTest fun cleanup() { @@ -24,16 +32,14 @@ class LiveWalletTest { @Test fun testSyncedBalance() { - val descriptor: Descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.SIGNET) - val wallet: Wallet = Wallet(descriptor, null, persistenceFilePath, Network.SIGNET) + val wallet: Wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val esploraClient: EsploraClient = EsploraClient(SIGNET_ESPLORA_URL) val fullScanRequest: FullScanRequest = wallet.startFullScan() val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL) wallet.applyUpdate(update) - wallet.commit() - println("Balance: ${wallet.getBalance().total.toSat()}") + println("Balance: ${wallet.balance().total.toSat()}") - assert(wallet.getBalance().total.toSat() > 0uL) { + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } @@ -41,7 +47,7 @@ class LiveWalletTest { val transactions = wallet.transactions().take(3) for (tx in transactions) { val sentAndReceived = wallet.sentAndReceived(tx.transaction) - println("Transaction: ${tx.transaction.txid()}") + println("Transaction: ${tx.transaction.computeTxid()}") println("Sent ${sentAndReceived.sent}") println("Received ${sentAndReceived.received}") } @@ -50,15 +56,14 @@ class LiveWalletTest { @Test fun testBroadcastTransaction() { val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.SIGNET) - val wallet: Wallet = Wallet(descriptor, null, persistenceFilePath, Network.SIGNET) + val wallet: Wallet = Wallet(descriptor, changeDescriptor, Network.SIGNET) val esploraClient = EsploraClient(SIGNET_ESPLORA_URL) val fullScanRequest: FullScanRequest = wallet.startFullScan() val update = esploraClient.fullScan(fullScanRequest, 10uL, 1uL) wallet.applyUpdate(update) - wallet.commit() - println("Balance: ${wallet.getBalance().total.toSat()}") + println("Balance: ${wallet.balance().total.toSat()}") - assert(wallet.getBalance().total.toSat() > 0uL) { + assert(wallet.balance().total.toSat() > 0uL) { "Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again." } @@ -76,9 +81,9 @@ class LiveWalletTest { assertTrue(walletDidSign) val tx: Transaction = psbt.extractTx() - println("Txid is: ${tx.txid()}") + println("Txid is: ${tx.computeTxid()}") - val txFee: ULong = wallet.calculateFee(tx) + val txFee: Amount = wallet.calculateFee(tx) println("Tx fee is: ${txFee}") val feeRate: FeeRate = wallet.calculateFeeRate(tx) diff --git a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/OfflineWalletTest.kt b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/OfflineWalletTest.kt index 3eea21a5..73d8cc8c 100644 --- a/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/OfflineWalletTest.kt +++ b/bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/OfflineWalletTest.kt @@ -12,6 +12,14 @@ class OfflineWalletTest { val currentDirectory = System.getProperty("user.dir") "$currentDirectory/bdk_persistence.sqlite" } + private val descriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + Network.TESTNET + ) + private val changeDescriptor: Descriptor = Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + Network.TESTNET + ) @AfterTest fun cleanup() { @@ -32,14 +40,9 @@ class OfflineWalletTest { @Test fun testNewAddress() { - val descriptor: Descriptor = Descriptor( - "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", - Network.TESTNET - ) val wallet: Wallet = Wallet( descriptor, - null, - persistenceFilePath, + changeDescriptor, Network.TESTNET ) val addressInfo: AddressInfo = wallet.revealNextAddress(KeychainKind.EXTERNAL) @@ -50,27 +53,22 @@ class OfflineWalletTest { assertFalse(addressInfo.address.isValidForNetwork(Network.BITCOIN), "Address is valid for bitcoin network, but it shouldn't be") assertEquals( - expected = "tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e", + expected = "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", actual = addressInfo.address.toString() ) } @Test fun testBalance() { - val descriptor: Descriptor = Descriptor( - "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", - Network.TESTNET - ) val wallet: Wallet = Wallet( descriptor, - null, - persistenceFilePath, + changeDescriptor, Network.TESTNET ) assertEquals( expected = 0uL, - actual = wallet.getBalance().total.toSat() + actual = wallet.balance().total.toSat() ) } } diff --git a/bdk-python/tests/test_live_tx_builder.py b/bdk-python/tests/test_live_tx_builder.py index 50379cb1..9e92c9d3 100644 --- a/bdk-python/tests/test_live_tx_builder.py +++ b/bdk-python/tests/test_live_tx_builder.py @@ -5,6 +5,15 @@ SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net" TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud" +descriptor: bdk.Descriptor = bdk.Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + bdk.Network.TESTNET +) +change_descriptor: bdk.Descriptor = bdk.Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + bdk.Network.TESTNET +) + class LiveTxBuilderTest(unittest.TestCase): def tearDown(self) -> None: @@ -18,8 +27,7 @@ def test_tx_builder(self): ) wallet: bdk.Wallet = bdk.Wallet( descriptor, - None, - "./bdk_persistence.sqlite", + change_descriptor, bdk.Network.SIGNET ) esplora_client: bdk.EsploraClient = bdk.EsploraClient(url = SIGNET_ESPLORA_URL) @@ -30,10 +38,9 @@ def test_tx_builder(self): parallel_requests=1 ) wallet.apply_update(update) - wallet.commit() self.assertGreater( - wallet.get_balance().total.to_sat(), + wallet.balance().total.to_sat(), 0, f"Wallet balance must be greater than 0! Please send funds to {wallet.reveal_next_address(bdk.KeychainKind.EXTERNAL).address} and try again." ) @@ -48,14 +55,9 @@ def test_tx_builder(self): self.assertTrue(psbt.serialize().startswith("cHNi"), "The PSBT should start with cHNi") def complex_tx_builder(self): - descriptor: bdk.Descriptor = bdk.Descriptor( - "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - bdk.Network.SIGNET - ) wallet: bdk.Wallet = bdk.Wallet( descriptor, - None, - "./bdk_persistence.sqlite", + change_descriptor, bdk.Network.SIGNET ) esplora_client: bdk.EsploraClient = bdk.EsploraClient(url = SIGNET_ESPLORA_URL) @@ -66,10 +68,9 @@ def complex_tx_builder(self): parallel_requests=1 ) wallet.apply_update(update) - wallet.commit() self.assertGreater( - wallet.get_balance().total.to_sat(), + wallet.balance().total.to_sat(), 0, f"Wallet balance must be greater than 0! Please send funds to {wallet.reveal_next_address(bdk.KeychainKind.EXTERNAL).address} and try again." ) diff --git a/bdk-python/tests/test_live_wallet.py b/bdk-python/tests/test_live_wallet.py index 9d556a58..d58f91d4 100644 --- a/bdk-python/tests/test_live_wallet.py +++ b/bdk-python/tests/test_live_wallet.py @@ -5,6 +5,15 @@ SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net" TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud" +descriptor: bdk.Descriptor = bdk.Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + bdk.Network.TESTNET +) +change_descriptor: bdk.Descriptor = bdk.Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + bdk.Network.TESTNET +) + class LiveWalletTest(unittest.TestCase): def tearDown(self) -> None: @@ -12,14 +21,9 @@ def tearDown(self) -> None: os.remove("./bdk_persistence.sqlite") def test_synced_balance(self): - descriptor: bdk.Descriptor = bdk.Descriptor( - "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - bdk.Network.SIGNET - ) wallet: bdk.Wallet = bdk.Wallet( descriptor, - None, - "./bdk_persistence.sqlite", + change_descriptor, bdk.Network.SIGNET ) esplora_client: bdk.EsploraClient = bdk.EsploraClient(url = SIGNET_ESPLORA_URL) @@ -30,10 +34,9 @@ def test_synced_balance(self): parallel_requests=1 ) wallet.apply_update(update) - wallet.commit() self.assertGreater( - wallet.get_balance().total.to_sat(), + wallet.balance().total.to_sat(), 0, f"Wallet balance must be greater than 0! Please send funds to {wallet.reveal_next_address(bdk.KeychainKind.EXTERNAL).address} and try again." ) @@ -42,20 +45,15 @@ def test_synced_balance(self): transactions = wallet.transactions()[:3] for tx in transactions: sent_and_received = wallet.sent_and_received(tx.transaction) - print(f"Transaction: {tx.transaction.txid()}") + print(f"Transaction: {tx.transaction.compute_txid()}") print(f"Sent {sent_and_received.sent.to_sat()}") print(f"Received {sent_and_received.received.to_sat()}") def test_broadcast_transaction(self): - descriptor: bdk.Descriptor = bdk.Descriptor( - "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - bdk.Network.SIGNET - ) wallet: bdk.Wallet = bdk.Wallet( descriptor, - None, - "./bdk_persistence.sqlite", + change_descriptor, bdk.Network.SIGNET ) esplora_client: bdk.EsploraClient = bdk.EsploraClient(url = SIGNET_ESPLORA_URL) @@ -66,10 +64,9 @@ def test_broadcast_transaction(self): parallel_requests=1 ) wallet.apply_update(update) - wallet.commit() self.assertGreater( - wallet.get_balance().total.to_sat(), + wallet.balance().total.to_sat(), 0, f"Wallet balance must be greater than 0! Please send funds to {wallet.reveal_next_address(bdk.KeychainKind.EXTERNAL).address} and try again." ) @@ -85,9 +82,9 @@ def test_broadcast_transaction(self): walletDidSign = wallet.sign(psbt) self.assertTrue(walletDidSign) tx = psbt.extract_tx() - print(f"Transaction Id: {tx.txid()}") + print(f"Transaction Id: {tx.compute_txid()}") fee = wallet.calculate_fee(tx) - print(f"Transaction Fee: {fee}") + print(f"Transaction Fee: {fee.to_sat()}") fee_rate = wallet.calculate_fee_rate(tx) print(f"Transaction Fee Rate: {fee_rate.to_sat_per_vb_ceil()} sat/vB") diff --git a/bdk-python/tests/test_offline_wallet.py b/bdk-python/tests/test_offline_wallet.py index dae0d50b..fb7d336d 100644 --- a/bdk-python/tests/test_offline_wallet.py +++ b/bdk-python/tests/test_offline_wallet.py @@ -2,6 +2,15 @@ import unittest import os +descriptor: bdk.Descriptor = bdk.Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + bdk.Network.TESTNET +) +change_descriptor: bdk.Descriptor = bdk.Descriptor( + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + bdk.Network.TESTNET +) + class OfflineWalletTest(unittest.TestCase): def tearDown(self) -> None: @@ -9,14 +18,9 @@ def tearDown(self) -> None: os.remove("./bdk_persistence.sqlite") def test_new_address(self): - descriptor: bdk.Descriptor = bdk.Descriptor( - "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", - bdk.Network.TESTNET - ) wallet: Wallet = bdk.Wallet( descriptor, - None, - "./bdk_persistence.sqlite", + change_descriptor, bdk.Network.TESTNET ) address_info: bdk.AddressInfo = wallet.reveal_next_address(bdk.KeychainKind.EXTERNAL) @@ -26,21 +30,16 @@ def test_new_address(self): self.assertFalse(address_info.address.is_valid_for_network(bdk.Network.REGTEST), "Address is valid for regtest network, but it shouldn't be") self.assertFalse(address_info.address.is_valid_for_network(bdk.Network.BITCOIN), "Address is valid for bitcoin network, but it shouldn't be") - self.assertEqual("tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e", address_info.address.__str__()) + self.assertEqual("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", address_info.address.__str__()) def test_balance(self): - descriptor: bdk.Descriptor = bdk.Descriptor( - "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", - bdk.Network.TESTNET - ) wallet: bdk.Wallet = bdk.Wallet( descriptor, - None, - "./bdk_persistence.sqlite", + change_descriptor, bdk.Network.TESTNET ) - self.assertEqual(wallet.get_balance().total.to_sat(), 0) + self.assertEqual(wallet.balance().total.to_sat(), 0) if __name__ == '__main__': unittest.main() diff --git a/bdk-swift/Tests/BitcoinDevKitTests/LiveElectrumClientTests.swift b/bdk-swift/Tests/BitcoinDevKitTests/LiveElectrumClientTests.swift index 16a32f3e..d86d6045 100644 --- a/bdk-swift/Tests/BitcoinDevKitTests/LiveElectrumClientTests.swift +++ b/bdk-swift/Tests/BitcoinDevKitTests/LiveElectrumClientTests.swift @@ -2,17 +2,21 @@ import XCTest @testable import BitcoinDevKit private let SIGNET_ELECTRUM_URL = "ssl://mempool.space:60602" +private let descriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + network: Network.signet +) +private let changeDescriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + network: Network.signet +) final class LiveElectrumClientTests: XCTestCase { func testSyncedBalance() throws { - let descriptor = try Descriptor( - descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - network: Network.signet - ) - let wallet = try Wallet.newNoPersist( + let wallet = try Wallet( descriptor: descriptor, - changeDescriptor: nil, - network: .signet + changeDescriptor: changeDescriptor, + network: Network.signet ) let electrumClient: ElectrumClient = try ElectrumClient(url: SIGNET_ELECTRUM_URL) let fullScanRequest: FullScanRequest = wallet.startFullScan() @@ -23,11 +27,10 @@ final class LiveElectrumClientTests: XCTestCase { fetchPrevTxouts: false ) try wallet.applyUpdate(update: update) - let _ = try wallet.commit() - let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address + let address = wallet.revealNextAddress(keychain: KeychainKind.external).address XCTAssertGreaterThan( - wallet.getBalance().total.toSat(), + wallet.balance().total.toSat(), UInt64(0), "Wallet must have positive balance, please send funds to \(address)" ) @@ -36,7 +39,7 @@ final class LiveElectrumClientTests: XCTestCase { let transactions = wallet.transactions().prefix(3) for tx in transactions { let sentAndReceived = wallet.sentAndReceived(tx: tx.transaction) - print("Transaction: \(tx.transaction.txid())") + print("Transaction: \(tx.transaction.computeTxid())") print("Sent \(sentAndReceived.sent.toSat())") print("Received \(sentAndReceived.received.toSat())") } diff --git a/bdk-swift/Tests/BitcoinDevKitTests/LiveMemoryWalletTests.swift b/bdk-swift/Tests/BitcoinDevKitTests/LiveMemoryWalletTests.swift index f80f0259..f042bdc4 100644 --- a/bdk-swift/Tests/BitcoinDevKitTests/LiveMemoryWalletTests.swift +++ b/bdk-swift/Tests/BitcoinDevKitTests/LiveMemoryWalletTests.swift @@ -3,17 +3,21 @@ import XCTest private let SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net" private let TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud" +private let descriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + network: Network.signet +) +private let changeDescriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + network: Network.signet +) final class LiveMemoryWalletTests: XCTestCase { func testSyncedBalance() throws { - let descriptor = try Descriptor( - descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - network: Network.signet - ) - let wallet = try Wallet.newNoPersist( + let wallet = try Wallet( descriptor: descriptor, - changeDescriptor: nil, + changeDescriptor: changeDescriptor, network: .signet ) let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL) @@ -24,11 +28,10 @@ final class LiveMemoryWalletTests: XCTestCase { parallelRequests: 1 ) try wallet.applyUpdate(update: update) - let _ = try wallet.commit() - let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address.description + let address = wallet.revealNextAddress(keychain: KeychainKind.external).address.description XCTAssertGreaterThan( - wallet.getBalance().total.toSat(), + wallet.balance().total.toSat(), UInt64(0), "Wallet must have positive balance, please send funds to \(address)" ) @@ -37,22 +40,14 @@ final class LiveMemoryWalletTests: XCTestCase { let transactions = wallet.transactions().prefix(3) for tx in transactions { let sentAndReceived = wallet.sentAndReceived(tx: tx.transaction) - print("Transaction: \(tx.transaction.txid())") + print("Transaction: \(tx.transaction.computeTxid())") print("Sent \(sentAndReceived.sent.toSat())") print("Received \(sentAndReceived.received.toSat())") } } func testScriptInspector() throws { - let descriptor = try Descriptor( - descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - network: Network.signet - ) - let changeDescriptor = try Descriptor( - descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", - network: Network.signet - ) - let wallet = try Wallet.newNoPersist( + let wallet = try Wallet( descriptor: descriptor, changeDescriptor: changeDescriptor, network: .signet @@ -67,11 +62,10 @@ final class LiveMemoryWalletTests: XCTestCase { parallelRequests: 1 ) try wallet.applyUpdate(update: update) - let _ = try wallet.commit() - let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address.description + let address = wallet.revealNextAddress(keychain: KeychainKind.external).address.description XCTAssertGreaterThan( - wallet.getBalance().total.toSat(), + wallet.balance().total.toSat(), UInt64(0), "Wallet must have positive balance, please send funds to \(address)" ) diff --git a/bdk-swift/Tests/BitcoinDevKitTests/LiveTransactionTests.swift b/bdk-swift/Tests/BitcoinDevKitTests/LiveTransactionTests.swift index dac2ce49..a4c376cc 100644 --- a/bdk-swift/Tests/BitcoinDevKitTests/LiveTransactionTests.swift +++ b/bdk-swift/Tests/BitcoinDevKitTests/LiveTransactionTests.swift @@ -3,16 +3,20 @@ import XCTest private let SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net" private let TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud" +private let descriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + network: Network.signet +) +private let changeDescriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + network: Network.signet +) final class LiveTransactionTests: XCTestCase { func testSyncedBalance() throws { - let descriptor = try Descriptor( - descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - network: Network.signet - ) - let wallet = try Wallet.newNoPersist( + let wallet = try Wallet( descriptor: descriptor, - changeDescriptor: nil, + changeDescriptor: changeDescriptor, network: .signet ) let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL) @@ -23,11 +27,10 @@ final class LiveTransactionTests: XCTestCase { parallelRequests: 1 ) try wallet.applyUpdate(update: update) - let _ = try wallet.commit() - let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address.description + let address = wallet.revealNextAddress(keychain: KeychainKind.external).address.description XCTAssertGreaterThan( - wallet.getBalance().total.toSat(), + wallet.balance().total.toSat(), UInt64(0), "Wallet must have positive balance, please send funds to \(address)" ) @@ -37,7 +40,7 @@ final class LiveTransactionTests: XCTestCase { return } print("First transaction:") - print("Txid: \(transaction.txid())") + print("Txid: \(transaction.computeTxid())") print("Version: \(transaction.version())") print("Total size: \(transaction.totalSize())") print("Vsize: \(transaction.vsize())") diff --git a/bdk-swift/Tests/BitcoinDevKitTests/LiveTxBuilderTests.swift b/bdk-swift/Tests/BitcoinDevKitTests/LiveTxBuilderTests.swift index f3ce83ac..ab415389 100644 --- a/bdk-swift/Tests/BitcoinDevKitTests/LiveTxBuilderTests.swift +++ b/bdk-swift/Tests/BitcoinDevKitTests/LiveTxBuilderTests.swift @@ -3,6 +3,14 @@ import XCTest private let SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net" private let TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud" +private let descriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + network: Network.signet +) +private let changeDescriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + network: Network.signet +) final class LiveTxBuilderTests: XCTestCase { var dbFilePath: URL! @@ -27,14 +35,9 @@ final class LiveTxBuilderTests: XCTestCase { } func testTxBuilder() throws { - let descriptor = try Descriptor( - descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - network: Network.signet - ) let wallet = try Wallet( descriptor: descriptor, - changeDescriptor: nil, - persistenceBackendPath: dbFilePath.path, + changeDescriptor: changeDescriptor, network: .signet ) let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL) @@ -45,11 +48,10 @@ final class LiveTxBuilderTests: XCTestCase { parallelRequests: 1 ) try wallet.applyUpdate(update: update) - let _ = try wallet.commit() - let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address.description + let address = wallet.revealNextAddress(keychain: KeychainKind.external).address.description XCTAssertGreaterThan( - wallet.getBalance().total.toSat(), + wallet.balance().total.toSat(), UInt64(0), "Wallet must have positive balance, please send funds to \(address)" ) @@ -76,7 +78,6 @@ final class LiveTxBuilderTests: XCTestCase { let wallet = try Wallet( descriptor: descriptor, changeDescriptor: changeDescriptor, - persistenceBackendPath: dbFilePath.path, network: .signet ) let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL) @@ -87,11 +88,10 @@ final class LiveTxBuilderTests: XCTestCase { parallelRequests: 1 ) try wallet.applyUpdate(update: update) - let _ = try wallet.commit() - let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address.description + let address = wallet.revealNextAddress(keychain: KeychainKind.external).address.description XCTAssertGreaterThan( - wallet.getBalance().total.toSat(), + wallet.balance().total.toSat(), UInt64(0), "Wallet must have positive balance, please send funds to \(address)" ) diff --git a/bdk-swift/Tests/BitcoinDevKitTests/LiveWalletTests.swift b/bdk-swift/Tests/BitcoinDevKitTests/LiveWalletTests.swift index 1f8592cd..b0c62ec4 100644 --- a/bdk-swift/Tests/BitcoinDevKitTests/LiveWalletTests.swift +++ b/bdk-swift/Tests/BitcoinDevKitTests/LiveWalletTests.swift @@ -3,6 +3,14 @@ import XCTest private let SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net" private let TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud" +private let descriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + network: Network.signet +) +private let changeDescriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + network: Network.signet +) final class LiveWalletTests: XCTestCase { var dbFilePath: URL! @@ -27,14 +35,9 @@ final class LiveWalletTests: XCTestCase { } func testSyncedBalance() throws { - let descriptor = try Descriptor( - descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - network: Network.signet - ) let wallet = try Wallet( descriptor: descriptor, - changeDescriptor: nil, - persistenceBackendPath: dbFilePath.path, + changeDescriptor: changeDescriptor, network: .signet ) let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL) @@ -45,11 +48,10 @@ final class LiveWalletTests: XCTestCase { parallelRequests: 1 ) try wallet.applyUpdate(update: update) - let _ = try wallet.commit() - let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address.description + let address = wallet.revealNextAddress(keychain: KeychainKind.external).address.description XCTAssertGreaterThan( - wallet.getBalance().total.toSat(), + wallet.balance().total.toSat(), UInt64(0), "Wallet must have positive balance, please send funds to \(address)" ) @@ -58,21 +60,16 @@ final class LiveWalletTests: XCTestCase { let transactions = wallet.transactions().prefix(3) for tx in transactions { let sentAndReceived = wallet.sentAndReceived(tx: tx.transaction) - print("Transaction: \(tx.transaction.txid())") + print("Transaction: \(tx.transaction.computeTxid())") print("Sent \(sentAndReceived.sent.toSat())") print("Received \(sentAndReceived.received.toSat())") } } func testBroadcastTransaction() throws { - let descriptor = try Descriptor( - descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", - network: Network.signet - ) let wallet = try Wallet( descriptor: descriptor, - changeDescriptor: nil, - persistenceBackendPath: dbFilePath.path, + changeDescriptor: changeDescriptor, network: .signet ) let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL) @@ -83,16 +80,15 @@ final class LiveWalletTests: XCTestCase { parallelRequests: 1 ) try wallet.applyUpdate(update: update) - let _ = try wallet.commit() - let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address.description + let address = wallet.revealNextAddress(keychain: KeychainKind.external).address.description XCTAssertGreaterThan( - wallet.getBalance().total.toSat(), + wallet.balance().total.toSat(), UInt64(0), "Wallet must have positive balance, please send funds to \(address)" ) - print("Balance: \(wallet.getBalance().total)") + print("Balance: \(wallet.balance().total)") let recipient: Address = try Address(address: "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", network: .signet) let psbt: Psbt = try @@ -108,8 +104,8 @@ final class LiveWalletTests: XCTestCase { XCTAssertTrue(walletDidSign, "Wallet did not sign transaction") let tx: Transaction = try! psbt.extractTx() - print(tx.txid()) - let fee: UInt64 = try wallet.calculateFee(tx: tx) + print(tx.computeTxid()) + let fee: Amount = try wallet.calculateFee(tx: tx) print("Transaction Fee: \(fee)") let feeRate: FeeRate = try wallet.calculateFeeRate(tx: tx) print("Transaction Fee Rate: \(feeRate.toSatPerVbCeil()) sat/vB") diff --git a/bdk-swift/Tests/BitcoinDevKitTests/OfflineWalletTests.swift b/bdk-swift/Tests/BitcoinDevKitTests/OfflineWalletTests.swift index 04c17987..b63d3864 100644 --- a/bdk-swift/Tests/BitcoinDevKitTests/OfflineWalletTests.swift +++ b/bdk-swift/Tests/BitcoinDevKitTests/OfflineWalletTests.swift @@ -1,6 +1,15 @@ import XCTest @testable import BitcoinDevKit +private let descriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", + network: Network.signet +) +private let changeDescriptor = try! Descriptor( + descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)", + network: Network.signet +) + final class OfflineWalletTests: XCTestCase { var dbFilePath: URL! @@ -24,17 +33,12 @@ final class OfflineWalletTests: XCTestCase { } func testNewAddress() throws { - let descriptor: Descriptor = try Descriptor( - descriptor: "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", - network: Network.testnet - ) let wallet = try Wallet( descriptor: descriptor, - changeDescriptor: nil, - persistenceBackendPath: dbFilePath.path, + changeDescriptor: changeDescriptor, network: .testnet ) - let addressInfo: AddressInfo = try wallet.revealNextAddress(keychain: KeychainKind.external) + let addressInfo: AddressInfo = wallet.revealNextAddress(keychain: KeychainKind.external) XCTAssertTrue(addressInfo.address.isValidForNetwork(network: Network.testnet), "Address is not valid for testnet network") @@ -45,21 +49,16 @@ final class OfflineWalletTests: XCTestCase { XCTAssertFalse(addressInfo.address.isValidForNetwork(network: Network.bitcoin), "Address is valid for bitcoin network, but it shouldn't be") - XCTAssertEqual(addressInfo.address.description, "tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e") + XCTAssertEqual(addressInfo.address.description, "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989") } func testBalance() throws { - let descriptor: Descriptor = try Descriptor( - descriptor: "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", - network: Network.testnet - ) let wallet = try Wallet( descriptor: descriptor, - changeDescriptor: nil, - persistenceBackendPath: dbFilePath.path, + changeDescriptor: changeDescriptor, network: .testnet ) - XCTAssertEqual(wallet.getBalance().total.toSat(), 0) + XCTAssertEqual(wallet.balance().total.toSat(), 0) } }