forked from LBRYCommunity/lbry-sdk
Merge pull request #3003 from lbryio/more_timestamp_fix
fix `modified_on` to always cast value to integer, also cast preferences timestamp to int
This commit is contained in:
commit
e033129dd3
4 changed files with 9 additions and 9 deletions
|
@ -311,7 +311,7 @@ class Account:
|
||||||
private_key=private_key,
|
private_key=private_key,
|
||||||
public_key=public_key,
|
public_key=public_key,
|
||||||
address_generator=d.get('address_generator', {}),
|
address_generator=d.get('address_generator', {}),
|
||||||
modified_on=d.get('modified_on', int(time.time())),
|
modified_on=int(d.get('modified_on', time.time())),
|
||||||
channel_keys=d.get('certificates', {})
|
channel_keys=d.get('certificates', {})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ class Account:
|
||||||
def merge(self, d: dict):
|
def merge(self, d: dict):
|
||||||
if d.get('modified_on', 0) > self.modified_on:
|
if d.get('modified_on', 0) > self.modified_on:
|
||||||
self.name = d['name']
|
self.name = d['name']
|
||||||
self.modified_on = d.get('modified_on', int(time.time()))
|
self.modified_on = int(d.get('modified_on', time.time()))
|
||||||
assert self.address_generator.name == d['address_generator']['name']
|
assert self.address_generator.name == d['address_generator']['name']
|
||||||
for chain_name in ('change', 'receiving'):
|
for chain_name in ('change', 'receiving'):
|
||||||
if chain_name in d['address_generator']:
|
if chain_name in d['address_generator']:
|
||||||
|
|
|
@ -35,7 +35,7 @@ class TimestampedPreferences(UserDict):
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
self.data[key] = {
|
self.data[key] = {
|
||||||
'value': value,
|
'value': value,
|
||||||
'ts': time.time()
|
'ts': int(time.time())
|
||||||
}
|
}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
|
@ -132,7 +132,7 @@ class TestAccount(AsyncioTestCase):
|
||||||
async def test_load_and_save_account(self):
|
async def test_load_and_save_account(self):
|
||||||
account_data = {
|
account_data = {
|
||||||
'name': 'Main Account',
|
'name': 'Main Account',
|
||||||
'modified_on': 123.456,
|
'modified_on': 123,
|
||||||
'seed':
|
'seed':
|
||||||
"carbon smart garage balance margin twelve chest sword toast envelope bottom stomac"
|
"carbon smart garage balance margin twelve chest sword toast envelope bottom stomac"
|
||||||
"h absent",
|
"h absent",
|
||||||
|
@ -183,7 +183,7 @@ class TestAccount(AsyncioTestCase):
|
||||||
def test_merge_diff(self):
|
def test_merge_diff(self):
|
||||||
account_data = {
|
account_data = {
|
||||||
'name': 'My Account',
|
'name': 'My Account',
|
||||||
'modified_on': 123.456,
|
'modified_on': 123,
|
||||||
'seed':
|
'seed':
|
||||||
"carbon smart garage balance margin twelve chest sword toast envelope bottom stomac"
|
"carbon smart garage balance margin twelve chest sword toast envelope bottom stomac"
|
||||||
"h absent",
|
"h absent",
|
||||||
|
@ -203,7 +203,7 @@ class TestAccount(AsyncioTestCase):
|
||||||
account = Account.from_dict(self.ledger, Wallet(), account_data)
|
account = Account.from_dict(self.ledger, Wallet(), account_data)
|
||||||
|
|
||||||
self.assertEqual(account.name, 'My Account')
|
self.assertEqual(account.name, 'My Account')
|
||||||
self.assertEqual(account.modified_on, 123.456)
|
self.assertEqual(account.modified_on, 123)
|
||||||
self.assertEqual(account.change.gap, 5)
|
self.assertEqual(account.change.gap, 5)
|
||||||
self.assertEqual(account.change.maximum_uses_per_address, 2)
|
self.assertEqual(account.change.maximum_uses_per_address, 2)
|
||||||
self.assertEqual(account.receiving.gap, 5)
|
self.assertEqual(account.receiving.gap, 5)
|
||||||
|
@ -366,7 +366,7 @@ class TestSingleKeyAccount(AsyncioTestCase):
|
||||||
async def test_load_and_save_account(self):
|
async def test_load_and_save_account(self):
|
||||||
account_data = {
|
account_data = {
|
||||||
'name': 'My Account',
|
'name': 'My Account',
|
||||||
'modified_on': 123.456,
|
'modified_on': 123,
|
||||||
'seed':
|
'seed':
|
||||||
"carbon smart garage balance margin twelve chest sword toast envelope bottom stomac"
|
"carbon smart garage balance margin twelve chest sword toast envelope bottom stomac"
|
||||||
"h absent",
|
"h absent",
|
||||||
|
|
|
@ -38,7 +38,7 @@ class TestWalletCreation(AsyncioTestCase):
|
||||||
'certificates': {},
|
'certificates': {},
|
||||||
'name': 'An Account',
|
'name': 'An Account',
|
||||||
'ledger': 'lbc_mainnet',
|
'ledger': 'lbc_mainnet',
|
||||||
'modified_on': 123.456,
|
'modified_on': 123,
|
||||||
'seed':
|
'seed':
|
||||||
"carbon smart garage balance margin twelve chest sword toast envelope bottom stomac"
|
"carbon smart garage balance margin twelve chest sword toast envelope bottom stomac"
|
||||||
"h absent",
|
"h absent",
|
||||||
|
@ -62,7 +62,7 @@ class TestWalletCreation(AsyncioTestCase):
|
||||||
wallet = Wallet.from_storage(storage, self.manager)
|
wallet = Wallet.from_storage(storage, self.manager)
|
||||||
self.assertEqual(wallet.name, 'Main Wallet')
|
self.assertEqual(wallet.name, 'Main Wallet')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
hexlify(wallet.hash), b'a75913d2e7339c1a9ac0c89d621a4e10fd3a40dc3560dc01f4cf4ada0a0b05b8'
|
hexlify(wallet.hash), b'869acc4660dde0f13784ed743796adf89562cdf79fdfc9e5c6dbea98d62ccf90'
|
||||||
)
|
)
|
||||||
self.assertEqual(len(wallet.accounts), 1)
|
self.assertEqual(len(wallet.accounts), 1)
|
||||||
account = wallet.default_account
|
account = wallet.default_account
|
||||||
|
|
Loading…
Reference in a new issue