public void Can_retrieve_empty_receipts() { _blockTree = Build.A.BlockTree(_genesisBlock).OfChainLength(2).TestObject; Block block0 = _blockTree.FindBlock(0, BlockTreeLookupOptions.None); Block block1 = _blockTree.FindBlock(1, BlockTreeLookupOptions.None); _syncServer.GetReceipts(block0.Hash).Should().HaveCount(0); _syncServer.GetReceipts(block1.Hash).Should().HaveCount(0); _syncServer.GetReceipts(TestItem.KeccakA).Should().HaveCount(0); }
public Task <TxReceipt[][]> GetReceipts(IList <Keccak> blockHash, CancellationToken token) { TxReceipt[][] result = new TxReceipt[blockHash.Count][]; for (int i = 0; i < blockHash.Count; i++) { result[i] = _remoteSyncServer.GetReceipts(blockHash[i]); } return(Task.FromResult(result)); }
public void Can_retrieve_empty_receipts() { _blockTree = Build.A.BlockTree(_genesisBlock).OfChainLength(2).TestObject; Block block0 = _blockTree.FindBlock(0, BlockTreeLookupOptions.None); Block block1 = _blockTree.FindBlock(1, BlockTreeLookupOptions.None); TxReceipt[][] txReceipts = _syncServer.GetReceipts(new[] { block0.Hash, block1.Hash, TestItem.KeccakA }); Assert.AreEqual(3, txReceipts.Length, "data.Length"); Assert.AreEqual(0, txReceipts[0].Length, "data[0]"); Assert.AreEqual(0, txReceipts[1].Length, "data[1]"); Assert.AreEqual(0, txReceipts[2].Length, "data[2]"); }
public void Will_not_send_messages_larger_than_2MB() { Context ctx = new(); StatusMessageSerializer statusMessageSerializer = new(); ReceiptsMessageSerializer receiptMessageSerializer = new(MainnetSpecProvider.Instance); GetReceiptsMessageSerializer getReceiptMessageSerializer = new(); MessageSerializationService serializationService = new(); serializationService.Register(statusMessageSerializer); serializationService.Register(receiptMessageSerializer); serializationService.Register(getReceiptMessageSerializer); ISyncServer syncServer = Substitute.For <ISyncServer>(); Eth63ProtocolHandler protocolHandler = new( ctx.Session, serializationService, Substitute.For <INodeStatsManager>(), syncServer, Substitute.For <ITxPool>(), Substitute.For <IGossipPolicy>(), LimboLogs.Instance); syncServer.GetReceipts(Arg.Any <Keccak>()).Returns( Enumerable.Repeat(Build.A.Receipt.WithAllFieldsFilled.TestObject, 512).ToArray()); StatusMessage statusMessage = new(); Packet statusPacket = new("eth", Eth62MessageCode.Status, statusMessageSerializer.Serialize(statusMessage)); GetReceiptsMessage getReceiptsMessage = new( Enumerable.Repeat(Keccak.Zero, 512).ToArray()); Packet getReceiptsPacket = new("eth", Eth63MessageCode.GetReceipts, getReceiptMessageSerializer.Serialize(getReceiptsMessage)); protocolHandler.HandleMessage(statusPacket); protocolHandler.HandleMessage(getReceiptsPacket); ctx.Session.Received().DeliverMessage(Arg.Is <ReceiptsMessage>(r => r.TxReceipts.Length == 14)); }
public Task <TxReceipt[][]> GetReceipts(Keccak[] blockHash, CancellationToken token) { return(Task.FromResult(_remoteSyncServer.GetReceipts(blockHash))); }