Skip to content

Commit

Permalink
fix: use alpha 9 types for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Apr 18, 2024
1 parent aee84f9 commit aa1c0de
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 34 deletions.
3 changes: 3 additions & 0 deletions bdk-android/lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ afterEvaluate {
tasks.named("mergeReleaseJniLibFolders") {
dependsOn(":lib:moveNativeAndroidLibs")
}
tasks.named("mergeDebugJniLibFolders") {
dependsOn(":lib:moveNativeAndroidLibs")
}
}

signing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LiveTxBuilderTest {
assert(wallet.getBalance().total > 0uL)

val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.TESTNET)
val psbt: PartiallySignedTransaction = TxBuilder()
val psbt: Psbt = TxBuilder()
.addRecipient(recipient.scriptPubkey(), 4200uL)
.feeRate(FeeRate.fromSatPerVb(2uL))
.finish(wallet)
Expand Down Expand Up @@ -61,7 +61,7 @@ class LiveTxBuilderTest {
ScriptAmount(recipient2.scriptPubkey(), 4200uL),
)

val psbt: PartiallySignedTransaction = TxBuilder()
val psbt: Psbt = TxBuilder()
.setRecipients(allRecipients)
.feeRate(FeeRate.fromSatPerVb(4uL))
.changePolicy(ChangeSpendPolicy.CHANGE_FORBIDDEN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ class LiveWalletTest {

val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.TESTNET)

val psbt: PartiallySignedTransaction = TxBuilder()
val psbt: Psbt = TxBuilder()
.addRecipient(recipient.scriptPubkey(), 4200uL)
.feeRate(FeeRate.fromSatPerVb(4.0f))
.feeRate(FeeRate.fromSatPerVb(4uL))
.finish(wallet)

println(psbt.serialize())
Expand Down
9 changes: 5 additions & 4 deletions bdk-ffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,10 @@ impl From<BdkEsploraError> for EsploraError {
BdkEsploraError::Minreq(e) => EsploraError::Minreq {
error_message: e.to_string(),
},
BdkEsploraError::HttpResponse { status, message } => {
EsploraError::HttpResponse { status: status, error_message: message }
}
BdkEsploraError::HttpResponse { status, message } => EsploraError::HttpResponse {
status,
error_message: message,
},
BdkEsploraError::Parsing(e) => EsploraError::Parsing {
error_message: e.to_string(),
},
Expand Down Expand Up @@ -563,7 +564,7 @@ mod test {
(
EsploraError::HttpResponse {
status: 404,
message: "Not found".to_string(),
error_message: "Not found".to_string(),
},
"http error with status code 404 and message Not found",
),
Expand Down
17 changes: 0 additions & 17 deletions bdk-ffi/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,6 @@ impl From<BdkCanonicalTx<'_, Arc<bdk::bitcoin::Transaction>, ConfirmationTimeHei
}
}

// impl From<BdkCanonicalTx<'_, BdkTransaction, ConfirmationTimeHeightAnchor>> for CanonicalTx {
// fn from(tx: BdkCanonicalTx<'_, BdkTransaction, ConfirmationTimeHeightAnchor>) -> Self {
// let chain_position = match tx.chain_position {
// BdkChainPosition::Confirmed(anchor) => ChainPosition::Confirmed {
// height: anchor.confirmation_height,
// timestamp: anchor.confirmation_time,
// },
// BdkChainPosition::Unconfirmed(timestamp) => ChainPosition::Unconfirmed { timestamp },
// };
//
// CanonicalTx {
// transaction: Arc::new(Transaction::from(tx.tx_node.tx)),
// chain_position,
// }
// }
// }

#[derive(Clone, Debug)]
pub struct FeeRate(pub BdkFeeRate);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LiveTxBuilderTest {
assert(wallet.getBalance().total > 0uL)

val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.TESTNET)
val psbt: PartiallySignedTransaction = TxBuilder()
val psbt: Psbt = TxBuilder()
.addRecipient(recipient.scriptPubkey(), 4200uL)
.feeRate(FeeRate.fromSatPerVb(2uL))
.finish(wallet)
Expand Down Expand Up @@ -60,7 +60,7 @@ class LiveTxBuilderTest {
ScriptAmount(recipient2.scriptPubkey(), 4200uL),
)

val psbt: PartiallySignedTransaction = TxBuilder()
val psbt: Psbt = TxBuilder()
.setRecipients(allRecipients)
.feeRate(FeeRate.fromSatPerVb(4uL))
.changePolicy(ChangeSpendPolicy.CHANGE_FORBIDDEN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class LiveWalletTest {

val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.TESTNET)

val psbt: PartiallySignedTransaction = TxBuilder()
val psbt: Psbt = TxBuilder()
.addRecipient(recipient.scriptPubkey(), 4200uL)
.feeRate(FeeRate.fromSatPerVb(2uL))
.finish(wallet)
Expand Down
2 changes: 1 addition & 1 deletion bdk-python/tests/test_live_tx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def complex_tx_builder(self):
bdk.ScriptAmount(recipient2.script_pubkey, 4200)
)

psbt: bdk.PartiallySignedTransaction = bdk.TxBuilder().set_recipients(all_recipients).fee_rate(fee_rate=bdk.FeeRate.from_sat_per_vb(2)).enable_rbf().finish(wallet)
psbt: bdk.Psbt = bdk.TxBuilder().set_recipients(all_recipients).fee_rate(fee_rate=bdk.FeeRate.from_sat_per_vb(2)).enable_rbf().finish(wallet)
wallet.sign(psbt)

self.assertTrue(psbt.serialize().startswith("cHNi"), "The PSBT should start with cHNi")
Expand Down
2 changes: 1 addition & 1 deletion bdk-python/tests/test_live_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_broadcast_transaction(self):
network = bdk.Network.TESTNET
)

psbt = bdk.TxBuilder().add_recipient(script=recipient.script_pubkey(), amount=4200).fee_rate(fee_rate=bdk.FeeRate.from_sat_per_vb(2)).finish(wallet)
psbt: bdk.Psbt = bdk.TxBuilder().add_recipient(script=recipient.script_pubkey(), amount=4200).fee_rate(fee_rate=bdk.FeeRate.from_sat_per_vb(2)).finish(wallet)
# print(psbt.serialize())
self.assertTrue(psbt.serialize().startswith("cHNi"), "The PSBT should start with cHNi")

Expand Down
4 changes: 2 additions & 2 deletions bdk-swift/Tests/BitcoinDevKitTests/LiveTxBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class LiveTxBuilderTests: XCTestCase {
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()
let psbt: Psbt = try TxBuilder()
.addRecipient(script: recipient.scriptPubkey(), amount: 4200)
.feeRate(feeRate: FeeRate.fromSatPerVb(satPerVb: 2))
.finish(wallet: wallet)
Expand Down Expand Up @@ -86,7 +86,7 @@ final class LiveTxBuilderTests: XCTestCase {
ScriptAmount(script: recipient2.scriptPubkey(), amount: 4200)
]

let psbt: PartiallySignedTransaction = try TxBuilder()
let psbt: Psbt = try TxBuilder()
.setRecipients(recipients: allRecipients)
.feeRate(feeRate: FeeRate.fromSatPerVb(satPerVb: 4))
.changePolicy(changePolicy: ChangeSpendPolicy.changeForbidden)
Expand Down
4 changes: 2 additions & 2 deletions bdk-swift/Tests/BitcoinDevKitTests/LiveWalletTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ final class LiveWalletTests: XCTestCase {
print("Balance: \(wallet.getBalance().total)")

let recipient: Address = try Address(address: "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", network: .testnet)
let psbt: PartiallySignedTransaction = try
let psbt: Psbt = try
TxBuilder()
.addRecipient(script: recipient.scriptPubkey(), amount: 4200)
.feeRate(feeRate: FeeRate.fromSatPerVb(satPerVb: 2))
Expand All @@ -90,7 +90,7 @@ final class LiveWalletTests: XCTestCase {
let walletDidSign: Bool = try wallet.sign(psbt: psbt)
XCTAssertTrue(walletDidSign, "Wallet did not sign transaction")

let tx: Transaction = psbt.extractTx()
let tx: Transaction = try! psbt.extractTx()
print(tx.txid())
let fee: UInt64 = try wallet.calculateFee(tx: tx)
print("Transaction Fee: \(fee)")
Expand Down

0 comments on commit aa1c0de

Please sign in to comment.