mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 03:41:02 +00:00
Add execute_with to TestExternalities (#3793)
This function executes the given closure in a context where the test externalities are set. This makes the srml tests easier to write, as the test externalities need to be created anyway.
This commit is contained in:
@@ -16,7 +16,6 @@ runtime_io = { package = "sr-io", path = "../sr-io", default-features = false }
|
||||
log = { version = "0.4.8", optional = true }
|
||||
paste = "0.1.6"
|
||||
rand = { version = "0.7.2", optional = true }
|
||||
externalities = { package = "substrate-externalities", path = "../externalities", optional = true }
|
||||
impl-trait-for-tuples = "0.1.2"
|
||||
|
||||
[dev-dependencies]
|
||||
@@ -38,5 +37,4 @@ std = [
|
||||
"primitives/std",
|
||||
"app-crypto/std",
|
||||
"rand",
|
||||
"externalities",
|
||||
]
|
||||
|
||||
@@ -73,9 +73,6 @@ pub use sr_arithmetic::helpers_128bit;
|
||||
/// Re-export big_uint stiff.
|
||||
pub use sr_arithmetic::biguint;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use externalities::set_and_run_with_externalities;
|
||||
|
||||
/// An abstraction over justification for a block's validity under a consensus algorithm.
|
||||
///
|
||||
/// Essentially a finality proof. The exact formulation will vary between consensus
|
||||
|
||||
@@ -512,7 +512,6 @@ impl<'a> HeadersIterator<'a> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::set_and_run_with_externalities;
|
||||
use runtime_io::TestExternalities;
|
||||
use substrate_offchain::testing;
|
||||
use primitives::offchain::OffchainExt;
|
||||
@@ -523,7 +522,7 @@ mod tests {
|
||||
let mut t = TestExternalities::default();
|
||||
t.register_extension(OffchainExt::new(offchain));
|
||||
|
||||
set_and_run_with_externalities(&mut t, || {
|
||||
t.execute_with(|| {
|
||||
let request: Request = Request::get("http://localhost:1234");
|
||||
let pending = request
|
||||
.add_header("X-Auth", "hunter2")
|
||||
@@ -564,7 +563,7 @@ mod tests {
|
||||
let mut t = TestExternalities::default();
|
||||
t.register_extension(OffchainExt::new(offchain));
|
||||
|
||||
set_and_run_with_externalities(&mut t, || {
|
||||
t.execute_with(|| {
|
||||
let pending = Request::default()
|
||||
.method(Method::Post)
|
||||
.url("http://localhost:1234")
|
||||
|
||||
Reference in New Issue
Block a user