Beispiel #1
0
# Send 1 tx from eth to near, then from near to eth back.
# Restart relay right after tx is sent and after 10 seconds restart again, if `one_more_restart`.

import sys, time

one_more_restart = False
if 'one_more_restart' in sys.argv:
    one_more_restart = True

sys.path.append('lib')

from bridge import Eth2NearBlockRelay, Near2EthBlockRelay, alice, bridge_cluster_config_changes
from cluster import start_cluster, start_bridge

nodes = start_cluster(2, 0, 1, None, [], bridge_cluster_config_changes)
(bridge, ganache) = start_bridge(nodes, handle_relays=False)

e2n = Eth2NearBlockRelay(bridge.config)
e2n.start()
print('=== E2N RELAY IS STARTED')

n2e = Near2EthBlockRelay(bridge.config)
n2e.start()
print('=== N2E RELAY IS STARTED')

tx = bridge.transfer_eth2near(alice, 1000)

e2n.restart()
if one_more_restart:
    time.sleep(10)
    e2n.restart()
Beispiel #2
0
assert not (no_txs_in_same_block and no_txs_in_parallel)  # to avoid errors

eth2near_tx_number = int(sys.argv[1])
near2eth_tx_number = int(sys.argv[2])
assert eth2near_tx_number > 0 and eth2near_tx_number <= 1000 or eth2near_tx_number == 0 and near2eth_tx_number == 0
assert near2eth_tx_number >= 0 and near2eth_tx_number <= 1000

sys.path.append('lib')

from cluster import start_cluster, start_bridge
from bridge import alice, bridge_cluster_config_changes
from configured_logger import logger

nodes = start_cluster(2, 0, 1, None, [], bridge_cluster_config_changes)
(bridge, ganache) = start_bridge(nodes)

txs = []
for _ in range(eth2near_tx_number):
    txs.append(bridge.transfer_eth2near(alice, 1000))
    if no_txs_in_same_block:
        time.sleep(bridge.config['ganache_block_prod_time'] + 2)
    if no_txs_in_parallel:
        [p.join() for p in txs]
[p.join() for p in txs]
exit_codes = [p.exitcode for p in txs]

assert exit_codes == [0 for _ in txs]
bridge.check_balances(alice)

txs = []
Beispiel #3
0
    exit(1)

eth2near_tx_number = int(sys.argv[1])
near2eth_tx_number = int(sys.argv[2])
assert eth2near_tx_number > 0 and eth2near_tx_number <= 1000 or eth2near_tx_number == 0 and near2eth_tx_number == 0
assert near2eth_tx_number >= 0 and near2eth_tx_number <= 1000

sys.path.append('lib')

from cluster import start_cluster, start_bridge

nodes = start_cluster(2, 0, 1, None, [], {})

time.sleep(2)

(bridge, ganache) = start_bridge()
print('=== BRIDGE IS STARTED')

eth_address = bridge.get_eth_address_by_secret_key(
    '0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200')
print('=== ADDRESS of %s is %s' %
      ('0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200',
       eth_address))
eth_balance_before = bridge.get_eth_balance(eth_address)
print('=== ETH BALANCE BEFORE', eth_balance_before)
near_balance_before = bridge.get_near_balance(
    nodes[0], 'rainbow_bridge_eth_on_near_prover')
print('=== NEAR BALANCE BEFORE', near_balance_before)
print('=== SENDING 1000 ETH TO NEAR PER TX, %d TXS' % (eth2near_tx_number))
txs = []
for _ in range(eth2near_tx_number):