(self)
| 544 | assert_equal(bals, wallet.getbalances()) |
| 545 | |
| 546 | def test_encrypted(self): |
| 547 | self.log.info("Test migration of an encrypted wallet") |
| 548 | wallet = self.create_legacy_wallet("encrypted") |
| 549 | default = self.master_node.get_wallet_rpc(self.default_wallet_name) |
| 550 | |
| 551 | wallet.encryptwallet("pass") |
| 552 | addr = wallet.getnewaddress() |
| 553 | txid = default.sendtoaddress(addr, 1) |
| 554 | self.generate(self.master_node, 1) |
| 555 | bals = wallet.getbalances() |
| 556 | bals["mine"]["nonmempool"] = Decimal('0.0') |
| 557 | |
| 558 | # Use self.migrate_and_get_rpc to test this error to get everything copied over to the master node |
| 559 | assert_raises_rpc_error(-4, "Error: Wallet decryption failed, the wallet passphrase was not provided or was incorrect", self.migrate_and_get_rpc, "encrypted") |
| 560 | |
| 561 | # Use the RPC directly on the master node for the rest of these checks |
| 562 | self.master_node.bumpmocktime(1) # Prevents filename duplication on wallet backups which is a problem on Windows |
| 563 | assert_raises_rpc_error(-4, "Error: Wallet decryption failed, the wallet passphrase was not provided or was incorrect", self.master_node.migratewallet, "encrypted", "badpass") |
| 564 | |
| 565 | self.master_node.bumpmocktime(1) # Prevents filename duplication on wallet backups which is a problem on Windows |
| 566 | assert_raises_rpc_error(-4, "The passphrase contains a null character", self.master_node.migratewallet, "encrypted", "pass\0with\0null") |
| 567 | |
| 568 | # Verify we can properly migrate the encrypted wallet |
| 569 | self.master_node.bumpmocktime(1) # Prevents filename duplication on wallet backups which is a problem on Windows |
| 570 | self.master_node.migratewallet("encrypted", passphrase="pass") |
| 571 | wallet = self.master_node.get_wallet_rpc("encrypted") |
| 572 | |
| 573 | info = wallet.getwalletinfo() |
| 574 | assert_equal(info["descriptors"], True) |
| 575 | assert_equal(info["format"], "sqlite") |
| 576 | assert_equal(info["unlocked_until"], 0) |
| 577 | wallet.gettransaction(txid) |
| 578 | |
| 579 | assert_equal(bals, wallet.getbalances()) |
| 580 | |
| 581 | def test_nonexistent(self): |
| 582 | self.log.info("Check migratewallet errors for nonexistent wallets") |
no test coverage detected