4
4
using System ;
5
5
using System . Collections . Generic ;
6
6
using System . Linq ;
7
- using System . Runtime . CompilerServices ;
7
+ using System . Text ;
8
8
using System . Threading ;
9
9
using System . Threading . Tasks ;
10
10
using FluentAssertions ;
@@ -96,6 +96,19 @@ public async Task Get_block_rlp_by_hash()
96
96
Assert . That ( ( byte [ ] ? ) response ? . Result , Is . EqualTo ( rlp . Bytes ) ) ;
97
97
}
98
98
99
+ [ Test ]
100
+ public async Task Get_raw_Header ( )
101
+ {
102
+ HeaderDecoder decoder = new ( ) ;
103
+ Block blk = Build . A . Block . WithNumber ( 0 ) . TestObject ;
104
+ Rlp rlp = decoder . Encode ( blk . Header ) ;
105
+ debugBridge . GetBlock ( new BlockParameter ( ( long ) 0 ) ) . Returns ( blk ) ;
106
+
107
+ DebugRpcModule rpcModule = new ( LimboLogs . Instance , debugBridge , jsonRpcConfig ) ;
108
+ JsonRpcSuccessResponse ? response = await RpcTest . TestRequest < IDebugRpcModule > ( rpcModule , "debug_getRawHeader" , $ "{ Keccak . Zero . Bytes . ToHexString ( ) } ") as JsonRpcSuccessResponse ;
109
+ Assert . That ( ( byte [ ] ? ) response ? . Result , Is . EqualTo ( rlp . Bytes ) ) ;
110
+ }
111
+
99
112
[ Test ]
100
113
public async Task Get_block_rlp ( )
101
114
{
@@ -110,6 +123,20 @@ public async Task Get_block_rlp()
110
123
Assert . That ( ( byte [ ] ? ) response ? . Result , Is . EqualTo ( rlp . Bytes ) ) ;
111
124
}
112
125
126
+ [ Test ]
127
+ public async Task Get_rawblock ( )
128
+ {
129
+ BlockDecoder decoder = new ( ) ;
130
+ IDebugBridge debugBridge = Substitute . For < IDebugBridge > ( ) ;
131
+ Rlp rlp = decoder . Encode ( Build . A . Block . WithNumber ( 1 ) . TestObject ) ;
132
+ debugBridge . GetBlockRlp ( new BlockParameter ( 1 ) ) . Returns ( rlp . Bytes ) ;
133
+
134
+ DebugRpcModule rpcModule = new ( LimboLogs . Instance , debugBridge , jsonRpcConfig ) ;
135
+ JsonRpcSuccessResponse ? response = await RpcTest . TestRequest < IDebugRpcModule > ( rpcModule , "debug_getRawBlock" , "1" ) as JsonRpcSuccessResponse ;
136
+
137
+ Assert . That ( ( byte [ ] ? ) response ? . Result , Is . EqualTo ( rlp . Bytes ) ) ;
138
+ }
139
+
113
140
[ Test ]
114
141
public async Task Get_block_rlp_when_missing ( )
115
142
{
@@ -121,6 +148,17 @@ public async Task Get_block_rlp_when_missing()
121
148
Assert . That ( response ? . Error ? . Code , Is . EqualTo ( - 32001 ) ) ;
122
149
}
123
150
151
+ [ Test ]
152
+ public async Task Get_rawblock_when_missing ( )
153
+ {
154
+ debugBridge . GetBlockRlp ( new BlockParameter ( 1 ) ) . ReturnsNull ( ) ;
155
+
156
+ DebugRpcModule rpcModule = new ( LimboLogs . Instance , debugBridge , jsonRpcConfig ) ;
157
+ JsonRpcErrorResponse ? response = await RpcTest . TestRequest < IDebugRpcModule > ( rpcModule , "debug_getRawBlock" , "1" ) as JsonRpcErrorResponse ;
158
+
159
+ Assert . That ( response ? . Error ? . Code , Is . EqualTo ( - 32001 ) ) ;
160
+ }
161
+
124
162
[ Test ]
125
163
public async Task Get_block_rlp_by_hash_when_missing ( )
126
164
{
0 commit comments