-
Notifications
You must be signed in to change notification settings - Fork 651
Expand file tree
/
Copy pathtest_attrib_reply.py
More file actions
39 lines (27 loc) · 1.64 KB
/
test_attrib_reply.py
File metadata and controls
39 lines (27 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import json
from indy_node.test.indy_vdr_ledger import build_attrib_request
from indy_node.test.api.helper import validate_write_reply, validate_attrib_txn
from plenum.test.helper import sdk_get_reply, sdk_sign_and_submit_req
from hashlib import sha256
def execute_attrib_txn(looper, sdk_pool_handle, sdk_wallet_steward, xhash, raw, enc):
_, identifier = sdk_wallet_steward
request = looper.loop.run_until_complete(build_attrib_request(identifier, identifier, xhash, raw, enc))
return sdk_get_reply(looper, sdk_sign_and_submit_req(sdk_pool_handle, sdk_wallet_steward, request))[1]
def test_attrib_xhash_reply_is_valid(looper, sdk_pool_handle, sdk_wallet_steward):
xhash = sha256("Hello, world".encode()).hexdigest()
reply = execute_attrib_txn(looper, sdk_pool_handle, sdk_wallet_steward, xhash, None, None)
validate_write_reply(reply)
validate_attrib_txn(reply['result']['txn'])
assert reply['result']['txn']['data']['hash'] == xhash
def test_attrib_raw_reply_is_valid(looper, sdk_pool_handle, sdk_wallet_steward):
raw = json.dumps({'answer': 42})
reply = execute_attrib_txn(looper, sdk_pool_handle, sdk_wallet_steward, None, raw, None)
validate_write_reply(reply)
validate_attrib_txn(reply['result']['txn'])
assert json.loads(reply['result']['txn']['data']['raw']) == json.loads(raw)
def test_attrib_enc_reply_is_valid(looper, sdk_pool_handle, sdk_wallet_steward):
enc = "amgine"
reply = execute_attrib_txn(looper, sdk_pool_handle, sdk_wallet_steward, None, None, enc)
validate_write_reply(reply)
validate_attrib_txn(reply['result']['txn'])
assert reply['result']['txn']['data']['enc'] == enc