def test_update_taa_aml( config_req_handler: ConfigReqHandler, taa_aml_input_data, taa_aml_expected_state_data, taa_aml_expected_data): """ `update_txn_author_agreement` updates state properly """ state = config_req_handler.state written = [] def _check_state(version): expected_data = taa_aml_expected_data[version] _data = state.get( ConfigReqHandler._state_path_taa_aml_version(version), isCommitted=False ) if version in written: assert (config_state_serializer.deserialize(_data)[VALUE] == config_state_serializer.deserialize(expected_data)) else: assert _data is None for data in taa_aml_input_data: config_req_handler.update_txn_author_agreement_acceptance_mechanisms( {AML_VERSION: data.version, AML: data.aml, AML_CONTEXT: data.amlContext}, data.seq_no, data.txn_time) written.append(data.version) data_d = data._asdict() assert state.get( ConfigReqHandler._state_path_taa_aml_latest(), isCommitted=False) == encode_state_value({AML_CONTEXT: data_d[AML_CONTEXT], AML: data_d[AML], AML_VERSION: data_d[AML_VERSION] }, data_d['seq_no'], data_d['txn_time']) for version in taa_aml_expected_state_data: _check_state(version)
def test_state_path_taa_aml_latest(): assert ConfigReqHandler._state_path_taa_aml_latest() == b'3:latest'