-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement oracle commands from Neo-Express to the NeoTestRunner interface #1097
Conversation
…estRunner interface
tx._attributes = [] | ||
if 'attributes' in json: | ||
attributes_json = json['attributes'] | ||
|
||
for attribute in attributes_json: | ||
from boa3_test.test_drive.model.network.payloads.transactionattribute import \ | ||
TransactionAttributeType | ||
if attribute['type'] == TransactionAttributeType.ORACLE_RESPONSE: | ||
from boa3_test.test_drive.model.network.payloads.oracleresponse import OracleResponse | ||
tx._attributes.append(OracleResponse.from_json(attribute)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to move this logic to TransactionAttribute and import there the method from the respective classes to deserialize the given json. Something like the following:
tx._attributes = [] | |
if 'attributes' in json: | |
attributes_json = json['attributes'] | |
for attribute in attributes_json: | |
from boa3_test.test_drive.model.network.payloads.transactionattribute import \ | |
TransactionAttributeType | |
if attribute['type'] == TransactionAttributeType.ORACLE_RESPONSE: | |
from boa3_test.test_drive.model.network.payloads.oracleresponse import OracleResponse | |
tx._attributes.append(OracleResponse.from_json(attribute)) | |
if 'attributes' in json: | |
tx._attributes = [TransactionAttribute.from_json(atttribute) for attribute in json['attributes']] | |
else: | |
tx._attributes = [] |
@staticmethod | ||
def from_json(json: Dict[str, Any]) -> TransactionAttribute: | ||
tx_attr = TransactionAttribute(json['type']) | ||
|
||
return tx_attr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the above suggestion
@staticmethod | |
def from_json(json: Dict[str, Any]) -> TransactionAttribute: | |
tx_attr = TransactionAttribute(json['type']) | |
return tx_attr | |
@staticmethod | |
def from_json(cls, json: Dict[str, Any]) -> TransactionAttribute: | |
tx_type = json['type'] | |
if tx_type == TransactionAttributeType.ORACLE_RESPONSE: | |
from boa3_test.test_drive.model.network.payloads.oracleresponse import OracleResponse | |
tx_attr = OracleResponse._from_json(json) | |
else: | |
tx_attr = TransactionAttribute._from_json(json) | |
return tx_attr | |
@staticmethod | |
def _from_json(cls, json: Dict[str, Any]) -> TransactionAttribute: | |
# this one is implemented by OracleResponse | |
tx_attr = TransactionAttribute(json['type']) | |
return tx_attr |
…ransactionAttribute
Summary or solution description
Implemented the
neoxp oracle enable
andneoxp oracle response
commands. Added new tests with responses.How to Reproduce
neo3-boa/boa3_test/test_sc/native_test/oracle/OracleRequestCall.py
Lines 1 to 32 in 96a5d4b
Tests
neo3-boa/boa3_test/tests/compiler_tests/test_native/test_oracle.py
Lines 101 to 303 in 96a5d4b
Platform:
(Optional) Additional context
There was a problem when using a string that had white space, instead of writing
"A string here"
, it would write""A string here""
on the batch file.neo3-boa/boa3_test/test_drive/neoxp/command/neoexpresscommand/neoexpresscommand.py
Lines 33 to 34 in 96a5d4b