mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-12 08:08:25 +00:00
Test walletpassphrase timeout bounds and clamping
This commit is contained in:
parent
0b63e3c7b2
commit
134cdc7cee
@ -10,6 +10,8 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||||||
from test_framework.util import (
|
from test_framework.util import (
|
||||||
assert_equal,
|
assert_equal,
|
||||||
assert_raises_rpc_error,
|
assert_raises_rpc_error,
|
||||||
|
assert_greater_than,
|
||||||
|
assert_greater_than_or_equal,
|
||||||
)
|
)
|
||||||
|
|
||||||
class WalletEncryptionTest(BitcoinTestFramework):
|
class WalletEncryptionTest(BitcoinTestFramework):
|
||||||
@ -56,6 +58,23 @@ class WalletEncryptionTest(BitcoinTestFramework):
|
|||||||
assert_raises_rpc_error(-14, "wallet passphrase entered was incorrect", self.nodes[0].walletpassphrase, passphrase, 10)
|
assert_raises_rpc_error(-14, "wallet passphrase entered was incorrect", self.nodes[0].walletpassphrase, passphrase, 10)
|
||||||
self.nodes[0].walletpassphrase(passphrase2, 10)
|
self.nodes[0].walletpassphrase(passphrase2, 10)
|
||||||
assert_equal(privkey, self.nodes[0].dumpprivkey(address))
|
assert_equal(privkey, self.nodes[0].dumpprivkey(address))
|
||||||
|
self.nodes[0].walletlock()
|
||||||
|
|
||||||
|
# Test timeout bounds
|
||||||
|
assert_raises_rpc_error(-8, "Timeout cannot be negative.", self.nodes[0].walletpassphrase, passphrase2, -10)
|
||||||
|
# Check the timeout
|
||||||
|
# Check a time less than the limit
|
||||||
|
expected_time = int(time.time()) + (1 << 30) - 600
|
||||||
|
self.nodes[0].walletpassphrase(passphrase2, (1 << 30) - 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) # 5 second buffer
|
||||||
|
# Check a time greater than the limit
|
||||||
|
expected_time = int(time.time()) + (1 << 30) - 1
|
||||||
|
self.nodes[0].walletpassphrase(passphrase2, (1 << 33))
|
||||||
|
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) # 5 second buffer
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
WalletEncryptionTest().main()
|
WalletEncryptionTest().main()
|
||||||
|
Loading…
Reference in New Issue
Block a user