Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Prev Previous commit
Next Next commit
Master.into()
  • Loading branch information
kianenigma committed Oct 14, 2019
commit 362e1f04ef418745d6e819c3c4bef6096e84932d
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions node/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ mod tests {
// initial fee multiplier must be zero
let mut prev_multiplier = Fixed64::from_parts(0);

sr_primitives::set_and_run_with_externalities(&mut t, || {
t.execute_with(|| {
assert_eq!(TransactionPayment::next_fee_multiplier(), prev_multiplier);
});

Expand Down Expand Up @@ -947,8 +947,8 @@ mod tests {
None,
).0.unwrap();

// fee multiplier is increased for next block.
sr_primitives::set_and_run_with_externalities(&mut t, || {
// weight multiplier is increased for next block.
t.execute_with(|| {
let fm = TransactionPayment::next_fee_multiplier();
println!("After a big block: {:?} -> {:?}", prev_multiplier, fm);
assert!(fm > prev_multiplier);
Expand All @@ -965,7 +965,7 @@ mod tests {
).0.unwrap();

// weight multiplier is increased for next block.
sr_primitives::set_and_run_with_externalities(&mut t, || {
t.execute_with(|| {
let fm = TransactionPayment::next_fee_multiplier();
println!("After a small block: {:?} -> {:?}", prev_multiplier, fm);
assert!(fm < prev_multiplier);
Expand Down
19 changes: 13 additions & 6 deletions srml/balances/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@

use super::*;
use mock::{Balances, ExtBuilder, Runtime, System, info_from_weight, CALL};
<<<<<<< HEAD
use sr_primitives::{set_and_run_with_externalities, traits::SignedExtension};
=======
>>>>>>> 64192122e3ce9d059bb15ab3e674aa6ddf670cc8
use support::{
assert_noop, assert_ok, assert_err,
traits::{LockableCurrency, LockIdentifier, WithdrawReason, WithdrawReasons,
Currency, ReservableCurrency}
};
<<<<<<< HEAD
use transaction_payment::ChargeTransactionPayment;
=======
use sr_primitives::weights::DispatchClass;
>>>>>>> 64192122e3ce9d059bb15ab3e674aa6ddf670cc8
use system::RawOrigin;

const ID_1: LockIdentifier = *b"1 ";
Expand Down Expand Up @@ -113,12 +120,12 @@ fn lock_value_extension_should_work() {

#[test]
fn lock_reasons_should_work() {
set_and_run_with_externalities(
&mut ExtBuilder::default()
.existential_deposit(1)
.monied(true)
.build(),
|| {
ExtBuilder::default()
.existential_deposit(1)
.monied(true)
.transaction_fees(0, 1, 0)
.build()
.execute_with(|| {
Balances::set_lock(ID_1, &1, 10, u64::max_value(), WithdrawReason::Transfer.into());
assert_noop!(
<Balances as Currency<_>>::transfer(&1, &2, 1),
Expand Down
45 changes: 41 additions & 4 deletions srml/transaction-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,11 @@ mod tests {

#[test]
fn signed_extension_transaction_payment_work() {
set_and_run_with_externalities(&mut
ExtBuilder::default()
.balance_factor(10) // 100
.fees(5, 1, 1) // 5 fixed, 1 per byte, 1 per weight
.build(), ||
.build()
.execute_with(||
{
let len = 10;
assert!(
Expand All @@ -370,11 +370,11 @@ mod tests {

#[test]
fn signed_extension_transaction_payment_is_bounded() {
set_and_run_with_externalities(&mut
ExtBuilder::default()
.balance_factor(1000)
.fees(0, 0, 1)
.build(), ||
.build()
.execute_with(||
{
use sr_primitives::weights::Weight;

Expand All @@ -391,5 +391,42 @@ mod tests {
);
});
}

#[test]
fn signed_extension_allows_free_transactions() {
ExtBuilder::default()
.transaction_fees(100, 1, 1)
.monied(false)
.build()
.execute_with(||
{
// 1 ain't have a penny.
assert_eq!(Balances::free_balance(&1), 0);

// like a FreeOperational
let operational_transaction = DispatchInfo {
weight: 0,
class: DispatchClass::Operational
};
let len = 100;
assert!(
TakeFees::<Runtime>::from(0)
.validate(&1, CALL, operational_transaction , len)
.is_ok()
);

// like a FreeNormal
let free_transaction = DispatchInfo {
weight: 0,
class: DispatchClass::Normal
};
assert!(
TakeFees::<Runtime>::from(0)
.validate(&1, CALL, free_transaction , len)
.is_err()
);
});
}
}


You are viewing a condensed version of this merge commit. You can view the full changes here.