2019-01-07 11:33:07 +01:00
|
|
|
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
|
|
|
// This file is part of Parity Ethereum.
|
2017-05-26 11:06:48 +02:00
|
|
|
|
2019-01-07 11:33:07 +01:00
|
|
|
// Parity Ethereum is free software: you can redistribute it and/or modify
|
2017-05-26 11:06:48 +02:00
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
2019-01-07 11:33:07 +01:00
|
|
|
// Parity Ethereum is distributed in the hope that it will be useful,
|
2017-05-26 11:06:48 +02:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
2019-01-07 11:33:07 +01:00
|
|
|
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
2017-05-26 11:06:48 +02:00
|
|
|
|
|
|
|
//! Simple VM output.
|
|
|
|
|
|
|
|
use ethcore::trace;
|
2017-09-06 20:47:45 +02:00
|
|
|
use bytes::ToPretty;
|
2017-05-26 11:06:48 +02:00
|
|
|
|
|
|
|
use display;
|
2017-08-01 16:41:33 +02:00
|
|
|
use info as vm;
|
2017-05-26 11:06:48 +02:00
|
|
|
|
|
|
|
/// Simple formatting informant.
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct Informant;
|
|
|
|
|
|
|
|
impl vm::Informant for Informant {
|
2018-11-25 20:12:59 +01:00
|
|
|
|
|
|
|
type Sink = ();
|
|
|
|
|
2018-01-18 10:32:22 +01:00
|
|
|
fn before_test(&mut self, name: &str, action: &str) {
|
2017-08-28 14:25:16 +02:00
|
|
|
println!("Test: {} ({})", name, action);
|
|
|
|
}
|
|
|
|
|
2018-11-25 20:12:59 +01:00
|
|
|
fn clone_sink(&self) -> Self::Sink { () }
|
|
|
|
|
|
|
|
fn finish(result: vm::RunResult<Self::Output>, _sink: &mut Self::Sink) {
|
2017-05-26 11:06:48 +02:00
|
|
|
match result {
|
|
|
|
Ok(success) => {
|
|
|
|
println!("Output: 0x{}", success.output.to_hex());
|
|
|
|
println!("Gas used: {:x}", success.gas_used);
|
|
|
|
println!("Time: {}", display::format_time(&success.time));
|
|
|
|
},
|
|
|
|
Err(failure) => {
|
|
|
|
println!("Error: {}", failure.error);
|
|
|
|
println!("Time: {}", display::format_time(&failure.time));
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl trace::VMTracer for Informant {
|
2017-10-20 15:40:25 +02:00
|
|
|
type Output = ();
|
|
|
|
|
2018-10-02 16:33:19 +02:00
|
|
|
fn prepare_subtrace(&mut self, _code: &[u8]) { Default::default() }
|
|
|
|
fn done_subtrace(&mut self) {}
|
2017-10-20 15:40:25 +02:00
|
|
|
fn drain(self) -> Option<()> { None }
|
2017-05-26 11:06:48 +02:00
|
|
|
}
|