Changeset View
Changeset View
Standalone View
Standalone View
test/functional/tool_wallet.py
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | def test_tool_wallet_info(self): | ||||
# The following lines should be uncommented and the tests still succeed: | # The following lines should be uncommented and the tests still succeed: | ||||
# | # | ||||
# self.log.debug('Setting wallet file permissions to 400 (read-only)') | # self.log.debug('Setting wallet file permissions to 400 (read-only)') | ||||
# os.chmod(self.wallet_path, stat.S_IRUSR) | # os.chmod(self.wallet_path, stat.S_IRUSR) | ||||
# assert self.wallet_permissions() in ['400', '666'] # Sanity check. 666 because Appveyor. | # assert self.wallet_permissions() in ['400', '666'] # Sanity check. 666 because Appveyor. | ||||
# shasum_before = self.wallet_shasum() | # shasum_before = self.wallet_shasum() | ||||
timestamp_before = self.wallet_timestamp() | timestamp_before = self.wallet_timestamp() | ||||
self.log.debug(f"Wallet file timestamp before calling info: {timestamp_before}") | self.log.debug(f"Wallet file timestamp before calling info: {timestamp_before}") | ||||
out = textwrap.dedent( | out = textwrap.dedent("""\ | ||||
"""\ | |||||
Wallet info | Wallet info | ||||
=========== | =========== | ||||
Encrypted: no | Encrypted: no | ||||
HD (hd seed available): yes | HD (hd seed available): yes | ||||
Keypool Size: 2 | Keypool Size: 2 | ||||
Transactions: 0 | Transactions: 0 | ||||
Address Book: 1 | Address Book: 1 | ||||
""" | """) | ||||
) | |||||
self.assert_tool_output(out, f"-wallet={self.default_wallet_name}", "info") | self.assert_tool_output(out, f"-wallet={self.default_wallet_name}", "info") | ||||
timestamp_after = self.wallet_timestamp() | timestamp_after = self.wallet_timestamp() | ||||
self.log.debug(f"Wallet file timestamp after calling info: {timestamp_after}") | self.log.debug(f"Wallet file timestamp after calling info: {timestamp_after}") | ||||
self.log_wallet_timestamp_comparison(timestamp_before, timestamp_after) | self.log_wallet_timestamp_comparison(timestamp_before, timestamp_after) | ||||
self.log.debug("Setting wallet file permissions back to 600 (read/write)") | self.log.debug("Setting wallet file permissions back to 600 (read/write)") | ||||
os.chmod(self.wallet_path, stat.S_IRUSR | stat.S_IWUSR) | os.chmod(self.wallet_path, stat.S_IRUSR | stat.S_IWUSR) | ||||
# Sanity check. 666 because Appveyor. | # Sanity check. 666 because Appveyor. | ||||
assert self.wallet_permissions() in ["600", "666"] | assert self.wallet_permissions() in ["600", "666"] | ||||
Show All 17 Lines | def test_tool_wallet_info_after_transaction(self): | ||||
self.stop_node(0) | self.stop_node(0) | ||||
self.log.info( | self.log.info( | ||||
"Calling wallet tool info after generating a transaction, testing output" | "Calling wallet tool info after generating a transaction, testing output" | ||||
) | ) | ||||
shasum_before = self.wallet_shasum() | shasum_before = self.wallet_shasum() | ||||
timestamp_before = self.wallet_timestamp() | timestamp_before = self.wallet_timestamp() | ||||
self.log.debug(f"Wallet file timestamp before calling info: {timestamp_before}") | self.log.debug(f"Wallet file timestamp before calling info: {timestamp_before}") | ||||
out = textwrap.dedent( | out = textwrap.dedent("""\ | ||||
"""\ | |||||
Wallet info | Wallet info | ||||
=========== | =========== | ||||
Encrypted: no | Encrypted: no | ||||
HD (hd seed available): yes | HD (hd seed available): yes | ||||
Keypool Size: 2 | Keypool Size: 2 | ||||
Transactions: 1 | Transactions: 1 | ||||
Address Book: 1 | Address Book: 1 | ||||
""" | """) | ||||
) | |||||
self.assert_tool_output(out, f"-wallet={self.default_wallet_name}", "info") | self.assert_tool_output(out, f"-wallet={self.default_wallet_name}", "info") | ||||
shasum_after = self.wallet_shasum() | shasum_after = self.wallet_shasum() | ||||
timestamp_after = self.wallet_timestamp() | timestamp_after = self.wallet_timestamp() | ||||
self.log.debug(f"Wallet file timestamp after calling info: {timestamp_after}") | self.log.debug(f"Wallet file timestamp after calling info: {timestamp_after}") | ||||
self.log_wallet_timestamp_comparison(timestamp_before, timestamp_after) | self.log_wallet_timestamp_comparison(timestamp_before, timestamp_after) | ||||
# | # | ||||
# TODO: Wallet tool info should not write to the wallet file. | # TODO: Wallet tool info should not write to the wallet file. | ||||
# This assertion should be uncommented and succeed: | # This assertion should be uncommented and succeed: | ||||
# assert_equal(timestamp_before, timestamp_after) | # assert_equal(timestamp_before, timestamp_after) | ||||
assert_equal(shasum_before, shasum_after) | assert_equal(shasum_before, shasum_after) | ||||
self.log.debug("Wallet file shasum unchanged\n") | self.log.debug("Wallet file shasum unchanged\n") | ||||
def test_tool_wallet_create_on_existing_wallet(self): | def test_tool_wallet_create_on_existing_wallet(self): | ||||
self.log.info( | self.log.info( | ||||
"Calling wallet tool create on an existing wallet, testing output" | "Calling wallet tool create on an existing wallet, testing output" | ||||
) | ) | ||||
shasum_before = self.wallet_shasum() | shasum_before = self.wallet_shasum() | ||||
timestamp_before = self.wallet_timestamp() | timestamp_before = self.wallet_timestamp() | ||||
self.log.debug( | self.log.debug( | ||||
f"Wallet file timestamp before calling create: {timestamp_before}" | f"Wallet file timestamp before calling create: {timestamp_before}" | ||||
) | ) | ||||
out = textwrap.dedent( | out = textwrap.dedent("""\ | ||||
"""\ | |||||
Topping up keypool... | Topping up keypool... | ||||
Wallet info | Wallet info | ||||
=========== | =========== | ||||
Encrypted: no | Encrypted: no | ||||
HD (hd seed available): yes | HD (hd seed available): yes | ||||
Keypool Size: 2000 | Keypool Size: 2000 | ||||
Transactions: 0 | Transactions: 0 | ||||
Address Book: 0 | Address Book: 0 | ||||
""" | """) | ||||
) | |||||
self.assert_tool_output(out, "-wallet=foo", "create") | self.assert_tool_output(out, "-wallet=foo", "create") | ||||
shasum_after = self.wallet_shasum() | shasum_after = self.wallet_shasum() | ||||
timestamp_after = self.wallet_timestamp() | timestamp_after = self.wallet_timestamp() | ||||
self.log.debug(f"Wallet file timestamp after calling create: {timestamp_after}") | self.log.debug(f"Wallet file timestamp after calling create: {timestamp_after}") | ||||
self.log_wallet_timestamp_comparison(timestamp_before, timestamp_after) | self.log_wallet_timestamp_comparison(timestamp_before, timestamp_after) | ||||
assert_equal(timestamp_before, timestamp_after) | assert_equal(timestamp_before, timestamp_after) | ||||
assert_equal(shasum_before, shasum_after) | assert_equal(shasum_before, shasum_after) | ||||
self.log.debug("Wallet file shasum unchanged\n") | self.log.debug("Wallet file shasum unchanged\n") | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |