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
def from_payment_csv_dict_row(row, cycle): reward_log = RewardLog(row["address"], row["type"], 0, 0) reward_log.cycle = cycle reward_log.adjusted_amount = int(row["amount"]) reward_log.hash = None if row["hash"] == "None" else row["hash"] reward_log.paid = PaymentStatus[str(row["paid"]).upper()] reward_log.desc = str(row["description"]) return reward_log
def calculate(self, reward_logs): # if address is in address destination dictionary; # then set payment address to mapped address value for rl in self.filterskipped(reward_logs): rl.ratio6 = rl.ratio address_set = set(rl.paymentaddress for rl in self.filterskipped(reward_logs)) payment_address_list_dict = {addr: [] for addr in address_set} # group payments by paymentaddress for rl in self.filterskipped(reward_logs): payment_address_list_dict[rl.paymentaddress].append(rl) reward_data6 = [] for rl in self.iterateskipped(reward_logs): reward_data6.append(rl) for addr, rl_list in payment_address_list_dict.items(): if len(rl_list) > 1: total_staking_balance = sum( [rl.staking_balance for rl in rl_list]) total_current_balance = sum( [rl.current_balance for rl in rl_list]) total_ratio = sum([rl.ratio for rl in rl_list]) total_payment_amount = sum([rl.amount for rl in rl_list]) total_adjusted_payment_amount = sum( [rl.adjusted_amount for rl in rl_list]) total_adjustment = sum([rl.adjustment for rl in rl_list]) total_service_fee_amount = sum( [rl.service_fee_amount for rl in rl_list]) total_service_fee_ratio = sum( [rl.service_fee_ratio for rl in rl_list]) merged = RewardLog(addr, TYPE_MERGED, total_staking_balance, total_current_balance) merged.ratio = total_ratio merged.amount = total_payment_amount merged.adjusted_amount = total_adjusted_payment_amount merged.adjustment = total_adjustment merged.service_fee_amount = total_service_fee_amount merged.service_fee_ratio = total_service_fee_ratio merged.service_fee_rate = 0 merged.parents = rl_list reward_data6.append(merged) else: reward_data6.append(rl_list[0]) return reward_data6