mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 03:58:04 +00:00
Move Externalities into its own crate (#3775)
* Move `Externalities` into `substrate-externalities` - `Externalities` now support generic extensions - Split of `primtives-storage` for storage primitive types * Move the externalities scoping into `substrate-externalities` * Fix compilation * Review feedback * Adds macro for declaring extensions * Fix benchmarks * Introduce `ExtensionStore` trait * Last review comments * Implement it for `ExtensionStore`
This commit is contained in:
@@ -36,7 +36,6 @@ native_executor_instance!(
|
||||
mod tests {
|
||||
use super::Executor;
|
||||
use {balances, contracts, indices, system, timestamp};
|
||||
use runtime_io;
|
||||
use codec::{Encode, Decode, Joiner};
|
||||
use runtime_support::{
|
||||
Hashable, StorageValue, StorageMap, traits::Currency,
|
||||
@@ -121,7 +120,7 @@ mod tests {
|
||||
NativeExecutor::new(WasmExecutionMethod::Interpreted, None)
|
||||
}
|
||||
|
||||
fn set_heap_pages<E: Externalities<Blake2Hasher>>(ext: &mut E, heap_pages: u64) {
|
||||
fn set_heap_pages<E: Externalities>(ext: &mut E, heap_pages: u64) {
|
||||
ext.place_storage(well_known_keys::HEAP_PAGES.to_vec(), Some(heap_pages.encode()));
|
||||
}
|
||||
|
||||
@@ -227,7 +226,7 @@ mod tests {
|
||||
).0;
|
||||
assert!(r.is_ok());
|
||||
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
assert_eq!(Balances::total_balance(&alice()), 42 * DOLLARS - transfer_fee(&xt()));
|
||||
assert_eq!(Balances::total_balance(&bob()), 69 * DOLLARS);
|
||||
});
|
||||
@@ -263,7 +262,7 @@ mod tests {
|
||||
).0;
|
||||
assert!(r.is_ok());
|
||||
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
assert_eq!(Balances::total_balance(&alice()), 42 * DOLLARS - transfer_fee(&xt()));
|
||||
assert_eq!(Balances::total_balance(&bob()), 69 * DOLLARS);
|
||||
});
|
||||
@@ -434,7 +433,7 @@ mod tests {
|
||||
None,
|
||||
).0.unwrap();
|
||||
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
assert_eq!(Balances::total_balance(&alice()), 42 * DOLLARS - transfer_fee(&xt()));
|
||||
assert_eq!(Balances::total_balance(&bob()), 169 * DOLLARS);
|
||||
let events = vec![
|
||||
@@ -469,7 +468,7 @@ mod tests {
|
||||
None,
|
||||
).0.unwrap();
|
||||
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
// NOTE: fees differ slightly in tests that execute more than one block due to the
|
||||
// weight update. Hence, using `assert_eq_error_rate`.
|
||||
assert_eq_error_rate!(
|
||||
@@ -541,7 +540,7 @@ mod tests {
|
||||
None,
|
||||
).0.unwrap();
|
||||
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
assert_eq!(Balances::total_balance(&alice()), 42 * DOLLARS - transfer_fee(&xt()));
|
||||
assert_eq!(Balances::total_balance(&bob()), 169 * DOLLARS);
|
||||
});
|
||||
@@ -554,7 +553,7 @@ mod tests {
|
||||
None,
|
||||
).0.unwrap();
|
||||
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
assert_eq_error_rate!(
|
||||
Balances::total_balance(&alice()),
|
||||
32 * DOLLARS - 2 * transfer_fee(&xt()),
|
||||
@@ -716,7 +715,7 @@ mod tests {
|
||||
None,
|
||||
).0.unwrap();
|
||||
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
// Verify that the contract constructor worked well and code of TRANSFER contract is actually deployed.
|
||||
assert_eq!(
|
||||
&contracts::ContractInfoOf::<Runtime>::get(addr)
|
||||
@@ -837,7 +836,7 @@ mod tests {
|
||||
.expect("Extrinsic could be applied")
|
||||
.expect("Extrinsic did not fail");
|
||||
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
assert_eq!(Balances::total_balance(&alice()), 42 * DOLLARS - 1 * transfer_fee(&xt()));
|
||||
assert_eq!(Balances::total_balance(&bob()), 69 * DOLLARS);
|
||||
});
|
||||
@@ -896,7 +895,7 @@ mod tests {
|
||||
|
||||
let mut prev_multiplier = WeightMultiplier::default();
|
||||
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
assert_eq!(System::next_weight_multiplier(), prev_multiplier);
|
||||
});
|
||||
|
||||
@@ -948,7 +947,7 @@ mod tests {
|
||||
).0.unwrap();
|
||||
|
||||
// weight multiplier is increased for next block.
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
let fm = System::next_weight_multiplier();
|
||||
println!("After a big block: {:?} -> {:?}", prev_multiplier, fm);
|
||||
assert!(fm > prev_multiplier);
|
||||
@@ -965,7 +964,7 @@ mod tests {
|
||||
).0.unwrap();
|
||||
|
||||
// weight multiplier is increased for next block.
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
let fm = System::next_weight_multiplier();
|
||||
println!("After a small block: {:?} -> {:?}", prev_multiplier, fm);
|
||||
assert!(fm < prev_multiplier);
|
||||
@@ -1019,7 +1018,7 @@ mod tests {
|
||||
).0;
|
||||
assert!(r.is_ok());
|
||||
|
||||
runtime_io::with_externalities(&mut t, || {
|
||||
sr_primitives::set_and_run_with_externalities(&mut t, || {
|
||||
assert_eq!(Balances::total_balance(&bob()), (10 + 69) * DOLLARS);
|
||||
// Components deducted from alice's balances:
|
||||
// - Weight fee
|
||||
|
||||
Reference in New Issue
Block a user