def run_test(self):
    passphrase = 'WalletPassphrase'
    passphrase2 = 'SecondWalletPassphrase'
    address = self.nodes[0].getnewaddress()
    privkey = self.nodes[0].dumpprivkey(address)
    assert_equal(privkey[:1], 'c')
    assert_equal(len(privkey), 52)
    self.nodes[0].node_encrypt_wallet(passphrase)
    self.start_node(0)
    assert_raises_rpc_error((- 13), 'Please enter the wallet passphrase with walletpassphrase first', self.nodes[0].dumpprivkey, address)
    self.nodes[0].walletpassphrase(passphrase, 2)
    assert_equal(privkey, self.nodes[0].dumpprivkey(address))
    time.sleep(2)
    assert_raises_rpc_error((- 13), 'Please enter the wallet passphrase with walletpassphrase first', self.nodes[0].dumpprivkey, address)
    assert_raises_rpc_error((- 14), 'wallet passphrase entered was incorrect', self.nodes[0].walletpassphrase, (passphrase + 'wrong'), 10)
    self.nodes[0].walletpassphrase(passphrase, 84600)
    assert_equal(privkey, self.nodes[0].dumpprivkey(address))
    self.nodes[0].walletlock()
    assert_raises_rpc_error((- 13), 'Please enter the wallet passphrase with walletpassphrase first', self.nodes[0].dumpprivkey, address)
    self.nodes[0].walletpassphrase(passphrase, 12000, True)
    assert_raises_rpc_error((- 17), 'Wallet is already unlocked', self.nodes[0].walletpassphrase, passphrase, 100, True)
    self.nodes[0].walletlock()
    self.nodes[0].walletpassphrasechange(passphrase, passphrase2)
    assert_raises_rpc_error((- 14), 'wallet passphrase entered was incorrect', self.nodes[0].walletpassphrase, passphrase, 10)
    self.nodes[0].walletpassphrase(passphrase2, 10)
    assert_equal(privkey, self.nodes[0].dumpprivkey(address))
    self.nodes[0].walletlock()
    assert_raises_rpc_error((- 8), 'Timeout cannot be negative.', self.nodes[0].walletpassphrase, passphrase2, (- 10))
    MAX_VALUE = 100000000
    expected_time = ((int(time.time()) + MAX_VALUE) - 600)
    self.nodes[0].walletpassphrase(passphrase2, (MAX_VALUE - 600))
    actual_time = self.nodes[0].getwalletinfo()['unlocked_until']
    assert_greater_than_or_equal(actual_time, expected_time)
    assert_greater_than((expected_time + 5), actual_time)
    expected_time = ((int(time.time()) + MAX_VALUE) - 1)
    self.nodes[0].walletpassphrase(passphrase2, (MAX_VALUE + 1000))
    actual_time = self.nodes[0].getwalletinfo()['unlocked_until']
    assert_greater_than_or_equal(actual_time, expected_time)
    assert_greater_than((expected_time + 5), actual_time)
def run_test(self):
    passphrase = 'WalletPassphrase'
    passphrase2 = 'SecondWalletPassphrase'
    address = self.nodes[0].getnewaddress()
    privkey = self.nodes[0].dumpprivkey(address)
    assert_equal(privkey[:1], 'c')
    assert_equal(len(privkey), 52)
    self.nodes[0].node_encrypt_wallet(passphrase)
    self.start_node(0)
    assert_raises_rpc_error((- 13), 'Please enter the wallet passphrase with walletpassphrase first', self.nodes[0].dumpprivkey, address)
    self.nodes[0].walletpassphrase(passphrase, 2)
    assert_equal(privkey, self.nodes[0].dumpprivkey(address))
    time.sleep(2)
    assert_raises_rpc_error((- 13), 'Please enter the wallet passphrase with walletpassphrase first', self.nodes[0].dumpprivkey, address)
    assert_raises_rpc_error((- 14), 'wallet passphrase entered was incorrect', self.nodes[0].walletpassphrase, (passphrase + 'wrong'), 10)
    self.nodes[0].walletpassphrase(passphrase, 84600)
    assert_equal(privkey, self.nodes[0].dumpprivkey(address))
    self.nodes[0].walletlock()
    assert_raises_rpc_error((- 13), 'Please enter the wallet passphrase with walletpassphrase first', self.nodes[0].dumpprivkey, address)
    self.nodes[0].walletpassphrase(passphrase, 12000, True)
    assert_raises_rpc_error((- 17), 'Wallet is already unlocked', self.nodes[0].walletpassphrase, passphrase, 100, True)
    self.nodes[0].walletlock()
    self.nodes[0].walletpassphrasechange(passphrase, passphrase2)
    assert_raises_rpc_error((- 14), 'wallet passphrase entered was incorrect', self.nodes[0].walletpassphrase, passphrase, 10)
    self.nodes[0].walletpassphrase(passphrase2, 10)
    assert_equal(privkey, self.nodes[0].dumpprivkey(address))
    self.nodes[0].walletlock()
    assert_raises_rpc_error((- 8), 'Timeout cannot be negative.', self.nodes[0].walletpassphrase, passphrase2, (- 10))
    MAX_VALUE = 100000000
    expected_time = ((int(time.time()) + MAX_VALUE) - 600)
    self.nodes[0].walletpassphrase(passphrase2, (MAX_VALUE - 600))
    actual_time = self.nodes[0].getwalletinfo()['unlocked_until']
    assert_greater_than_or_equal(actual_time, expected_time)
    assert_greater_than((expected_time + 5), actual_time)
    expected_time = ((int(time.time()) + MAX_VALUE) - 1)
    self.nodes[0].walletpassphrase(passphrase2, (MAX_VALUE + 1000))
    actual_time = self.nodes[0].getwalletinfo()['unlocked_until']
    assert_greater_than_or_equal(actual_time, expected_time)
    assert_greater_than((expected_time + 5), actual_time)