test: better messages when tests fail for low balance
This commit is contained in:
parent
1b0b50a954
commit
f27bada9c9
@ -35,7 +35,9 @@ class LiveTxBuilderTest {
|
||||
wallet.commit()
|
||||
println("Balance: ${wallet.getBalance().total}")
|
||||
|
||||
assert(wallet.getBalance().total > 0uL)
|
||||
assert(wallet.getBalance().total > 0uL) {
|
||||
"Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address.asString()} and try again."
|
||||
}
|
||||
|
||||
val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.SIGNET)
|
||||
val psbt: Psbt = TxBuilder()
|
||||
@ -59,7 +61,9 @@ class LiveTxBuilderTest {
|
||||
wallet.commit()
|
||||
println("Balance: ${wallet.getBalance().total}")
|
||||
|
||||
assert(wallet.getBalance().total > 0uL)
|
||||
assert(wallet.getBalance().total > 0uL) {
|
||||
"Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address.asString()} and try again."
|
||||
}
|
||||
|
||||
val recipient1: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.SIGNET)
|
||||
val recipient2: Address = Address("tb1qw2c3lxufxqe2x9s4rdzh65tpf4d7fssjgh8nv6", Network.SIGNET)
|
||||
|
@ -37,7 +37,9 @@ class LiveWalletTest {
|
||||
val balance: Balance = wallet.getBalance()
|
||||
println("Balance: $balance")
|
||||
|
||||
assert(wallet.getBalance().total > 0uL)
|
||||
assert(wallet.getBalance().total > 0uL) {
|
||||
"Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address.asString()} and try again."
|
||||
}
|
||||
|
||||
println("Transactions count: ${wallet.transactions().count()}")
|
||||
val transactions = wallet.transactions().take(3)
|
||||
@ -59,7 +61,6 @@ class LiveWalletTest {
|
||||
wallet.applyUpdate(update)
|
||||
wallet.commit()
|
||||
println("Balance: ${wallet.getBalance().total}")
|
||||
println("New address: ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address}")
|
||||
|
||||
assert(wallet.getBalance().total > 0uL) {
|
||||
"Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address} and try again."
|
||||
@ -82,7 +83,7 @@ class LiveWalletTest {
|
||||
println("Txid is: ${tx.txid()}")
|
||||
|
||||
val txFee: ULong = wallet.calculateFee(tx)
|
||||
println("Tx fee is: ${txFee}")
|
||||
println("Tx fee is: $txFee")
|
||||
|
||||
val feeRate: FeeRate = wallet.calculateFeeRate(tx)
|
||||
println("Tx fee rate is: ${feeRate.toSatPerVbCeil()} sat/vB")
|
||||
|
@ -33,7 +33,9 @@ class LiveTxBuilderTest {
|
||||
wallet.commit()
|
||||
println("Balance: ${wallet.getBalance().total}")
|
||||
|
||||
assert(wallet.getBalance().total > 0uL)
|
||||
assert(wallet.getBalance().total > 0uL) {
|
||||
"Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address.asString()} and try again."
|
||||
}
|
||||
|
||||
val recipient: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.SIGNET)
|
||||
val psbt: Psbt = TxBuilder()
|
||||
@ -58,7 +60,9 @@ class LiveTxBuilderTest {
|
||||
wallet.commit()
|
||||
println("Balance: ${wallet.getBalance().total}")
|
||||
|
||||
assert(wallet.getBalance().total > 0uL)
|
||||
assert(wallet.getBalance().total > 0uL) {
|
||||
"Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address.asString()} and try again."
|
||||
}
|
||||
|
||||
val recipient1: Address = Address("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", Network.SIGNET)
|
||||
val recipient2: Address = Address("tb1qw2c3lxufxqe2x9s4rdzh65tpf4d7fssjgh8nv6", Network.SIGNET)
|
||||
|
@ -33,7 +33,9 @@ class LiveWalletTest {
|
||||
wallet.commit()
|
||||
println("Balance: ${wallet.getBalance().total}")
|
||||
|
||||
assert(wallet.getBalance().total > 0uL)
|
||||
assert(wallet.getBalance().total > 0uL) {
|
||||
"Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address.asString()} and try again."
|
||||
}
|
||||
|
||||
println("Transactions count: ${wallet.transactions().count()}")
|
||||
val transactions = wallet.transactions().take(3)
|
||||
@ -55,7 +57,6 @@ class LiveWalletTest {
|
||||
wallet.applyUpdate(update)
|
||||
wallet.commit()
|
||||
println("Balance: ${wallet.getBalance().total}")
|
||||
println("New address: ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address.asString()}")
|
||||
|
||||
assert(wallet.getBalance().total > 0uL) {
|
||||
"Wallet balance must be greater than 0! Please send funds to ${wallet.revealNextAddress(KeychainKind.EXTERNAL).address.asString()} and try again."
|
||||
|
@ -32,7 +32,11 @@ class LiveTxBuilderTest(unittest.TestCase):
|
||||
wallet.apply_update(update)
|
||||
wallet.commit()
|
||||
|
||||
self.assertGreater(wallet.get_balance().total, 0)
|
||||
self.assertGreater(
|
||||
wallet.get_balance().total,
|
||||
0,
|
||||
f"Wallet balance must be greater than 0! Please send funds to {wallet.reveal_next_address(bdk.KeychainKind.EXTERNAL).address.as_string()} and try again."
|
||||
)
|
||||
|
||||
recipient = bdk.Address(
|
||||
address="tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989",
|
||||
@ -68,7 +72,11 @@ class LiveTxBuilderTest(unittest.TestCase):
|
||||
wallet.apply_update(update)
|
||||
wallet.commit()
|
||||
|
||||
self.assertGreater(wallet.get_balance().total, 0)
|
||||
self.assertGreater(
|
||||
wallet.get_balance().total,
|
||||
0,
|
||||
f"Wallet balance must be greater than 0! Please send funds to {wallet.reveal_next_address(bdk.KeychainKind.EXTERNAL).address.as_string()} and try again."
|
||||
)
|
||||
|
||||
recipient1 = bdk.Address(
|
||||
address="tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989",
|
||||
|
@ -32,7 +32,11 @@ class LiveWalletTest(unittest.TestCase):
|
||||
wallet.apply_update(update)
|
||||
wallet.commit()
|
||||
|
||||
self.assertGreater(wallet.get_balance().total, 0)
|
||||
self.assertGreater(
|
||||
wallet.get_balance().total,
|
||||
0,
|
||||
f"Wallet balance must be greater than 0! Please send funds to {wallet.reveal_next_address(bdk.KeychainKind.EXTERNAL).address.as_string()} and try again."
|
||||
)
|
||||
|
||||
print(f"Transactions count: {len(wallet.transactions())}")
|
||||
transactions = wallet.transactions()[:3]
|
||||
@ -64,7 +68,11 @@ class LiveWalletTest(unittest.TestCase):
|
||||
wallet.apply_update(update)
|
||||
wallet.commit()
|
||||
|
||||
self.assertGreater(wallet.get_balance().total, 0)
|
||||
self.assertGreater(
|
||||
wallet.get_balance().total,
|
||||
0,
|
||||
f"Wallet balance must be greater than 0! Please send funds to {wallet.reveal_next_address(bdk.KeychainKind.EXTERNAL).address.as_string()} and try again."
|
||||
)
|
||||
|
||||
recipient = bdk.Address(
|
||||
address="tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989",
|
||||
|
@ -1,8 +1,8 @@
|
||||
import XCTest
|
||||
@testable import BitcoinDevKit
|
||||
|
||||
let SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net"
|
||||
let TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud"
|
||||
private let SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net"
|
||||
private let TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud"
|
||||
|
||||
final class LiveTxBuilderTests: XCTestCase {
|
||||
var dbFilePath: URL!
|
||||
@ -45,9 +45,14 @@ final class LiveTxBuilderTests: XCTestCase {
|
||||
parallelRequests: 1
|
||||
)
|
||||
try wallet.applyUpdate(update: update)
|
||||
try wallet.commit()
|
||||
let _ = try wallet.commit()
|
||||
let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address.asString()
|
||||
|
||||
XCTAssertGreaterThan(wallet.getBalance().total, UInt64(0), "Wallet must have positive balance, please add funds")
|
||||
XCTAssertGreaterThan(
|
||||
wallet.getBalance().total,
|
||||
UInt64(0),
|
||||
"Wallet must have positive balance, please send funds to \(address)"
|
||||
)
|
||||
|
||||
let recipient: Address = try Address(address: "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", network: .signet)
|
||||
let psbt: Psbt = try TxBuilder()
|
||||
@ -82,9 +87,14 @@ final class LiveTxBuilderTests: XCTestCase {
|
||||
parallelRequests: 1
|
||||
)
|
||||
try wallet.applyUpdate(update: update)
|
||||
try wallet.commit()
|
||||
let _ = try wallet.commit()
|
||||
let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address.asString()
|
||||
|
||||
XCTAssertGreaterThan(wallet.getBalance().total, UInt64(0), "Wallet must have positive balance, please add funds")
|
||||
XCTAssertGreaterThan(
|
||||
wallet.getBalance().total,
|
||||
UInt64(0),
|
||||
"Wallet must have positive balance, please send funds to \(address)"
|
||||
)
|
||||
|
||||
let recipient1: Address = try Address(address: "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", network: .signet)
|
||||
let recipient2: Address = try Address(address: "tb1qw2c3lxufxqe2x9s4rdzh65tpf4d7fssjgh8nv6", network: .signet)
|
||||
@ -100,7 +110,7 @@ final class LiveTxBuilderTests: XCTestCase {
|
||||
.enableRbf()
|
||||
.finish(wallet: wallet)
|
||||
|
||||
try! wallet.sign(psbt: psbt)
|
||||
let _ = try! wallet.sign(psbt: psbt)
|
||||
|
||||
XCTAssertTrue(psbt.serialize().hasPrefix("cHNi"), "PSBT should start with cHNI")
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import XCTest
|
||||
@testable import BitcoinDevKit
|
||||
|
||||
let SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net"
|
||||
let TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud"
|
||||
private let SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net"
|
||||
private let TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud"
|
||||
|
||||
final class LiveWalletTests: XCTestCase {
|
||||
var dbFilePath: URL!
|
||||
@ -45,9 +45,14 @@ final class LiveWalletTests: XCTestCase {
|
||||
parallelRequests: 1
|
||||
)
|
||||
try wallet.applyUpdate(update: update)
|
||||
try wallet.commit()
|
||||
let _ = try wallet.commit()
|
||||
let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address.asString()
|
||||
|
||||
XCTAssertGreaterThan(wallet.getBalance().total, UInt64(0))
|
||||
XCTAssertGreaterThan(
|
||||
wallet.getBalance().total,
|
||||
UInt64(0),
|
||||
"Wallet must have positive balance, please send funds to \(address)"
|
||||
)
|
||||
|
||||
print("Transactions count: \(wallet.transactions().count)")
|
||||
let transactions = wallet.transactions().prefix(3)
|
||||
@ -78,9 +83,15 @@ final class LiveWalletTests: XCTestCase {
|
||||
parallelRequests: 1
|
||||
)
|
||||
try wallet.applyUpdate(update: update)
|
||||
try wallet.commit()
|
||||
let _ = try wallet.commit()
|
||||
let address = try wallet.revealNextAddress(keychain: KeychainKind.external).address.asString()
|
||||
|
||||
XCTAssertGreaterThan(
|
||||
wallet.getBalance().total,
|
||||
UInt64(0),
|
||||
"Wallet must have positive balance, please send funds to \(address)"
|
||||
)
|
||||
|
||||
XCTAssertGreaterThan(wallet.getBalance().total, UInt64(0), "Wallet must have positive balance, please add funds")
|
||||
|
||||
print("Balance: \(wallet.getBalance().total)")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user