Skip to content

Commit

Permalink
tests(python): add in-memory connection
Browse files Browse the repository at this point in the history
  • Loading branch information
rustaceanrob committed Aug 7, 2024
1 parent cdbf424 commit 52ee8a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
10 changes: 7 additions & 3 deletions bdk-python/tests/test_live_tx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ def test_tx_builder(self):
"wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)",
bdk.Network.SIGNET
)
connection: bdk.Connection = bdk.Connection.new_in_memory()
wallet: bdk.Wallet = bdk.Wallet(
descriptor,
change_descriptor,
bdk.Network.SIGNET
bdk.Network.SIGNET,
connection
)
esplora_client: bdk.EsploraClient = bdk.EsploraClient(url = SIGNET_ESPLORA_URL)
full_scan_request: bdk.FullScanRequest = wallet.start_full_scan()
Expand All @@ -55,10 +57,12 @@ def test_tx_builder(self):
self.assertTrue(psbt.serialize().startswith("cHNi"), "The PSBT should start with cHNi")

def complex_tx_builder(self):
connection: bdk.Connection = bdk.Connection.new_in_memory()
wallet: bdk.Wallet = bdk.Wallet(
descriptor,
change_descriptor,
bdk.Network.SIGNET
bdk.Network.SIGNET,
connection
)
esplora_client: bdk.EsploraClient = bdk.EsploraClient(url = SIGNET_ESPLORA_URL)
full_scan_request: bdk.FullScanRequest = wallet.start_full_scan()
Expand Down Expand Up @@ -95,4 +99,4 @@ def complex_tx_builder(self):


if __name__ == '__main__':
unittest.main()
unittest.main()
10 changes: 7 additions & 3 deletions bdk-python/tests/test_live_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ def tearDown(self) -> None:
os.remove("./bdk_persistence.sqlite")

def test_synced_balance(self):
connection: bdk.Connection = bdk.Connection.new_in_memory()
wallet: bdk.Wallet = bdk.Wallet(
descriptor,
change_descriptor,
bdk.Network.SIGNET
bdk.Network.SIGNET,
connection
)
esplora_client: bdk.EsploraClient = bdk.EsploraClient(url = SIGNET_ESPLORA_URL)
full_scan_request: bdk.FullScanRequest = wallet.start_full_scan()
Expand All @@ -51,10 +53,12 @@ def test_synced_balance(self):


def test_broadcast_transaction(self):
connection: bdk.Connection = bdk.Connection.new_in_memory()
wallet: bdk.Wallet = bdk.Wallet(
descriptor,
change_descriptor,
bdk.Network.SIGNET
bdk.Network.SIGNET,
connection
)
esplora_client: bdk.EsploraClient = bdk.EsploraClient(url = SIGNET_ESPLORA_URL)
full_scan_request: bdk.FullScanRequest = wallet.start_full_scan()
Expand Down Expand Up @@ -92,4 +96,4 @@ def test_broadcast_transaction(self):


if __name__ == '__main__':
unittest.main()
unittest.main()
10 changes: 7 additions & 3 deletions bdk-python/tests/test_offline_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ def tearDown(self) -> None:
os.remove("./bdk_persistence.sqlite")

def test_new_address(self):
wallet: Wallet = bdk.Wallet(
connection: bdk.Connection = bdk.Connection.new_in_memory()
wallet: bdk.Wallet = bdk.Wallet(
descriptor,
change_descriptor,
bdk.Network.TESTNET
bdk.Network.TESTNET,
connection
)
address_info: bdk.AddressInfo = wallet.reveal_next_address(bdk.KeychainKind.EXTERNAL)

Expand All @@ -33,10 +35,12 @@ def test_new_address(self):
self.assertEqual("tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989", address_info.address.__str__())

def test_balance(self):
connection: bdk.Connection = bdk.Connection.new_in_memory()
wallet: bdk.Wallet = bdk.Wallet(
descriptor,
change_descriptor,
bdk.Network.TESTNET
bdk.Network.TESTNET,
connection
)

self.assertEqual(wallet.balance().total.to_sat(), 0)
Expand Down

0 comments on commit 52ee8a2

Please sign in to comment.