public void TestRunInvBlock() { var b1 = TestUtils.CreateFakeBlock(_unitTestParams, _blockStore).Block; _blockChain.Add(b1); var prev = TestUtils.MakeSolvedTestBlock(_unitTestParams, _blockStore); var b2 = TestUtils.MakeSolvedTestBlock(_unitTestParams, prev); var b3 = TestUtils.MakeSolvedTestBlock(_unitTestParams, b2); _control.Setup(x => x.WriteMessage(It.IsAny <Message>())).Verifiable(); var inv = new InventoryMessage(_unitTestParams); var item = new InventoryItem(InventoryItem.ItemType.Block, b3.Hash); inv.AddItem(item); _control.Setup(x => x.ReadMessage()).Returns(() => b2, () => inv, ReadFinalMessage).Verifiable(); var message = CaptureGetDataMessage(); RunPeerAndVerify(); var items = message.Value.Items; Assert.AreEqual(1, items.Count); Assert.AreEqual(b3.Hash, items[0].Hash); Assert.AreEqual(InventoryItem.ItemType.Block, items[0].Type); }
public void TestRunInvTickle() { var b1 = TestUtils.CreateFakeBlock(_unitTestParams, _blockStore).Block; _blockChain.Add(b1); var prev = TestUtils.MakeSolvedTestBlock(_unitTestParams, _blockStore); var block = TestUtils.MakeSolvedTestBlock(_unitTestParams, prev); var inv = new InventoryMessage(_unitTestParams); var item = new InventoryItem(InventoryItem.ItemType.Block, block.Hash); inv.AddItem(item); _control.Setup(x => x.ReadMessage()).Returns(() => block, () => inv, ReadFinalMessage).Verifiable(); var message = CaptureGetBlocksMessage(); RunPeerAndVerify(); var expectedLocator = new List <Sha256Hash>(); expectedLocator.Add(b1.Hash); expectedLocator.Add(_unitTestParams.GenesisBlock.Hash); Assert.AreEqual(message.Value.Locator, expectedLocator); Assert.AreEqual(message.Value.StopHash, block.Hash); }