1- #![ cfg( feature = "unsafe-debug" ) ]
2-
31use super :: * ;
4- use crate :: unsafe_debug :: { ExecutionObserver , ExportedFunction } ;
2+ use crate :: debug :: { CallSpan , ExportedFunction , Tracing } ;
53use frame_support:: traits:: Currency ;
64use pallet_contracts_primitives:: ExecReturnValue ;
75use pretty_assertions:: assert_eq;
@@ -19,31 +17,40 @@ thread_local! {
1917 static DEBUG_EXECUTION_TRACE : RefCell <Vec <DebugFrame >> = RefCell :: new( Vec :: new( ) ) ;
2018}
2119
22- pub struct TestDebugger ;
20+ pub struct TestDebug ;
21+ pub struct TestCallSpan {
22+ code_hash : CodeHash < Test > ,
23+ call : ExportedFunction ,
24+ input : Vec < u8 > ,
25+ }
26+
27+ impl Tracing < Test > for TestDebug {
28+ type CallSpan = TestCallSpan ;
2329
24- impl ExecutionObserver < CodeHash < Test > > for TestDebugger {
25- fn before_call ( code_hash : & CodeHash < Test > , entry_point : ExportedFunction , input_data : & [ u8 ] ) {
30+ fn new_call_span (
31+ code_hash : & CodeHash < Test > ,
32+ entry_point : ExportedFunction ,
33+ input_data : & [ u8 ] ,
34+ ) -> TestCallSpan {
2635 DEBUG_EXECUTION_TRACE . with ( |d| {
2736 d. borrow_mut ( ) . push ( DebugFrame {
28- code_hash : code_hash. clone ( ) ,
37+ code_hash : * code_hash,
2938 call : entry_point,
3039 input : input_data. to_vec ( ) ,
3140 result : None ,
3241 } )
3342 } ) ;
43+ TestCallSpan { code_hash : * code_hash, call : entry_point, input : input_data. to_vec ( ) }
3444 }
45+ }
3546
36- fn after_call (
37- code_hash : & CodeHash < Test > ,
38- entry_point : ExportedFunction ,
39- input_data : Vec < u8 > ,
40- output : & ExecReturnValue ,
41- ) {
47+ impl CallSpan for TestCallSpan {
48+ fn after_call ( self , output : & ExecReturnValue ) {
4249 DEBUG_EXECUTION_TRACE . with ( |d| {
4350 d. borrow_mut ( ) . push ( DebugFrame {
44- code_hash : code_hash . clone ( ) ,
45- call : entry_point ,
46- input : input_data ,
51+ code_hash : self . code_hash ,
52+ call : self . call ,
53+ input : self . input ,
4754 result : Some ( output. data . clone ( ) ) ,
4855 } )
4956 } ) ;
0 commit comments