test: use signet for live tests
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import XCTest
|
||||
@testable import BitcoinDevKit
|
||||
|
||||
let SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net"
|
||||
let TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud"
|
||||
|
||||
final class LiveTxBuilderTests: XCTestCase {
|
||||
var dbFilePath: URL!
|
||||
|
||||
@@ -26,15 +29,15 @@ final class LiveTxBuilderTests: XCTestCase {
|
||||
func testTxBuilder() throws {
|
||||
let descriptor = try Descriptor(
|
||||
descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)",
|
||||
network: Network.testnet
|
||||
network: Network.signet
|
||||
)
|
||||
let wallet = try Wallet(
|
||||
descriptor: descriptor,
|
||||
changeDescriptor: nil,
|
||||
persistenceBackendPath: dbFilePath.path,
|
||||
network: .testnet
|
||||
network: .signet
|
||||
)
|
||||
let esploraClient = EsploraClient(url: "https://esplora.testnet.kuutamo.cloud/")
|
||||
let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL)
|
||||
let fullScanRequest: FullScanRequest = wallet.startFullScan()
|
||||
let update = try esploraClient.fullScan(
|
||||
fullScanRequest: fullScanRequest,
|
||||
@@ -46,7 +49,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 recipient: Address = try Address(address: "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", network: .signet)
|
||||
let psbt: Psbt = try TxBuilder()
|
||||
.addRecipient(script: recipient.scriptPubkey(), amount: 4200)
|
||||
.feeRate(feeRate: FeeRate.fromSatPerVb(satPerVb: 2))
|
||||
@@ -59,19 +62,19 @@ final class LiveTxBuilderTests: XCTestCase {
|
||||
func testComplexTxBuilder() throws {
|
||||
let descriptor = try Descriptor(
|
||||
descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)",
|
||||
network: Network.testnet
|
||||
network: Network.signet
|
||||
)
|
||||
let changeDescriptor = try Descriptor(
|
||||
descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)",
|
||||
network: Network.testnet
|
||||
network: Network.signet
|
||||
)
|
||||
let wallet = try Wallet(
|
||||
descriptor: descriptor,
|
||||
changeDescriptor: changeDescriptor,
|
||||
persistenceBackendPath: dbFilePath.path,
|
||||
network: .testnet
|
||||
network: .signet
|
||||
)
|
||||
let esploraClient = EsploraClient(url: "https://esplora.testnet.kuutamo.cloud/")
|
||||
let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL)
|
||||
let fullScanRequest: FullScanRequest = wallet.startFullScan()
|
||||
let update = try esploraClient.fullScan(
|
||||
fullScanRequest: fullScanRequest,
|
||||
@@ -83,8 +86,8 @@ final class LiveTxBuilderTests: XCTestCase {
|
||||
|
||||
XCTAssertGreaterThan(wallet.getBalance().total, UInt64(0), "Wallet must have positive balance, please add funds")
|
||||
|
||||
let recipient1: Address = try Address(address: "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", network: .testnet)
|
||||
let recipient2: Address = try Address(address: "tb1qw2c3lxufxqe2x9s4rdzh65tpf4d7fssjgh8nv6", network: .testnet)
|
||||
let recipient1: Address = try Address(address: "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", network: .signet)
|
||||
let recipient2: Address = try Address(address: "tb1qw2c3lxufxqe2x9s4rdzh65tpf4d7fssjgh8nv6", network: .signet)
|
||||
let allRecipients: [ScriptAmount] = [
|
||||
ScriptAmount(script: recipient1.scriptPubkey(), amount: 4200),
|
||||
ScriptAmount(script: recipient2.scriptPubkey(), amount: 4200)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import XCTest
|
||||
@testable import BitcoinDevKit
|
||||
|
||||
let SIGNET_ESPLORA_URL = "http://signet.bitcoindevkit.net"
|
||||
let TESTNET_ESPLORA_URL = "https://esplora.testnet.kuutamo.cloud"
|
||||
|
||||
final class LiveWalletTests: XCTestCase {
|
||||
var dbFilePath: URL!
|
||||
|
||||
@@ -26,15 +29,15 @@ final class LiveWalletTests: XCTestCase {
|
||||
func testSyncedBalance() throws {
|
||||
let descriptor = try Descriptor(
|
||||
descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)",
|
||||
network: Network.testnet
|
||||
network: Network.signet
|
||||
)
|
||||
let wallet = try Wallet(
|
||||
descriptor: descriptor,
|
||||
changeDescriptor: nil,
|
||||
persistenceBackendPath: dbFilePath.path,
|
||||
network: .testnet
|
||||
network: .signet
|
||||
)
|
||||
let esploraClient = EsploraClient(url: "https://esplora.testnet.kuutamo.cloud/")
|
||||
let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL)
|
||||
let fullScanRequest: FullScanRequest = wallet.startFullScan()
|
||||
let update = try esploraClient.fullScan(
|
||||
fullScanRequest: fullScanRequest,
|
||||
@@ -59,15 +62,15 @@ final class LiveWalletTests: XCTestCase {
|
||||
func testBroadcastTransaction() throws {
|
||||
let descriptor = try Descriptor(
|
||||
descriptor: "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)",
|
||||
network: Network.testnet
|
||||
network: Network.signet
|
||||
)
|
||||
let wallet = try Wallet(
|
||||
descriptor: descriptor,
|
||||
changeDescriptor: nil,
|
||||
persistenceBackendPath: dbFilePath.path,
|
||||
network: .testnet
|
||||
network: .signet
|
||||
)
|
||||
let esploraClient = EsploraClient(url: "https://esplora.testnet.kuutamo.cloud/")
|
||||
let esploraClient = EsploraClient(url: SIGNET_ESPLORA_URL)
|
||||
let fullScanRequest: FullScanRequest = wallet.startFullScan()
|
||||
let update = try esploraClient.fullScan(
|
||||
fullScanRequest: fullScanRequest,
|
||||
@@ -81,7 +84,7 @@ final class LiveWalletTests: XCTestCase {
|
||||
|
||||
print("Balance: \(wallet.getBalance().total)")
|
||||
|
||||
let recipient: Address = try Address(address: "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", network: .testnet)
|
||||
let recipient: Address = try Address(address: "tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", network: .signet)
|
||||
let psbt: Psbt = try
|
||||
TxBuilder()
|
||||
.addRecipient(script: recipient.scriptPubkey(), amount: 4200)
|
||||
|
||||
Reference in New Issue
Block a user