Ejemplo n.º 1
0
    def test_connect_to_testchain(self, our_address):
        uri = "http://0.0.0.0:8545"
        web3 = web3_via_http(uri, 63, 39)
        assert isinstance(web3.provider, HTTPProvider)
        assert web3.provider._request_kwargs['timeout'] == 63

        for adapter in _get_session(uri).adapters.values():
            assert adapter._pool_connections == 39
            assert adapter._pool_maxsize == 39

        assert isinstance(web3, Web3)
        assert eth_balance(web3, our_address) > Wad(0)
Ejemplo n.º 2
0
def get_web3():
    # These details are specific to the GEB testchain used for pyflex unit tests.
    web3 = web3_via_http("http://0.0.0.0:8545", 3, 100)
    web3.eth.defaultAccount = "0x50FF810797f75f6bfbf2227442e0c961a8562F4C"
    register_keys(web3, [
        "key_file=lib/pyflex/tests/config/keys/UnlimitedChain/key1.json,pass_file=/dev/null",
        "key_file=lib/pyflex/tests/config/keys/UnlimitedChain/key2.json,pass_file=/dev/null",
        "key_file=lib/pyflex/tests/config/keys/UnlimitedChain/key3.json,pass_file=/dev/null",
        "key_file=lib/pyflex/tests/config/keys/UnlimitedChain/key4.json,pass_file=/dev/null",
        "key_file=lib/pyflex/tests/config/keys/UnlimitedChain/key.json,pass_file=/dev/null"
    ])

    # reduce logspew
    logging.getLogger("web3").setLevel(logging.INFO)
    logging.getLogger("urllib3").setLevel(logging.INFO)
    logging.getLogger("asyncio").setLevel(logging.INFO)

    return web3
Ejemplo n.º 3
0
from pyflex.gas import FixedGasPrice, GeometricGasPrice
from pyflex.keys import register_keys
from pyflex.numeric import Wad
from pyflex import get_pending_transactions

logging.basicConfig(format='%(asctime)-15s %(levelname)-8s %(message)s',
                    level=logging.DEBUG)
# reduce logspew
logging.getLogger('urllib3').setLevel(logging.INFO)
logging.getLogger("web3").setLevel(logging.INFO)
logging.getLogger("asyncio").setLevel(logging.INFO)

pool_size = int(sys.argv[3]) if len(sys.argv) > 3 else 10

#web3 = Web3(HTTPProvider(endpoint_uri=os.environ['ETH_RPC_URL'], request_kwargs={"timeout": 60}))
web3 = web3_via_http(endpoint_uri=os.environ['ETH_RPC_URL'],
                     http_pool_size=pool_size)
web3.eth.defaultAccount = sys.argv[
    1]  # ex: 0x0000000000000000000000000000000aBcdef123
register_keys(
    web3, [sys.argv[2]]
)  # ex: key_file=~keys/default-account.json,pass_file=~keys/default-account.pass

geb = GfDeployment.from_node(web3, 'rai')
our_address = Address(web3.eth.defaultAccount)

weth = geb.collaterals['ETH-A'].collateral

GWEI = 1000000000
slow_gas = GeometricGasPrice(initial_price=int(15 * GWEI),
                             every_secs=42,
                             max_price=300 * GWEI)
Ejemplo n.º 4
0
 def test_unsupported_url(self):
     with pytest.raises(ValueError):
         web3_via_http("wss://0.0.0.0:8545")
Ejemplo n.º 5
0
from pprint import pprint

from pyflex import Address, get_pending_transactions, Wad, web3_via_http
from pyflex.deployment import GfDeployment
from pyflex.gas import FixedGasPrice, GeometricGasPrice
from pyflex.keys import register_keys

logging.basicConfig(format='%(asctime)-15s %(levelname)-8s %(message)s',
                    level=logging.DEBUG)
# reduce logspew
logging.getLogger('urllib3').setLevel(logging.INFO)
logging.getLogger("web3").setLevel(logging.INFO)
logging.getLogger("asyncio").setLevel(logging.INFO)
logging.getLogger("requests").setLevel(logging.INFO)

web3 = web3_via_http(endpoint_uri=os.environ['ETH_RPC_URL'])
web3.eth.defaultAccount = sys.argv[
    1]  # ex: 0x0000000000000000000000000000000aBcdef123
register_keys(
    web3, [sys.argv[2]]
)  # ex: key_file=~keys/default-account.json,pass_file=~keys/default-account.pass
our_address = Address(web3.eth.defaultAccount)
weth = GfDeployment.from_node(web3, 'rai').collaterals['ETH-A'].collateral
stuck_txes_to_submit = int(sys.argv[3]) if len(sys.argv) > 3 else 1

GWEI = 1000000000
increasing_gas = GeometricGasPrice(initial_price=int(1 * GWEI),
                                   every_secs=30,
                                   coefficient=1.5,
                                   max_price=100 * GWEI)