public void If_comes_back_empty_then_it_can_be_reused() { LoadScenario(_1024BodiesWithOneTxEach); ReceiptsSyncBatch batch = _feed.PrepareRequest().Result; SyncResponseHandlingResult handlingResult = _feed.HandleResponse(batch); handlingResult.Should().Be(SyncResponseHandlingResult.NotAssigned); ReceiptsSyncBatch batch2 = _feed.PrepareRequest().Result; batch2.Should().BeSameAs(batch); batch2.Retries.Should().Be(1); }
public void If_comes_back_filled_with_empty_responses_then_it_can_be_reused() { LoadScenario(_1024BodiesWithOneTxEach); ReceiptsSyncBatch batch = _feed.PrepareRequest().Result; batch.Response = new TxReceipt[batch.Request.Length][]; SyncResponseHandlingResult handlingResult = _feed.HandleResponse(batch); handlingResult.Should().Be(SyncResponseHandlingResult.NoProgress); ReceiptsSyncBatch batch2 = _feed.PrepareRequest().Result; batch2.Should().BeSameAs(batch); batch2.Retries.Should().Be(1); }
public void If_only_one_valid_item_comes_back_then_we_create_a_filler_batch() { LoadScenario(_1024BodiesWithOneTxEach); ReceiptsSyncBatch batch = _feed.PrepareRequest().Result; batch.Response = new TxReceipt[batch.Request.Length][]; batch.Response[0] = new [] { Build.A.Receipt.TestObject }; SyncResponseHandlingResult handlingResult = _feed.HandleResponse(batch); handlingResult.Should().Be(SyncResponseHandlingResult.OK); ReceiptsSyncBatch batch2 = _feed.PrepareRequest().Result; batch2.Request.Length.Should().Be(batch.Request.Length - 1); }
public void If_receipts_root_comes_invalid_then_reports_breach_of_protocol() { LoadScenario(_1024BodiesWithOneTxEach); ReceiptsSyncBatch batch = _feed.PrepareRequest().Result; batch.Response = new TxReceipt[batch.Request.Length][]; // default receipts that we use when constructing receipt root for tests have stats code 0 // so by using 1 here we create a different tx root batch.Response[0] = new [] { Build.A.Receipt.WithStatusCode(1).TestObject }; PeerInfo peerInfo = new PeerInfo(Substitute.For <ISyncPeer>()); batch.ResponseSourcePeer = peerInfo; SyncResponseHandlingResult handlingResult = _feed.HandleResponse(batch); handlingResult.Should().Be(SyncResponseHandlingResult.NoProgress); _syncPeerPool.Received().ReportBreachOfProtocol(peerInfo, Arg.Any <string>()); }