def test_attempt_single_batch_tz(sign, request_url, request_url_post):
    network_config = {"BLOCK_TIME_IN_SEC": 60, "MINIMAL_BLOCK_DELAY": 30}
    batch_payer = BatchPayer(
        node_url="node_addr",
        pymnt_addr=TEST_TZ_ADDRESS,
        clnt_mngr=ClientManager(
            node_endpoint=PUBLIC_NODE_URL[CURRENT_TESTNET],
            signer_endpoint=PRIVATE_SIGNER_URL,
        ),
        delegator_pays_ra_fee=True,
        delegator_pays_xfer_fee=True,
        network_config=network_config,
        plugins_manager=MagicMock(),
        dry_run=False,
    )
    batch_payer.base_counter = 0
    reward_log = RewardLog(
        address=TEST_TZ_ADDRESS,
        type="D",
        staking_balance=80,
        current_balance=100,
    )

    reward_log.adjusted_amount = 15577803
    reward_log.skipped = False

    opt_counter = OpCounter()
    status, operation_hash, _ = batch_payer.attempt_single_batch([reward_log],
                                                                 opt_counter,
                                                                 dry_run=True)
    assert status == PaymentStatus.DONE
    assert operation_hash is None
    assert reward_log.delegator_transaction_fee == TZTX_FEE
    assert opt_counter.counter == 3209358
示例#2
0
def test_simulate_single_operation():
    default_fee = TZTX_FEE
    network_config = {"BLOCK_TIME_IN_SEC": 60, "MINIMAL_BLOCK_DELAY": 30}
    batch_payer = BatchPayer(
        node_url="node_addr",
        pymnt_addr="tz1234567890123456789012345678901234",
        clnt_mngr=ClientManager(
            node_endpoint=PUBLIC_NODE_URL[CURRENT_TESTNET],
            signer_endpoint=PRIVATE_SIGNER_URL,
        ),
        delegator_pays_ra_fee=True,
        delegator_pays_xfer_fee=True,
        network_config=network_config,
        plugins_manager=MagicMock(),
        dry_run=False,
    )
    batch_payer.base_counter = 0
    reward_log = RewardLog(
        address="KT1P3Y1mkGASzuJqLh7uGuQEvHatztGuQRgC",
        type="D",
        staking_balance=0,
        current_balance=0,
    )
    reward_log.amount = 15577803
    reward_log.skipped = False
    simulation_status, simulation_results = batch_payer.simulate_single_operation(
        reward_log, reward_log.amount, "hash", "unittest")
    assert PaymentStatus.DONE == simulation_status
    consumed_gas, tx_fee, storage = simulation_results
    assert 150 == consumed_gas
    assert 410 == default_fee + consumed_gas * MUTEZ_PER_GAS_UNIT
    assert int == type(storage)  # type of storage should be int
    assert 24 == storage
示例#3
0
def test_simulate_single_operation():
    config = configparser.ConfigParser()
    assert os.path.isfile(FEE_INI) is True
    config.read(FEE_INI)
    default_fee = int(config["KTTX"]["fee"])
    network_config = {"BLOCK_TIME_IN_SEC": 64}
    batch_payer = BatchPayer(
        node_url="node_addr",
        pymnt_addr="tz1234567890123456789012345678901234",
        clnt_mngr=ClientManager(
            node_endpoint="https://testnet-tezos.giganode.io:443",
            signer_endpoint="http://127.0.0.1:6732",
        ),
        delegator_pays_ra_fee=True,
        delegator_pays_xfer_fee=True,
        network_config=network_config,
        plugins_manager=MagicMock(),
        dry_run=False,
    )
    batch_payer.base_counter = 0
    reward_log = RewardLog(
        address="KT1P3Y1mkGASzuJqLh7uGuQEvHatztGuQRgC",
        type="D",
        staking_balance=0,
        current_balance=0,
    )
    reward_log.amount = 15577803
    reward_log.skipped = False
    simulation_status, simulation_results = batch_payer.simulate_single_operation(
        reward_log, reward_log.amount, "hash", "unittest")
    assert PaymentStatus.DONE == simulation_status
    consumed_gas, tx_fee, storage = simulation_results
    assert 150 == consumed_gas
    assert 589 == default_fee + consumed_gas * MUTEZ_PER_GAS_UNIT
    assert int == type(storage)  # type of storage should be int
    assert 24 == storage