Ejemplo n.º 1
0
        public void GetBlockByNumberTest()
        {
            IEthModule ethModule = Substitute.For <IEthModule>();

            ethModule.eth_getBlockByNumber(Arg.Any <BlockParameter>(), true).ReturnsForAnyArgs(x => ResultWrapper <BlockForRpc> .Success(new BlockForRpc(Build.A.Block.WithNumber(2).TestObject, true)));
            JsonRpcResponse response = TestRequest <IEthModule>(ethModule, "eth_getBlockByNumber", "0x1b4", "true");

            Assert.AreEqual(2L, (response.Result as BlockForRpc)?.Number);
        }
Ejemplo n.º 2
0
        public void Eth_module_populates_size_when_returning_block_data()
        {
            IEthModule ethModule = Substitute.For <IEthModule>();

            ethModule.eth_getBlockByNumber(Arg.Any <BlockParameter>(), true).ReturnsForAnyArgs(x => ResultWrapper <BlockForRpc> .Success(new BlockForRpc(Build.A.Block.WithNumber(2).TestObject, true)));
            JsonRpcSuccessResponse response = TestRequest(ethModule, "eth_getBlockByNumber", "0x1b4", "true") as JsonRpcSuccessResponse;

            Assert.AreEqual(513L, (response?.Result as BlockForRpc)?.Size);
        }
Ejemplo n.º 3
0
        public void GetBlockByNumberTest()
        {
            IEthModule ethModule = Substitute.For <IEthModule>();

            ethModule.eth_getBlockByNumber(Arg.Any <BlockParameter>(), true).ReturnsForAnyArgs(x => ResultWrapper <Block> .Success(new Block {
                Number = new Quantity(2)
            }));
            JsonRpcResponse response = TestRequest <IEthModule>(ethModule, "eth_getBlockByNumber", "0x1b4", "true");

            Assert.IsTrue(response.Result.ToString().Contains("0x02"));
        }