|
|
@ -29,89 +29,116 @@ def _test_blockchain_rpc(fn, *args, **kwargs): |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=1) |
|
|
|
@pytest.mark.run(order=1) |
|
|
|
def test_get_node_metadata(setup_blockchain): |
|
|
|
def test_get_node_metadata(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_node_metadata) |
|
|
|
metadata = _test_blockchain_rpc(blockchain.get_node_metadata) |
|
|
|
|
|
|
|
assert isinstance(metadata, dict) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=2) |
|
|
|
@pytest.mark.run(order=2) |
|
|
|
def test_get_sharding_structure(setup_blockchain): |
|
|
|
def test_get_sharding_structure(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_sharding_structure) |
|
|
|
sharding_structure = _test_blockchain_rpc(blockchain.get_sharding_structure) |
|
|
|
|
|
|
|
assert isinstance(sharding_structure, list) |
|
|
|
|
|
|
|
assert len(sharding_structure) > 0 |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=3) |
|
|
|
@pytest.mark.run(order=3) |
|
|
|
def test_get_leader_address(setup_blockchain): |
|
|
|
def test_get_leader_address(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_leader_address) |
|
|
|
leader = _test_blockchain_rpc(blockchain.get_leader_address) |
|
|
|
|
|
|
|
assert isinstance(leader, str) |
|
|
|
|
|
|
|
assert 'one1' in leader |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=4) |
|
|
|
@pytest.mark.run(order=4) |
|
|
|
def test_get_block_number(setup_blockchain): |
|
|
|
def test_get_block_number(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_block_number) |
|
|
|
current_block_number = _test_blockchain_rpc(blockchain.get_block_number) |
|
|
|
|
|
|
|
assert isinstance(current_block_number, int) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=5) |
|
|
|
@pytest.mark.run(order=5) |
|
|
|
def test_get_current_epoch(setup_blockchain): |
|
|
|
def test_get_current_epoch(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_current_epoch) |
|
|
|
current_epoch = _test_blockchain_rpc(blockchain.get_current_epoch) |
|
|
|
|
|
|
|
assert isinstance(current_epoch, int) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=6) |
|
|
|
@pytest.mark.run(order=6) |
|
|
|
def tset_get_gas_price(setup_blockchain): |
|
|
|
def tset_get_gas_price(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_gas_price) |
|
|
|
gas = _test_blockchain_rpc(blockchain.get_gas_price) |
|
|
|
|
|
|
|
assert isinstance(gas, int) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=7) |
|
|
|
@pytest.mark.run(order=7) |
|
|
|
def test_get_num_peers(setup_blockchain): |
|
|
|
def test_get_num_peers(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_num_peers) |
|
|
|
peers = _test_blockchain_rpc(blockchain.get_num_peers) |
|
|
|
|
|
|
|
assert isinstance(peers, int) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=8) |
|
|
|
@pytest.mark.run(order=8) |
|
|
|
def test_get_latest_header(setup_blockchain): |
|
|
|
def test_get_latest_header(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_latest_header) |
|
|
|
header = _test_blockchain_rpc(blockchain.get_latest_header) |
|
|
|
|
|
|
|
assert isinstance(header, dict) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=9) |
|
|
|
@pytest.mark.run(order=9) |
|
|
|
def test_get_latest_headers(setup_blockchain): |
|
|
|
def test_get_latest_headers(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_latest_headers) |
|
|
|
header_pair = _test_blockchain_rpc(blockchain.get_latest_headers) |
|
|
|
|
|
|
|
assert isinstance(header_pair, dict) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=10) |
|
|
|
@pytest.mark.run(order=10) |
|
|
|
def test_get_block_by_number(setup_blockchain): |
|
|
|
def test_get_block_by_number(setup_blockchain): |
|
|
|
global test_block_hash |
|
|
|
global test_block_hash |
|
|
|
block = _test_blockchain_rpc(blockchain.get_block_by_number, test_block_number) |
|
|
|
block = _test_blockchain_rpc(blockchain.get_block_by_number, test_block_number) |
|
|
|
|
|
|
|
assert isinstance(block, dict) |
|
|
|
|
|
|
|
assert 'hash' in block.keys() |
|
|
|
test_block_hash = block['hash'] |
|
|
|
test_block_hash = block['hash'] |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=11) |
|
|
|
@pytest.mark.run(order=11) |
|
|
|
def test_get_block_by_hash(setup_blockchain): |
|
|
|
def test_get_block_by_hash(setup_blockchain): |
|
|
|
if not test_block_hash: |
|
|
|
if not test_block_hash: |
|
|
|
pytest.skip('Failed to get reference block hash') |
|
|
|
pytest.skip('Failed to get reference block hash') |
|
|
|
_test_blockchain_rpc(blockchain.get_block_by_hash, test_block_hash) |
|
|
|
block = _test_blockchain_rpc(blockchain.get_block_by_hash, test_block_hash) |
|
|
|
|
|
|
|
assert isinstance(block, dict) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=12) |
|
|
|
@pytest.mark.run(order=12) |
|
|
|
def test_get_block_transaction_count_by_number(setup_blockchain): |
|
|
|
def test_get_block_transaction_count_by_number(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_block_transaction_count_by_number, test_block_number) |
|
|
|
tx_count = _test_blockchain_rpc(blockchain.get_block_transaction_count_by_number, test_block_number) |
|
|
|
|
|
|
|
assert isinstance(tx_count, int) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=13) |
|
|
|
@pytest.mark.run(order=13) |
|
|
|
def test_get_block_transaction_count_by_hash(setup_blockchain): |
|
|
|
def test_get_block_transaction_count_by_hash(setup_blockchain): |
|
|
|
if not test_block_hash: |
|
|
|
if not test_block_hash: |
|
|
|
pytest.skip('Failed to get reference block hash') |
|
|
|
pytest.skip('Failed to get reference block hash') |
|
|
|
_test_blockchain_rpc(blockchain.get_block_transaction_count_by_hash, test_block_hash) |
|
|
|
tx_count = _test_blockchain_rpc(blockchain.get_block_transaction_count_by_hash, test_block_hash) |
|
|
|
|
|
|
|
assert isinstance(tx_count, int) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=14) |
|
|
|
@pytest.mark.run(order=14) |
|
|
|
def test_get_blocks(setup_blockchain): |
|
|
|
def test_get_blocks(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_blocks, genesis_block_number, test_block_number) |
|
|
|
blocks = _test_blockchain_rpc(blockchain.get_blocks, genesis_block_number, test_block_number) |
|
|
|
|
|
|
|
assert isinstance(blocks, list) |
|
|
|
|
|
|
|
assert len(blocks) == (test_block_number - genesis_block_number + 1) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=15) |
|
|
|
@pytest.mark.run(order=15) |
|
|
|
def test_get_block_signers(setup_blockchain): |
|
|
|
def test_get_block_signers(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_block_signers, test_block_number) |
|
|
|
block_signers = _test_blockchain_rpc(blockchain.get_block_signers, test_block_number) |
|
|
|
|
|
|
|
assert isinstance(block_signers, list) |
|
|
|
|
|
|
|
assert len(block_signers) > 0 |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=16) |
|
|
|
@pytest.mark.run(order=16) |
|
|
|
def test_get_validators(setup_blockchain): |
|
|
|
def test_get_validators(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_validators, test_epoch_number) |
|
|
|
validators = _test_blockchain_rpc(blockchain.get_validators, test_epoch_number) |
|
|
|
|
|
|
|
assert isinstance(validators, dict) |
|
|
|
|
|
|
|
assert 'validators' in validators.keys() |
|
|
|
|
|
|
|
assert len(validators['validators']) > 0 |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=17) |
|
|
|
@pytest.mark.run(order=17) |
|
|
|
def test_get_shard(setup_blockchain): |
|
|
|
def test_get_shard(setup_blockchain): |
|
|
|
shard = _test_blockchain_rpc(blockchain.get_shard) |
|
|
|
shard = _test_blockchain_rpc(blockchain.get_shard) |
|
|
|
|
|
|
|
assert isinstance(shard, int) |
|
|
|
assert shard == 0 |
|
|
|
assert shard == 0 |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=18) |
|
|
|
@pytest.mark.run(order=18) |
|
|
|
def test_get_staking_epoch(setup_blockchain): |
|
|
|
def test_get_staking_epoch(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_staking_epoch) |
|
|
|
staking_epoch = _test_blockchain_rpc(blockchain.get_staking_epoch) |
|
|
|
|
|
|
|
assert isinstance(staking_epoch, int) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=19) |
|
|
|
@pytest.mark.run(order=19) |
|
|
|
def test_get_prestaking_epoch(setup_blockchain): |
|
|
|
def test_get_prestaking_epoch(setup_blockchain): |
|
|
|
_test_blockchain_rpc(blockchain.get_prestaking_epoch) |
|
|
|
prestaking_epoch = _test_blockchain_rpc(blockchain.get_prestaking_epoch) |
|
|
|
|
|
|
|
assert isinstance(prestaking_epoch, int) |
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.run(order=20) |
|
|
|
@pytest.mark.run(order=20) |
|
|
|
def test_get_bad_blocks(setup_blockchain): |
|
|
|
def test_get_bad_blocks(setup_blockchain): |
|
|
|
# TODO: Remove skip when RPC is fixed |
|
|
|
# TODO: Remove skip when RPC is fixed |
|
|
|
pytest.skip("Known error with hmy_getCurrentBadBlocks") |
|
|
|
pytest.skip("Known error with hmy_getCurrentBadBlocks") |
|
|
|
_test_blockchain_rpc(blockchain.get_bad_blocks) |
|
|
|
bad_blocks = _test_blockchain_rpc(blockchain.get_bad_blocks) |
|
|
|
|
|
|
|
assert isinstance(bad_blocks, list) |
|
|
|