public ResultWrapper <GethLikeTxTrace[]> debug_traceBlock(byte[] blockRlp, GethTraceOptions options = null) { var blockTrace = _debugBridge.GetBlockTrace(new Rlp(blockRlp), options); if (blockTrace == null) { return(ResultWrapper <GethLikeTxTrace[]> .Fail($"Trace is null for RLP {blockRlp.ToHexString()}", ErrorType.NotFound)); } return(ResultWrapper <GethLikeTxTrace[]> .Success(blockTrace)); }
public ResultWrapper <GethLikeTxTrace> debug_traceTransactionInBlockByIndex(byte[] blockRlp, int txIndex, GethTraceOptions options = null) { var blockTrace = _debugBridge.GetBlockTrace(new Rlp(blockRlp), options); var transactionTrace = blockTrace?.ElementAtOrDefault(txIndex); if (transactionTrace == null) { return(ResultWrapper <GethLikeTxTrace> .Fail($"Trace is null for RLP {blockRlp.ToHexString()} and transaction index {txIndex}", ErrorType.NotFound)); } return(ResultWrapper <GethLikeTxTrace> .Success(transactionTrace)); }
public ResultWrapper <GethLikeTxTrace[]> debug_traceBlockByNumber(BigInteger blockNumber) { var blockTrace = _debugBridge.GetBlockTrace((UInt256)blockNumber); if (blockTrace == null) { return(ResultWrapper <GethLikeTxTrace[]> .Fail($"Trace is null for block {blockNumber}", ErrorType.NotFound)); } if (Logger.IsTrace) { Logger.Trace($"{nameof(debug_traceBlockByNumber)} request {blockNumber}, result: blockTrace"); } return(ResultWrapper <GethLikeTxTrace[]> .Success(blockTrace)); }
public ResultWrapper <BlockTraceItem[]> debug_traceBlockByNumber(Quantity blockNumber) { UInt256?blockNo = blockNumber.AsNumber(); if (!blockNo.HasValue) { throw new InvalidDataException("Expected block number value"); } var blockTrace = _debugBridge.GetBlockTrace(blockNo.Value); if (blockTrace == null) { return(ResultWrapper <BlockTraceItem[]> .Fail($"Trace is null for block {blockNo}", ErrorType.NotFound)); } var blockTraceModel = _modelMapper.MapBlockTrace(blockTrace); if (Logger.IsTrace) { Logger.Trace($"{nameof(debug_traceBlockByNumber)} request {blockNumber}, result: {GetJsonLog(blockTraceModel.Select(btm => btm.ToJson()))}"); } return(ResultWrapper <BlockTraceItem[]> .Success(blockTraceModel)); }
public void TraceBlock_Success() { var traces = Enumerable.Repeat(MockGethLikeTrace(), 2).ToArray(); var tracesClone = TestItem.CloneObject(traces); var blockRlp = new Rlp(TestItem.RandomDataA); debugBridge .GetBlockTrace(blockRlp, Arg.Any <CancellationToken>(), Arg.Any <GethTraceOptions>()) .Returns(traces); var rpcModule = new DebugRpcModule(LimboLogs.Instance, debugBridge, jsonRpcConfig); var actual = rpcModule.debug_traceBlock(blockRlp.Bytes); var expected = ResultWrapper <GethLikeTxTrace[]> .Success(tracesClone); actual.Should().BeEquivalentTo(expected); }