mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
datastore: docs, schemas, and a test.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
1b48545e5b
commit
dfe2693bbd
@@ -2624,3 +2624,56 @@ def test_force_feerates(node_factory):
|
||||
"penalty": 6666,
|
||||
"min_acceptable": 1875,
|
||||
"max_acceptable": 150000}
|
||||
|
||||
|
||||
def test_datastore(node_factory):
|
||||
l1 = node_factory.get_node()
|
||||
|
||||
# Starts empty
|
||||
assert l1.rpc.listdatastore() == {'datastore': []}
|
||||
assert l1.rpc.listdatastore('somekey') == {'datastore': []}
|
||||
|
||||
# Add entries.
|
||||
somedata = b'somedata'.hex()
|
||||
assert l1.rpc.datastore('somekey', somedata) == {'key': 'somekey',
|
||||
'hex': somedata}
|
||||
|
||||
assert l1.rpc.listdatastore() == {'datastore': [{'key': 'somekey',
|
||||
'hex': somedata}]}
|
||||
assert l1.rpc.listdatastore('somekey') == {'datastore': [{'key': 'somekey',
|
||||
'hex': somedata}]}
|
||||
assert l1.rpc.listdatastore('otherkey') == {'datastore': []}
|
||||
|
||||
otherdata = b'otherdata'.hex()
|
||||
assert l1.rpc.datastore('otherkey', otherdata) == {'key': 'otherkey',
|
||||
'hex': otherdata}
|
||||
|
||||
assert l1.rpc.listdatastore('somekey') == {'datastore': [{'key': 'somekey',
|
||||
'hex': somedata}]}
|
||||
assert l1.rpc.listdatastore('otherkey') == {'datastore': [{'key': 'otherkey',
|
||||
'hex': otherdata}]}
|
||||
assert l1.rpc.listdatastore('badkey') == {'datastore': []}
|
||||
|
||||
ds = l1.rpc.listdatastore()
|
||||
# Order is undefined!
|
||||
assert (ds == {'datastore': [{'key': 'somekey', 'hex': somedata},
|
||||
{'key': 'otherkey', 'hex': otherdata}]}
|
||||
or ds == {'datastore': [{'key': 'otherkey', 'hex': otherdata},
|
||||
{'key': 'somekey', 'hex': somedata}]})
|
||||
|
||||
assert l1.rpc.deldatastore('somekey') == {'key': 'somekey',
|
||||
'hex': somedata}
|
||||
assert l1.rpc.listdatastore() == {'datastore': [{'key': 'otherkey',
|
||||
'hex': otherdata}]}
|
||||
assert l1.rpc.listdatastore('somekey') == {'datastore': []}
|
||||
assert l1.rpc.listdatastore('otherkey') == {'datastore': [{'key': 'otherkey',
|
||||
'hex': otherdata}]}
|
||||
assert l1.rpc.listdatastore('badkey') == {'datastore': []}
|
||||
assert l1.rpc.listdatastore() == {'datastore': [{'key': 'otherkey',
|
||||
'hex': otherdata}]}
|
||||
|
||||
# It's persistent
|
||||
l1.restart()
|
||||
|
||||
assert l1.rpc.listdatastore() == {'datastore': [{'key': 'otherkey',
|
||||
'hex': otherdata}]}
|
||||
|
||||
Reference in New Issue
Block a user