-
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 0bbbdaf
Showing
15 changed files
with
203 additions
and
90 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
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
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
25 changes: 25 additions & 0 deletions
25
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,25 @@ | ||
package org.bitcoindevkit | ||
|
||
import org.junit.Test | ||
|
||
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()) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
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,16 @@ | ||
package org.bitcoindevkit | ||
|
||
import org.junit.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()}") | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
bdk-jvm/lib/src/test/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,15 @@ | ||
package org.bitcoindevkit | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertTrue | ||
|
||
class OfflineDescriptorTest { | ||
@Test | ||
fun testDescriptorBip86() { | ||
val mnemonic: Mnemonic = Mnemonic(WordCount.WORDS12) | ||
val descriptorSecretKey: DescriptorSecretKey = DescriptorSecretKey(Network.TESTNET, mnemonic, null) | ||
val descriptor: Descriptor = Descriptor.newBip86(descriptorSecretKey, KeychainKind.EXTERNAL, Network.TESTNET) | ||
|
||
assertTrue(descriptor.asString().startsWith("tr"), "Bip86 Descriptor does not start with 'tr'") | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import bdkpython as bdk | ||
import unittest | ||
|
||
class TestLiveWallet(unittest.TestCase): | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
File renamed without changes.
68 changes: 0 additions & 68 deletions
68
bdk-swift/Tests/BitcoinDevKitTests/BitcoinDevKitTests.swift
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
bdk-swift/Tests/BitcoinDevKitTests/LiveTxBuilderTests.swift
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,34 @@ | ||
import XCTest | ||
@testable import BitcoinDevKit | ||
|
||
final class LiveTxBuilderTests: XCTestCase { | ||
func testTxBuilder() throws { | ||
let descriptor = try Descriptor( | ||
descriptor: "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", | ||
network: Network.testnet | ||
) | ||
let wallet = try Wallet.newNoPersist( | ||
descriptor: descriptor, | ||
changeDescriptor: nil, | ||
network: .testnet | ||
) | ||
let esploraClient = EsploraClient(url: "https://mempool.space/testnet/api") | ||
let update = try esploraClient.scan( | ||
wallet: wallet, | ||
stopGap: 10, | ||
parallelRequests: 1 | ||
) | ||
try wallet.applyUpdate(update: update) | ||
|
||
XCTAssertGreaterThan(wallet.getBalance().total(), UInt64(0), "Wallet must have positive balance, please add funds") | ||
|
||
let recipient: Address = try Address(address: "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", network: .testnet) | ||
let psbt: PartiallySignedTransaction = try TxBuilder() | ||
.addRecipient(script: recipient.scriptPubkey(), amount: 4200) | ||
.feeRate(satPerVbyte: 2.0) | ||
.finish(wallet: wallet) | ||
|
||
print(psbt.serialize()) | ||
XCTAssertTrue(psbt.serialize().hasPrefix("cHNi"), "PSBT should start with cHNI") | ||
} | ||
} |
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,25 @@ | ||
import XCTest | ||
@testable import BitcoinDevKit | ||
|
||
final class LiveWalletTests: XCTestCase { | ||
func testSyncedBalance() throws { | ||
let descriptor = try Descriptor( | ||
descriptor: "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", | ||
network: Network.testnet | ||
) | ||
let wallet = try Wallet.newNoPersist( | ||
descriptor: descriptor, | ||
changeDescriptor: nil, | ||
network: .testnet | ||
) | ||
let esploraClient = EsploraClient(url: "https://mempool.space/testnet/api") | ||
let update = try esploraClient.scan( | ||
wallet: wallet, | ||
stopGap: 10, | ||
parallelRequests: 1 | ||
) | ||
try wallet.applyUpdate(update: update) | ||
|
||
XCTAssertGreaterThan(wallet.getBalance().total(), UInt64(0)) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
bdk-swift/Tests/BitcoinDevKitTests/OfflineDescriptorTests.swift
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,20 @@ | ||
import XCTest | ||
@testable import BitcoinDevKit | ||
|
||
final class OfflineDescriptorTests: XCTestCase { | ||
func testDescriptorBip86() { | ||
let mnemonic: Mnemonic = Mnemonic(wordCount: WordCount.words12) | ||
let descriptorSecretKey: DescriptorSecretKey = DescriptorSecretKey( | ||
network: Network.testnet, | ||
mnemonic: mnemonic, | ||
password: nil | ||
) | ||
let descriptor: Descriptor = Descriptor.newBip86( | ||
secretKey: descriptorSecretKey, | ||
keychain: KeychainKind.external, | ||
network: Network.testnet | ||
) | ||
|
||
XCTAssertTrue(descriptor.asString().hasPrefix("tr"), "Bip86 Descriptor does not start with 'tr'") | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
bdk-swift/Tests/BitcoinDevKitTests/OfflineWalletTests.swift
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,33 @@ | ||
import XCTest | ||
@testable import BitcoinDevKit | ||
|
||
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: Wallet = try Wallet.newNoPersist( | ||
descriptor: descriptor, | ||
changeDescriptor: nil, | ||
network: .testnet | ||
) | ||
let addressInfo: AddressInfo = wallet.getAddress(addressIndex: AddressIndex.new) | ||
|
||
XCTAssertEqual(addressInfo.address.asString(), "tb1qzg4mckdh50nwdm9hkzq06528rsu73hjxxzem3e") | ||
} | ||
|
||
func testBalance() throws { | ||
let descriptor: Descriptor = try Descriptor( | ||
descriptor: "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)", | ||
network: Network.testnet | ||
) | ||
let wallet: Wallet = try Wallet.newNoPersist( | ||
descriptor: descriptor, | ||
changeDescriptor: nil, | ||
network: .testnet | ||
) | ||
|
||
XCTAssertEqual(wallet.getBalance().total(), 0) | ||
} | ||
} |