Skip to content

Commit

Permalink
Merge pull request #152 from neonlabsorg/NDEV-2257
Browse files Browse the repository at this point in the history
Ndev 2257
  • Loading branch information
lyubenkov authored Oct 6, 2023
2 parents fa592bd + f4aef21 commit b83b35c
Show file tree
Hide file tree
Showing 15 changed files with 1,488 additions and 1,342 deletions.
10 changes: 10 additions & 0 deletions contracts/common/StorageSoliditySource.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ contract Storage {
return number;
}
}

contract StorageMultipleVars {
string public data = "test";
uint256 constant public number = 1;
uint256 public notSet;

function setData(string memory _data) public {
data = _data;
}
}
108 changes: 62 additions & 46 deletions docs/tests/audit/test_rpc_calls.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions integration/tests/basic/helpers/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ def wait_finalized_block(self, block_num: int):
response = self.proxy_api.send_rpc("neon_finalizedBlockNumber", [])
fin_block_num = int(response["result"], 16)

def make_contract_tx_object(self, sender=None, amount=0, estimate_gas=False) -> tp.Dict:
"""Can be used with build_transaction method"""
if sender is None:
sender = self.sender_account.address
return super().create_tx_object(sender, recipient=None, amount=amount, estimate_gas=estimate_gas)

def create_tx_object(self, sender=None, recipient=None, amount=2, nonce=None, gas=None, gas_price=None, data=None,
estimate_gas=True):
if sender is None:
Expand Down
16 changes: 16 additions & 0 deletions integration/tests/basic/helpers/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Error32000:
CODE = -32000
MISSING_ARGUMENT = "missing 1 required positional argument"


class Error32600:
CODE = -32600
INVALID_FILTER = "invalid filter"


class Error32602:
CODE = -32602
NOT_HEX = "is not hex"
BAD_BLOCK_HASH = "bad block hash"
BAD_ADDRESS = "bad address"
BAD_TOPIC = "bad topic"
29 changes: 26 additions & 3 deletions integration/tests/basic/helpers/rpc_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ def is_hex(hex_data: str) -> bool:
return False


def hex_str_consists_not_only_of_zeros(hex_data: str) -> bool:
"""Helps to verify that long response hex str data is not consists of just zeros"""
t = hex_data
if t.startswith("0x"):
t = hex_data.split("0x")[1]
for c in t:
if c != "0":
return True
return False


def assert_block_fields(block: dict, full_trx: bool, tx_receipt: tp.Optional[types.TxReceipt],
pending: bool = False):
assert "error" not in block
Expand Down Expand Up @@ -110,10 +121,22 @@ def assert_fields_are_boolean(object, expected_boolean_fields):
assert type(object[field]) == bool, f"field {field} is not boolean. Actual : {type(object[field])}"


def assert_equal_fields(response, receipt, comparable_fields):
def assert_equal_fields(result, comparable_object, comparable_fields, keys_mappings=None):
"""
Assert that fields in the result object are equal to fields in comparable_object
:param result:
:param comparable_object:
:param comparable_fields: list of comparable fields
:param keys_mappings: map name of the field in the result object to the field in comparable_object
:return:
"""
for field in comparable_fields:
l = response["result"][0][field]
r = receipt["logs"][0][field]
l = result[field]
if keys_mappings and keys_mappings.get(field):
r = comparable_object[keys_mappings.get(field)]
else:
r = comparable_object[field]
if isinstance(r, str):
r = r.lower()
if isinstance(r, int):
Expand Down
Empty file.
Loading

0 comments on commit b83b35c

Please sign in to comment.