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 Sep 27, 2024
1 parent 0850f8a commit 6f2120b
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-payment", label="test")
addr_info = wallet.getaddressinfo(labeled_sp_addr)
assert addr_info["labels"][0] == "test"
assert wallet.listlabels() == ["test"]
assert_raises_rpc_error(-11, "No addresses with label test", wallet.getaddressesbylabel, "test") # SP destination is ignored

txid = 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 len(addresses) == 1
assert addresses[sp_taproot_spk_addr]["purpose"] == "receive"
assert wallet.getaddressinfo(sp_taproot_spk_addr)["labels"][0] == "test"
wallet_txs_by_label = wallet.listreceivedbylabel()
assert wallet_txs_by_label[0]["amount"] == 10
assert wallet_txs_by_label[0]["label"] == "test"
assert 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 6f2120b

Please sign in to comment.