-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13c751c
commit d37b2f3
Showing
24 changed files
with
393 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,4 @@ jobs: | |
- name: "Run JVM tests" | ||
run: | | ||
cd bdk-jvm | ||
./gradlew test | ||
./gradlew test -P excludeConnectedTests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveTxBuilderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.bitcoindevkit | ||
|
||
import org.junit.Test | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.runner.RunWith | ||
import kotlin.test.assertTrue | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class LiveTxBuilderTest { | ||
@Test | ||
fun testTxBuilder() { | ||
val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET) | ||
val wallet = Wallet.newNoPersist(descriptor, null, Network.TESTNET) | ||
val esploraClient = EsploraClient("https://mempool.space/testnet/api") | ||
val update = esploraClient.scan(wallet, 10uL, 1uL) | ||
wallet.applyUpdate(update) | ||
println("Balance: ${wallet.getBalance().total()}") | ||
|
||
assert(wallet.getBalance().total() > 0uL) | ||
|
||
val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.TESTNET) | ||
val psbt: PartiallySignedTransaction = TxBuilder() | ||
.addRecipient(recipient.scriptPubkey(), 4200uL) | ||
.feeRate(2.0f) | ||
.finish(wallet) | ||
|
||
println(psbt.serialize()) | ||
assertTrue(psbt.serialize().startsWith("cHNi"), "PSBT should start with 'cHNi'") | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/LiveWalletTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.bitcoindevkit | ||
|
||
import org.junit.Test | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class LiveWalletTest { | ||
@Test | ||
fun testSyncedBalance() { | ||
val descriptor: Descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET) | ||
val wallet: Wallet = Wallet.newNoPersist(descriptor, null, Network.TESTNET) | ||
val esploraClient: EsploraClient = EsploraClient("https://mempool.space/testnet/api") | ||
// val esploraClient = EsploraClient("https://blockstream.info/testnet/api") | ||
val update = esploraClient.scan(wallet, 10uL, 1uL) | ||
wallet.applyUpdate(update) | ||
println("Balance: ${wallet.getBalance().total()}") | ||
|
||
assert(wallet.getBalance().total() > 0uL) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
bdk-android/lib/src/androidTest/kotlin/org/bitcoindevkit/OfflineDescriptorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.bitcoindevkit | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertTrue | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class OfflineDescriptorTest { | ||
@Test | ||
fun testDescriptorBip86() { | ||
val mnemonic: Mnemonic = Mnemonic.fromString("space echo position wrist orient erupt relief museum myself grain wisdom tumble") | ||
val descriptorSecretKey: DescriptorSecretKey = DescriptorSecretKey(Network.TESTNET, mnemonic, null) | ||
val descriptor: Descriptor = Descriptor.newBip86(descriptorSecretKey, KeychainKind.EXTERNAL, Network.TESTNET) | ||
|
||
assertEquals( | ||
expected = "tr([be1eec8f/86'/1'/0']tpubDCTtszwSxPx3tATqDrsSyqScPNnUChwQAVAkanuDUCJQESGBbkt68nXXKRDifYSDbeMa2Xg2euKbXaU3YphvGWftDE7ozRKPriT6vAo3xsc/0/*)#m7puekcx", | ||
actual = descriptor.asString() | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveTxBuilderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.bitcoindevkit | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertTrue | ||
|
||
class LiveTxBuilderTest { | ||
@Test | ||
fun testTxBuilder() { | ||
val descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET) | ||
val wallet = Wallet.newNoPersist(descriptor, null, Network.TESTNET) | ||
val esploraClient = EsploraClient("https://mempool.space/testnet/api") | ||
val update = esploraClient.scan(wallet, 10uL, 1uL) | ||
wallet.applyUpdate(update) | ||
println("Balance: ${wallet.getBalance().total()}") | ||
|
||
assert(wallet.getBalance().total() > 0uL) | ||
|
||
val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.TESTNET) | ||
val psbt: PartiallySignedTransaction = TxBuilder() | ||
.addRecipient(recipient.scriptPubkey(), 4200uL) | ||
.feeRate(2.0f) | ||
.finish(wallet) | ||
|
||
println(psbt.serialize()) | ||
|
||
assertTrue(psbt.serialize().startsWith("cHNi"), "PSBT should start with 'cHNi'") | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
bdk-jvm/lib/src/test/kotlin/org/bitcoindevkit/LiveWalletTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.bitcoindevkit | ||
|
||
import kotlin.test.Test | ||
|
||
class LiveWalletTest { | ||
@Test | ||
fun testSyncedBalance() { | ||
val descriptor: Descriptor = Descriptor("wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)", Network.TESTNET) | ||
val wallet: Wallet = Wallet.newNoPersist(descriptor, null, Network.TESTNET) | ||
val esploraClient: EsploraClient = EsploraClient("https://mempool.space/testnet/api") | ||
// val esploraClient = EsploraClient("https://blockstream.info/testnet/api") | ||
val update = esploraClient.scan(wallet, 10uL, 1uL) | ||
wallet.applyUpdate(update) | ||
println("Balance: ${wallet.getBalance().total()}") | ||
|
||
assert(wallet.getBalance().total() > 0uL) | ||
} | ||
} |
Oops, something went wrong.