def test_ok_load_chain_config(self):
        os.environ['PUBLIC_CHAIN_RPC_URL'] = 'http://example1.com'
        os.environ['PUBLIC_CHAIN_BRIDGE_CONTRACT_ADDRESS'] = '0x' + 'a' * 40
        os.environ['PUBLIC_CHAIN_GAS'] = '100'
        os.environ['PUBLIC_CHAIN_GAS_PRICE'] = '10000'
        os.environ['PRIVATE_CHAIN_RPC_URL'] = 'http://example2.com'
        os.environ['PRIVATE_CHAIN_BRIDGE_CONTRACT_ADDRESS'] = '0x' + 'b' * 40
        os.environ['PRIVATE_CHAIN_GAS'] = '200'
        os.environ['PRIVATE_CHAIN_GAS_PRICE'] = '20000'

        # Execute load_chain_config (for Deposit)
        deposit_config = helper.load_chain_config(True)

        # Assert return value
        self.assertEqual(
            deposit_config, {
                'isDeposit':
                True,
                'chainRpcUrlFrom':
                os.environ['PUBLIC_CHAIN_RPC_URL'],
                'bridgeContractAddressFrom':
                os.environ['PUBLIC_CHAIN_BRIDGE_CONTRACT_ADDRESS'],
                'chainRpcUrlTo':
                os.environ['PRIVATE_CHAIN_RPC_URL'],
                'bridgeContractAddressTo':
                os.environ['PRIVATE_CHAIN_BRIDGE_CONTRACT_ADDRESS'],
                'gas':
                os.environ['PRIVATE_CHAIN_GAS'],
                'gasPrice':
                os.environ['PRIVATE_CHAIN_GAS_PRICE']
            })

        # Execute load_chain_config (for Withdraw)
        withdraw_config = helper.load_chain_config(False)

        # Assert return value
        self.assertEqual(
            withdraw_config, {
                'isDeposit':
                False,
                'chainRpcUrlFrom':
                os.environ['PRIVATE_CHAIN_RPC_URL'],
                'bridgeContractAddressFrom':
                os.environ['PRIVATE_CHAIN_BRIDGE_CONTRACT_ADDRESS'],
                'chainRpcUrlTo':
                os.environ['PUBLIC_CHAIN_RPC_URL'],
                'bridgeContractAddressTo':
                os.environ['PUBLIC_CHAIN_BRIDGE_CONTRACT_ADDRESS'],
                'gas':
                os.environ['PUBLIC_CHAIN_GAS'],
                'gasPrice':
                os.environ['PUBLIC_CHAIN_GAS_PRICE']
            })
def handler(event, content):
    """ 未完了の出金処理の検出
    """
    detect_pending_relay.execute(helper.load_chain_config(False),
                                 event['notificationEnabled'],
                                 int(os.environ['RELAY_FROM_BLOCK_NUM']),
                                 int(os.environ['APPLY_RELAY_FROM_BLOCK_NUM']),
                                 int(os.environ['RELAY_IGNORE_SEC_THRESHOLD']))
def handler(event, content):
    """ Relayイベントのトランザクションハッシュを指定して入金処理を実行(未完了の入金処理をリトライする際に利用)
    """
    retry_apply_relay.execute(helper.load_chain_config(True),
                              helper.get_private_key(True),
                              event['relayTransactions'])
示例#4
0
def handler(event, context):
    """ 入金処理の実行
    """
    bridge.execute(helper.load_chain_config(True),
                   helper.get_db_table(), helper.get_private_key(True))