1
- #![ cfg( feature = "unsafe-debug" ) ]
2
-
3
1
use super :: * ;
4
- use crate :: unsafe_debug :: { ExecutionObserver , ExportedFunction } ;
2
+ use crate :: debug :: { CallSpan , ExportedFunction , Tracing } ;
5
3
use frame_support:: traits:: Currency ;
6
4
use pallet_contracts_primitives:: ExecReturnValue ;
7
5
use pretty_assertions:: assert_eq;
@@ -19,31 +17,40 @@ thread_local! {
19
17
static DEBUG_EXECUTION_TRACE : RefCell <Vec <DebugFrame >> = RefCell :: new( Vec :: new( ) ) ;
20
18
}
21
19
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 ;
23
29
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 {
26
35
DEBUG_EXECUTION_TRACE . with ( |d| {
27
36
d. borrow_mut ( ) . push ( DebugFrame {
28
- code_hash : code_hash. clone ( ) ,
37
+ code_hash : * code_hash,
29
38
call : entry_point,
30
39
input : input_data. to_vec ( ) ,
31
40
result : None ,
32
41
} )
33
42
} ) ;
43
+ TestCallSpan { code_hash : * code_hash, call : entry_point, input : input_data. to_vec ( ) }
34
44
}
45
+ }
35
46
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 ) {
42
49
DEBUG_EXECUTION_TRACE . with ( |d| {
43
50
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 ,
47
54
result : Some ( output. data . clone ( ) ) ,
48
55
} )
49
56
} ) ;
0 commit comments