Exemple #1
0
 def getCurrentEpoch(self) -> int:
     url = Globals.getHmyNetworkUrl()
     epoch_number = 0
     try:
         epoch_number = blockchain.get_current_epoch(url)
         #print(f"Block Number {block_number}")
     except Exception as ex:
         HmyBidderLog.error(
             f'Validator getCurrentEpoch get_block_number {ex}')
     finally:
         return epoch_number
Exemple #2
0
def is_cross_shard_era():
    """
    Returns if the network is in cross shard tx era...
    """
    global _is_cross_shard_era
    if _is_cross_shard_era:
        return True
    time.sleep(random.uniform(0.5,
                              1.5))  # Random to stop burst spam of RPC calls.
    if all(blockchain.get_current_epoch(e) >= 1 for e in endpoints):
        _is_cross_shard_era = True
        return True
    return False
Exemple #3
0
def is_staking_era():
    """
    Returns if the network is in staking era...
    """
    global _is_staking_era
    if _is_staking_era:
        return True
    time.sleep(random.uniform(0.5,
                              1.5))  # Random to stop burst spam of RPC calls.
    threshold_epoch = blockchain.get_prestaking_epoch(
        endpoints[beacon_shard_id])
    if all(
            blockchain.get_current_epoch(e) >= threshold_epoch
            for e in endpoints):
        _is_staking_era = True
    return False
def test_errors():
    with pytest.raises(exceptions.RPCError):
        blockchain.chain_id(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_node_metadata(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_peer_info(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.protocol_version(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_shard(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_staking_epoch(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_prestaking_epoch(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_sharding_structure(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_leader_address(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.is_last_block(0, fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.epoch_last_block(0, fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_circulating_supply(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_total_supply(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_block_number(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_current_epoch(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_last_cross_links(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_gas_price(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_num_peers(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_version(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_latest_header(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_header_by_number(0, fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_latest_chain_headers(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_block_by_number(0, endpoint=fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_block_by_hash('', endpoint=fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_block_transaction_count_by_number(0, fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_block_transaction_count_by_hash('', fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_block_staking_transaction_count_by_number(0, fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_block_staking_transaction_count_by_hash('', fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_blocks(0, 1, endpoint=fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_block_signers(0, fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_block_signers_keys(0, fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.is_block_signer(0, '', fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_signed_blocks('', fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_validators(1, fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.get_validator_keys(0, fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.in_sync(fake_shard)
    with pytest.raises(exceptions.RPCError):
        blockchain.beacon_in_sync(fake_shard)