def test_send_valid_txn_athr_agrmt_succeeds(looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_trustee): req = looper.loop.run_until_complete( prepare_txn_author_agreement(sdk_wallet_trustee[1])) rep = sdk_sign_and_send_prepared_request(looper, sdk_wallet_trustee, sdk_pool_handle, req) sdk_get_and_check_replies(looper, [rep]) req = json.loads(req) version = req[OPERATION][TXN_AUTHOR_AGREEMENT_VERSION] text = req[OPERATION][TXN_AUTHOR_AGREEMENT_TEXT] digest = ConfigReqHandler._taa_digest(version, text) # TODO: Replace this with get transaction ensure_all_nodes_have_same_data(looper, txnPoolNodeSet) for node in txnPoolNodeSet: config_req_handler = get_config_req_handler(node) assert config_req_handler.get_taa_digest() == digest.encode() assert config_req_handler.get_taa_digest(version) == digest.encode() taa = config_req_handler.state.get( ConfigReqHandler._state_path_taa_digest(digest)) assert taa is not None taa = json.loads(taa.decode()) assert taa[TXN_AUTHOR_AGREEMENT_VERSION] == version assert taa[TXN_AUTHOR_AGREEMENT_TEXT] == text
def test_update_txn_author_agreement(config_req_handler: ConfigReqHandler): version = 'Some version' text = 'Some agreement' agreement = {TXN_AUTHOR_AGREEMENT_VERSION: version, TXN_AUTHOR_AGREEMENT_TEXT: text} digest = ConfigReqHandler._taa_digest(version, text) config_req_handler.update_txn_author_agreement(agreement) state = config_req_handler.state assert state.get(ConfigReqHandler._state_path_taa_latest(), isCommitted=False) == digest.encode() assert state.get(ConfigReqHandler._state_path_taa_version(version), isCommitted=False) == digest.encode() taa = state.get(ConfigReqHandler._state_path_taa_digest(digest), isCommitted=False) assert taa is not None taa = json.loads(taa.decode()) assert taa.get(TXN_AUTHOR_AGREEMENT_VERSION) == version assert taa.get(TXN_AUTHOR_AGREEMENT_TEXT) == text
def _check_state(version): digest = taa_expected_digests[version] _digest = state.get( ConfigReqHandler._state_path_taa_version(version), isCommitted=False ) _data = state.get( ConfigReqHandler._state_path_taa_digest(digest), isCommitted=False ) if version in written: assert _digest == digest.encode() assert ( config_state_serializer.deserialize(_data) == taa_expected_state_data[version] ) else: assert _digest is None assert _data is None
def test_state_path_taa_digest(): assert ConfigReqHandler._state_path_taa_digest('some_digest') == b'taa:d:some_digest'