コード例 #1
0
ファイル: DebugModule.cs プロジェクト: vicnaum/nethermind
        public ResultWrapper <byte[]> debug_getBlockRlp(long blockNumber)
        {
            byte[] rlp = _debugBridge.GetBlockRlp(blockNumber);
            if (rlp == null)
            {
                return(ResultWrapper <byte[]> .Fail($"Block {blockNumber} was not found", ErrorType.NotFound));
            }

            return(ResultWrapper <byte[]> .Success(rlp));
        }
コード例 #2
0
        public void Get_block_rlp_by_hash()
        {
            BlockDecoder decoder = new BlockDecoder();
            Rlp          rlp     = decoder.Encode(Build.A.Block.WithNumber(1).TestObject);

            debugBridge.GetBlockRlp(Keccak.Zero).Returns(rlp.Bytes);

            DebugRpcModule         rpcModule = new DebugRpcModule(LimboLogs.Instance, debugBridge, jsonRpcConfig);
            JsonRpcSuccessResponse response  = RpcTest.TestRequest <IDebugRpcModule>(rpcModule, "debug_getBlockRlpByHash", $"{Keccak.Zero.Bytes.ToHexString()}") as JsonRpcSuccessResponse;

            Assert.AreEqual(rlp.Bytes, (byte[])response?.Result);
        }
コード例 #3
0
        public void Get_block_rlp_when_missing()
        {
            IDebugBridge debugBridge = Substitute.For <IDebugBridge>();

            debugBridge.GetBlockRlp(1).Returns((byte[])null);

            DebugModule          module   = new DebugModule(NullLogManager.Instance, debugBridge);
            JsonRpcErrorResponse response = RpcTest.TestRequest <IDebugModule>(module, "debug_getBlockRlp", "1") as JsonRpcErrorResponse;

            Assert.AreEqual(-32601, response.Error.Code);
        }
コード例 #4
0
        public void Get_block_rlp()
        {
            BlockDecoder decoder     = new BlockDecoder();
            IDebugBridge debugBridge = Substitute.For <IDebugBridge>();
            Rlp          rlp         = decoder.Encode(Build.A.Block.WithNumber(1).TestObject);

            debugBridge.GetBlockRlp(1).Returns(rlp.Bytes);

            DebugRpcModule         rpcModule = new DebugRpcModule(LimboLogs.Instance, debugBridge, jsonRpcConfig);
            JsonRpcSuccessResponse response  = RpcTest.TestRequest <IDebugRpcModule>(rpcModule, "debug_getBlockRlp", "1") as JsonRpcSuccessResponse;

            Assert.AreEqual(rlp.Bytes, (byte[])response?.Result);
        }
コード例 #5
0
        public void Get_block_rlp_by_hash_when_missing()
        {
            BlockDecoder decoder     = new BlockDecoder();
            IDebugBridge debugBridge = Substitute.For <IDebugBridge>();
            Rlp          rlp         = decoder.Encode(Build.A.Block.WithNumber(1).TestObject);

            debugBridge.GetBlockRlp(Keccak.Zero).Returns((byte[])null);

            DebugModule          module   = new DebugModule(NullLogManager.Instance, debugBridge);
            JsonRpcErrorResponse response = RpcTest.TestRequest <IDebugModule>(module, "debug_getBlockRlpByHash", $"{Keccak.Zero.Bytes.ToHexString()}") as JsonRpcErrorResponse;

            Assert.AreEqual(-32601, response.Error.Code);
        }
コード例 #6
0
        public void Get_block_rlp()
        {
            BlockDecoder decoder     = new BlockDecoder();
            IDebugBridge debugBridge = Substitute.For <IDebugBridge>();
            Rlp          rlp         = decoder.Encode(Build.A.Block.WithNumber(1).TestObject);

            debugBridge.GetBlockRlp(1).Returns(rlp.Bytes);

            DebugModule     module   = new DebugModule(NullLogManager.Instance, debugBridge);
            JsonRpcResponse response = RpcTest.TestRequest <IDebugModule>(module, "debug_getBlockRlp", "1");

            Assert.IsNotInstanceOf <JsonRpcErrorResponse>(response);
            Assert.AreEqual(rlp.Bytes, (byte[])response.Result);
        }
コード例 #7
0
        public void Get_block_rlp_by_hash()
        {
            BlockDecoder decoder     = new BlockDecoder();
            IDebugBridge debugBridge = Substitute.For <IDebugBridge>();
            Rlp          rlp         = decoder.Encode(Build.A.Block.WithNumber(1).TestObject);

            debugBridge.GetBlockRlp(Keccak.Zero).Returns(rlp.Bytes);

            DebugModule     module   = new DebugModule(NullLogManager.Instance, debugBridge);
            JsonRpcResponse response = RpcTest.TestRequest <IDebugModule>(module, "debug_getBlockRlpByHash", $"{Keccak.Zero.Bytes.ToHexString()}");

            Assert.IsNull(response.Error, response.Error?.Message);
            Assert.AreEqual(rlp.Bytes, (byte[])response.Result);
        }