Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions multinode_integration_tests/tests/verify_bill_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ fn verify_bill_payment() {
assert_balances(
&contract_owner_wallet,
&blockchain_interface,
"99995231980000000000",
"99992712652000000000",
"471999999700000000000000000",
);

Expand Down Expand Up @@ -409,7 +409,7 @@ fn verify_pending_payables() {
assert_balances(
&contract_owner_wallet,
&blockchain_interface,
"99995231980000000000",
"99992712652000000000",
"471999999700000000000000000",
);
assert_balances(
Expand Down Expand Up @@ -450,17 +450,17 @@ fn verify_pending_payables() {
);
MASQNodeUtils::assert_node_wrote_log_containing(
real_consuming_node.name(),
"Transaction 0x75a8f185b7fb3ac0c4d1ee6b402a46940c9ae0477c0c7378a1308fb4bf539c5c has been added to the blockchain;",
"Transaction 0x7e08536811791ff20855e459fed222e1cc06bcd684524ae1beaa36fb28dca4f8 has been added to the blockchain;",
Duration::from_secs(5),
);
MASQNodeUtils::assert_node_wrote_log_containing(
real_consuming_node.name(),
"Transaction 0x384a3bb5bbd9718a97322be2878fa88c7cacacb2ac3416f521a621ca1946ddfc has been added to the blockchain;",
"Transaction 0x21aee15c389bd8894e4b8ffbc35a9f5084c4eea91d01d6ba5b7a93a58555d4e8 has been added to the blockchain;",
Duration::from_secs(5),
);
MASQNodeUtils::assert_node_wrote_log_containing(
real_consuming_node.name(),
"Transaction 0x6bc98d5db61ddd7676de1f25cb537156b3d9e066cec414fef8dbe9c695908215 has been added to the blockchain;",
"Transaction 0x619c64860fea5593d74fccb48fd8e3d44fe374345ff4bb657c053b2d83b71138 has been added to the blockchain;",
Duration::from_secs(5),
);
}
Expand Down
16 changes: 8 additions & 8 deletions node/src/accountant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3437,10 +3437,10 @@ mod tests {
init_test_logging();
let port = find_free_port();
let pending_tx_hash_1 =
H256::from_str("e66814b2812a80d619813f51aa999c0df84eb79d10f4923b2b7667b30d6b33d3")
H256::from_str("acc64bde11847ec2186914c8cf18b9b153bf1b6e02b534aa314946fc3a828df0")
.unwrap();
let pending_tx_hash_2 =
H256::from_str("0288ef000581b3bca8a2017eac9aea696366f8f1b7437f18d1aad57bccb7032c")
H256::from_str("e91c8324cb47305eefc0bff30b5981353326910eede7d3cf41579b5fcce712b4")
.unwrap();
let _blockchain_client_server = MBCSBuilder::new(port)
// Blockchain Agent Gas Price
Expand Down Expand Up @@ -3770,16 +3770,16 @@ mod tests {
);
let log_handler = TestLogHandler::new();
log_handler.exists_log_containing(
"WARN: Accountant: Broken transactions 0xe66814b2812a80d619813f51aa999c0df84eb79d10f\
4923b2b7667b30d6b33d3 marked as an error. You should take over the care of those to make sure \
"WARN: Accountant: Broken transactions 0xacc64bde11847ec2186914c8cf18b9b153bf\
1b6e02b534aa314946fc3a828df0 marked as an error. You should take over the care of those to make sure \
your debts are going to be settled properly. At the moment, there is no automated process \
fixing that without your assistance");
log_handler.exists_log_matching("INFO: Accountant: Transaction 0x0288ef000581b3bca8a2017eac9\
aea696366f8f1b7437f18d1aad57bccb7032c has been added to the blockchain; detected locally at \
log_handler.exists_log_matching("INFO: Accountant: Transaction 0xe91c8324cb47305eef\
c0bff30b5981353326910eede7d3cf41579b5fcce712b4 has been added to the blockchain; detected locally at \
attempt 4 at \\d{2,}ms after its sending");
log_handler.exists_log_containing(
"INFO: Accountant: Transactions 0x0288ef000581b3bca8a2017eac9aea696366f8f1b7437f18d1aad5\
7bccb7032c completed their confirmation process succeeding",
"INFO: Accountant: Transactions 0xe91c8324cb47305eefc0bff30b5981353326910eede7\
d3cf41579b5fcce712b4 completed their confirmation process succeeding",
);
}

Expand Down
9 changes: 6 additions & 3 deletions node/src/blockchain/blockchain_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ mod tests {
use std::time::{Duration, SystemTime};
use web3::types::{TransactionReceipt, H160};
use masq_lib::constants::DEFAULT_MAX_BLOCK_COUNT;
use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt};
use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt, GAS_PRICE_INCREASE_PERCENTAGE};

impl Handler<AssertionsMessage<Self>> for BlockchainBridge {
type Result = ();
Expand Down Expand Up @@ -745,6 +745,9 @@ mod tests {
let accountant_received_payment = accountant_recording_arc.lock().unwrap();
let blockchain_agent_with_context_msg_actual: &BlockchainAgentWithContextMessage =
accountant_received_payment.get_record(0);
let gas_price_from_rpc = 9395240960;
let gas_price_increase = (gas_price_from_rpc * GAS_PRICE_INCREASE_PERCENTAGE) / 100;
let expected_gas_price = gas_price_from_rpc + gas_price_increase;
assert_eq!(
blockchain_agent_with_context_msg_actual.protected_qualified_payables,
qualified_payables
Expand All @@ -759,7 +762,7 @@ mod tests {
blockchain_agent_with_context_msg_actual
.agent
.agreed_fee_per_computation_unit(),
0x230000000
expected_gas_price
);
assert_eq!(
blockchain_agent_with_context_msg_actual
Expand All @@ -776,7 +779,7 @@ mod tests {
blockchain_agent_with_context_msg_actual
.agent
.estimated_transaction_fee_total(1),
(1 * 0x230000000 * (gas_limit_const_part + WEB3_MAXIMAL_GAS_LIMIT_MARGIN))
(1 * expected_gas_price * (gas_limit_const_part + WEB3_MAXIMAL_GAS_LIMIT_MARGIN))
);
assert_eq!(
blockchain_agent_with_context_msg_actual.response_skeleton_opt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use web3::transports::{Batch, Http};
use web3::types::{Address, BlockNumber, Filter, Log, TransactionReceipt};
use web3::{Error, Web3};

pub const GAS_PRICE_INCREASE_PERCENTAGE: u128 = 80;

#[derive(Debug, PartialEq, Eq, Clone)]
pub enum TransactionReceiptResult {
RpcResponse(TxReceipt),
Expand Down Expand Up @@ -93,7 +95,12 @@ impl LowBlockchainInt for LowBlockchainIntWeb3 {
self.web3
.eth()
.gas_price()
.map_err(|e| QueryFailed(e.to_string())),
.map_err(|e| QueryFailed(e.to_string()))
.map(|price| {
let increase =
price * U256::from(GAS_PRICE_INCREASE_PERCENTAGE) / U256::from(100);
price + increase
}),
)
}

Expand Down Expand Up @@ -184,7 +191,12 @@ mod tests {
use masq_lib::utils::find_free_port;
use std::str::FromStr;
use web3::types::{BlockNumber, Bytes, FilterBuilder, Log, TransactionReceipt, U256};
use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TxReceipt, TxStatus};
use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TxReceipt, TxStatus, GAS_PRICE_INCREASE_PERCENTAGE};

#[test]
fn constants_have_correct_values() {
assert_eq!(GAS_PRICE_INCREASE_PERCENTAGE, 80);
}

#[test]
fn get_transaction_fee_balance_works() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ mod tests {
use std::str::FromStr;
use web3::transports::Http;
use web3::types::{H256, U256};
use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt, TxStatus};
use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::{TransactionBlock, TxReceipt, TxStatus, GAS_PRICE_INCREASE_PERCENTAGE};

#[test]
fn constants_are_correct() {
Expand Down Expand Up @@ -855,7 +855,9 @@ mod tests {

let expected_transaction_fee_balance = U256::from(65_520);
let expected_masq_balance = U256::from(65_535);
let expected_gas_price_wei = 1_000_000_000;
let gas_price_from_rpc = 1_000_000_000;
let gas_price_increase = (gas_price_from_rpc * GAS_PRICE_INCREASE_PERCENTAGE) / 100;
let expected_gas_price_wei = gas_price_from_rpc + gas_price_increase;
assert_eq!(result.consuming_wallet(), &wallet);
assert_eq!(
result.consuming_wallet_balances(),
Expand Down
5 changes: 4 additions & 1 deletion node/src/blockchain/blockchain_interface_initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ mod tests {
use masq_lib::constants::DEFAULT_CHAIN;
use masq_lib::test_utils::mock_blockchain_client_server::MBCSBuilder;
use masq_lib::utils::find_free_port;
use crate::blockchain::blockchain_interface::blockchain_interface_web3::lower_level_interface_web3::GAS_PRICE_INCREASE_PERCENTAGE;

#[test]
fn initialize_web3_interface_works() {
Expand All @@ -83,10 +84,12 @@ mod tests {
.wait()
.unwrap();

let gas_price_from_rpc = 1_000_000_000;
let gas_price_increase = (gas_price_from_rpc * GAS_PRICE_INCREASE_PERCENTAGE) / 100;
assert_eq!(blockchain_agent.consuming_wallet(), &wallet);
assert_eq!(
blockchain_agent.agreed_fee_per_computation_unit(),
1_000_000_000
gas_price_from_rpc + gas_price_increase
);
}

Expand Down
Loading