mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 00:41:08 +00:00
* ok_or → ok_or_else * Correct the sides of the given and expected args * Indent } properly * Convert identation from tabs to spaces. * Convert identation from tabs to spaces. [2]
This commit is contained in:
committed by
Robert Habermeier
parent
06ec2669fe
commit
94be7783e2
@@ -115,7 +115,7 @@ fn is_node_name_valid(_name: &str) -> Result<(), &str> {
|
||||
let name = _name.to_string();
|
||||
if name.chars().count() >= MAX_NODE_NAME_LENGTH {
|
||||
return Err("Node name too long");
|
||||
}
|
||||
}
|
||||
|
||||
let invalid_chars = r"[\\.@]";
|
||||
let re = Regex::new(invalid_chars).unwrap();
|
||||
@@ -384,9 +384,9 @@ fn revert_chain<F>(matches: &clap::ArgMatches, spec: ChainSpec<FactoryGenesis<F>
|
||||
}
|
||||
|
||||
fn parse_address(default: &str, port_param: &str, matches: &clap::ArgMatches) -> Result<SocketAddr, String> {
|
||||
let mut address: SocketAddr = default.parse().ok().ok_or(format!("Invalid address specified for --{}.", port_param))?;
|
||||
let mut address: SocketAddr = default.parse().ok().ok_or_else(|| format!("Invalid address specified for --{}.", port_param))?;
|
||||
if let Some(port) = matches.value_of(port_param) {
|
||||
let port: u16 = port.parse().ok().ok_or(format!("Invalid port for --{} specified.", port_param))?;
|
||||
let port: u16 = port.parse().ok().ok_or_else(|| format!("Invalid port for --{} specified.", port_param))?;
|
||||
address.set_port(port);
|
||||
}
|
||||
|
||||
@@ -485,18 +485,18 @@ fn kill_color(s: &str) -> String {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn tests_node_name_good() {
|
||||
assert!(is_node_name_valid("short name").is_ok());
|
||||
}
|
||||
#[test]
|
||||
fn tests_node_name_good() {
|
||||
assert!(is_node_name_valid("short name").is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[test]
|
||||
fn tests_node_name_bad() {
|
||||
assert!(is_node_name_valid("long names are not very cool for the ui").is_err());
|
||||
assert!(is_node_name_valid("Dots.not.Ok").is_err());
|
||||
assert!(is_node_name_valid("http://visit.me").is_err());
|
||||
assert!(is_node_name_valid("https://visit.me").is_err());
|
||||
assert!(is_node_name_valid("www.visit.me").is_err());
|
||||
assert!(is_node_name_valid("email@domain").is_err());
|
||||
}
|
||||
assert!(is_node_name_valid("long names are not very cool for the ui").is_err());
|
||||
assert!(is_node_name_valid("Dots.not.Ok").is_err());
|
||||
assert!(is_node_name_valid("http://visit.me").is_err());
|
||||
assert!(is_node_name_valid("https://visit.me").is_err());
|
||||
assert!(is_node_name_valid("www.visit.me").is_err());
|
||||
assert!(is_node_name_valid("email@domain").is_err());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ pub fn panic(info: &::core::panic::PanicInfo) -> ! {
|
||||
|
||||
#[alloc_error_handler]
|
||||
pub extern fn oom(_: ::core::alloc::Layout) -> ! {
|
||||
static OOM_MSG: &str = "Runtime memory exhausted. Aborting";
|
||||
static OOM_MSG: &str = "Runtime memory exhausted. Aborting";
|
||||
|
||||
unsafe {
|
||||
ext_print_utf8(OOM_MSG.as_ptr(), OOM_MSG.len() as u32);
|
||||
|
||||
@@ -269,7 +269,7 @@ pub fn execute_using_consensus_failure_handler<
|
||||
|
||||
// make a copy.
|
||||
let code = ext::Ext::new(overlay, backend).storage(b":code")
|
||||
.ok_or(Box::new(ExecutionError::CodeEntryDoesNotExist) as Box<Error>)?
|
||||
.ok_or_else(|| Box::new(ExecutionError::CodeEntryDoesNotExist) as Box<Error>)?
|
||||
.to_vec();
|
||||
|
||||
let result = {
|
||||
@@ -509,7 +509,7 @@ mod tests {
|
||||
},
|
||||
"test",
|
||||
&[],
|
||||
ExecutionManager::Both(|we, _ne| {
|
||||
ExecutionManager::Both(|we, _ne| {
|
||||
consensus_failed = true;
|
||||
println!("HELLO!");
|
||||
we
|
||||
|
||||
@@ -69,16 +69,16 @@ pub fn execute_block(block: Block) {
|
||||
let txs = block.extrinsics.iter().map(Encode::encode).collect::<Vec<_>>();
|
||||
let txs = txs.iter().map(Vec::as_slice).collect::<Vec<_>>();
|
||||
let txs_root = enumerated_trie_root(&txs).into();
|
||||
info_expect_equal_hash(&header.extrinsics_root, &txs_root);
|
||||
assert!(header.extrinsics_root == txs_root, "Transaction trie root must be valid.");
|
||||
info_expect_equal_hash(&txs_root, &header.extrinsics_root);
|
||||
assert!(txs_root == header.extrinsics_root, "Transaction trie root must be valid.");
|
||||
|
||||
// execute transactions
|
||||
block.extrinsics.iter().for_each(|e| { execute_transaction_backend(e).map_err(|_| ()).expect("Extrinsic error"); });
|
||||
|
||||
// check storage root.
|
||||
let storage_root = storage_root().into();
|
||||
info_expect_equal_hash(&header.state_root, &storage_root);
|
||||
assert!(header.state_root == storage_root, "Storage root must match that calculated.");
|
||||
info_expect_equal_hash(&storage_root, &header.state_root);
|
||||
assert!(storage_root == header.state_root, "Storage root must match that calculated.");
|
||||
}
|
||||
|
||||
/// Execute a transaction outside of the block execution function.
|
||||
|
||||
Reference in New Issue
Block a user