Skip to content

Commit

Permalink
test: Silent Payment labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunovo committed Oct 2, 2024
1 parent c445b64 commit 1df251b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/functional/wallet_silentpayments_receiving.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,31 @@ def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
self.skip_if_no_sqlite()

def test_labels(self):
self.log.info("Check Silent Payment Labels")

self.nodes[0].createwallet(wallet_name="labels", silent_payment=True)
wallet = self.nodes[0].get_wallet_rpc("labels")

labeled_sp_addr = wallet.getnewaddress(address_type="silent-payments", label="test")
addr_info = wallet.getaddressinfo(labeled_sp_addr)
assert_equal(addr_info["labels"][0], "test")
assert_equal(wallet.listlabels(), ["test"])
assert_raises_rpc_error(-11, "No addresses with label test", wallet.getaddressesbylabel, "test") # SP destination is ignored

self.def_wallet.sendtoaddress(labeled_sp_addr, 10)
self.generate(self.nodes[0], 1)

addresses = wallet.getaddressesbylabel("test")
sp_taproot_spk_addr = list(addresses)[0]
assert_equal(len(addresses), 1)
assert_equal(addresses[sp_taproot_spk_addr]["purpose"], "receive")
assert_equal(wallet.getaddressinfo(sp_taproot_spk_addr)["labels"][0], "test")
wallet_txs_by_label = wallet.listreceivedbylabel()
assert_equal(wallet_txs_by_label[0]["amount"], 10)
assert_equal(wallet_txs_by_label[0]["label"], "test")
assert_equal(wallet.getreceivedbylabel("test"), 10)

def test_encrypt_and_decrypt(self):
self.log.info("Check that a silent payments wallet can be encrypted and decrypted")
self.log.info("Create encrypted wallet")
Expand Down Expand Up @@ -171,6 +196,7 @@ def run_test(self):
self.test_encrypting_unencrypted()
self.test_basic()
self.test_import_rescan()
self.test_labels()


if __name__ == '__main__':
Expand Down

0 comments on commit 1df251b

Please sign in to comment.