|
1 | | -// use aleph_client::{ |
2 | | -// api::transaction_payment::events::TransactionFeePaid, |
3 | | -// pallets::{balances::BalanceUserApi, fee::TransactionPaymentApi, system::SystemSudoApi}, |
4 | | -// utility::BlocksApi, |
5 | | -// AccountId, RootConnection, SignedConnection, TxStatus, |
6 | | -// }; |
7 | | -// use log::info; |
8 | | -// use primitives::Balance; |
| 1 | +use aleph_client::{ |
| 2 | + api::transaction_payment::events::TransactionFeePaid, |
| 3 | + pallets::{balances::BalanceUserApi, fee::TransactionPaymentApi}, |
| 4 | + utility::BlocksApi, |
| 5 | + AccountId, SignedConnection, TxStatus, |
| 6 | +}; |
| 7 | +use log::info; |
| 8 | +use primitives::Balance; |
| 9 | + |
| 10 | +// use aleph_client::{RootConnection, pallets::system::SystemSudoApi}; |
9 | 11 | // use sp_runtime::{FixedPointNumber, FixedU128}; |
10 | 12 |
|
11 | 13 | // use crate::{config::setup_test, transfer::setup_for_transfer}; |
12 | 14 |
|
| 15 | +// This test is disabled, as for now we no longer have access to fill_block runtime call |
13 | 16 | // #[tokio::test] |
14 | 17 | // pub async fn fee_calculation() -> anyhow::Result<()> { |
15 | 18 | // let config = setup_test(); |
|
99 | 102 | // } |
100 | 103 | // } |
101 | 104 |
|
102 | | -// pub async fn current_fees( |
103 | | -// connection: &SignedConnection, |
104 | | -// to: AccountId, |
105 | | -// tip: Option<Balance>, |
106 | | -// transfer_value: Balance, |
107 | | -// ) -> (Balance, u128) { |
108 | | -// let actual_multiplier = connection.get_next_fee_multiplier(None).await; |
109 | | - |
110 | | -// let tx_info = match tip { |
111 | | -// None => connection.transfer(to, transfer_value, TxStatus::Finalized), |
112 | | -// Some(tip) => connection.transfer_with_tip(to, transfer_value, tip, TxStatus::Finalized), |
113 | | -// } |
114 | | -// .await |
115 | | -// .unwrap(); |
| 105 | +pub async fn current_fees( |
| 106 | + connection: &SignedConnection, |
| 107 | + to: AccountId, |
| 108 | + tip: Option<Balance>, |
| 109 | + transfer_value: Balance, |
| 110 | +) -> (Balance, u128) { |
| 111 | + let actual_multiplier = connection.get_next_fee_multiplier(None).await; |
116 | 112 |
|
117 | | -// let events = connection.get_tx_events(tx_info).await.unwrap(); |
118 | | -// let event = events.find_first::<TransactionFeePaid>().unwrap().unwrap(); |
| 113 | + let tx_info = match tip { |
| 114 | + None => connection.transfer(to, transfer_value, TxStatus::Finalized), |
| 115 | + Some(tip) => connection.transfer_with_tip(to, transfer_value, tip, TxStatus::Finalized), |
| 116 | + } |
| 117 | + .await |
| 118 | + .unwrap(); |
119 | 119 |
|
120 | | -// let fee = event.actual_fee; |
| 120 | + let events = connection.get_tx_events(tx_info).await.unwrap(); |
| 121 | + let event = events.find_first::<TransactionFeePaid>().unwrap().unwrap(); |
121 | 122 |
|
122 | | -// info!("fee payed: {}", fee); |
| 123 | + let fee = event.actual_fee; |
123 | 124 |
|
124 | | -// (fee, actual_multiplier) |
125 | | -// } |
| 125 | + info!("fee payed: {}", fee); |
| 126 | + |
| 127 | + (fee, actual_multiplier) |
| 128 | +} |
0 commit comments