Use TryFrom instead of From+panic for Builtin (#11140)
* Use TryFrom instead of From+panic for Builtin * fix tests * change expect text to be more descriptive * fix formatting
This commit is contained in:
@@ -16,14 +16,16 @@
|
||||
|
||||
//! Provide facilities to create `Machine` instances for testing various networks.
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use common_types::engines::params::CommonParams;
|
||||
use ethcore_builtin::Builtin;
|
||||
use ethjson;
|
||||
use crate::Machine;
|
||||
|
||||
pub fn load_machine(reader: &[u8]) -> Machine {
|
||||
let spec = ethjson::spec::Spec::load(reader).expect("chain spec is invalid");
|
||||
|
||||
let builtins = spec.accounts.builtins().into_iter().map(|p| (p.0.into(), From::from(p.1))).collect();
|
||||
let builtins = spec.accounts.builtins().into_iter().map(|p| (p.0.into(), Builtin::try_from(p.1).expect("chain spec is invalid"))).collect();
|
||||
let params = CommonParams::from(spec.params);
|
||||
|
||||
if let ethjson::spec::Engine::Ethash(ref ethash) = spec.engine {
|
||||
|
||||
Reference in New Issue
Block a user