forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add receiving functional test
- Loading branch information
Showing
3 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from test_framework.test_framework import BitcoinTestFramework | ||
from test_framework.util import ( | ||
assert_equal, | ||
assert_raises_rpc_error, | ||
) | ||
|
||
|
||
class SilentPaymentsReceivingTest(BitcoinTestFramework): | ||
def add_options(self, parser): | ||
self.add_wallet_options(parser, legacy=False) | ||
|
||
def set_test_params(self): | ||
self.setup_clean_chain = True | ||
self.num_nodes = 1 | ||
|
||
def skip_test_if_missing_module(self): | ||
self.skip_if_no_wallet() | ||
self.skip_if_no_sqlite() | ||
|
||
def test_createwallet(self): | ||
self.log.info("Check createwallet silent payments option") | ||
|
||
self.nodes[0].createwallet(wallet_name="sp", silent_payment=True) | ||
wallet = self.nodes[0].get_wallet_rpc("sp") | ||
addr = wallet.getnewaddress(address_type="silent-payment") | ||
assert addr.startswith("sp") | ||
addr_again = wallet.getnewaddress(address_type="silent-payment") | ||
assert_equal(addr, addr_again) | ||
|
||
self.nodes[0].createwallet(wallet_name="non_sp", silent_payment=False) | ||
wallet = self.nodes[0].get_wallet_rpc("non_sp") | ||
assert_raises_rpc_error(-12, "Error: No silent-payment addresses available", wallet.getnewaddress, address_type="silent-payment") | ||
|
||
if self.is_bdb_compiled(): | ||
assert_raises_rpc_error(-4, "Wallet with silent payments must also be a descriptor wallet", self.nodes[0].createwallet, wallet_name="legacy_sp", descriptors=False, silent_payment=True) | ||
|
||
self.nodes[0].createwallet(wallet_name="legacy_sp", descriptors=False) | ||
wallet = self.nodes[0].get_wallet_rpc("legacy_sp") | ||
assert_raises_rpc_error(-12, "Error: No silent-payment addresses available", wallet.getnewaddress, address_type="silent-payment") | ||
|
||
def run_test(self): | ||
self.test_createwallet() | ||
|
||
|
||
if __name__ == '__main__': | ||
SilentPaymentsReceivingTest().main() |