Add to scenario a test with one peer announcing two transactions, to verify they are * fetched in announcement order. * * config is an integer in [0, 4) inclusive, and selects the variant of the test. */
| 472 | * config is an integer in [0, 4) inclusive, and selects the variant of the test. |
| 473 | */ |
| 474 | void TxRequestTest::BuildRequestOrderTest(Scenario& scenario, int config) |
| 475 | { |
| 476 | scenario.SetTestName(strprintf("RequestOrder(config=%i)", config)); |
| 477 | |
| 478 | auto peer = scenario.NewPeer(); |
| 479 | auto gtxid1 = scenario.NewGTxid(); |
| 480 | auto gtxid2 = scenario.NewGTxid(); |
| 481 | |
| 482 | auto reqtime2 = scenario.Now() + RandomTime8s(); |
| 483 | auto reqtime1 = reqtime2 + RandomTime8s(); |
| 484 | |
| 485 | scenario.ReceivedInv(peer, gtxid1, config & 1, reqtime1); |
| 486 | // Simulate time going backwards by giving the second announcement an earlier reqtime. |
| 487 | scenario.ReceivedInv(peer, gtxid2, config & 2, reqtime2); |
| 488 | |
| 489 | scenario.AdvanceTime(reqtime2 - MICROSECOND - scenario.Now()); |
| 490 | scenario.Check(peer, {}, 2, 0, 0, "o1"); |
| 491 | scenario.AdvanceTime(MICROSECOND); |
| 492 | scenario.Check(peer, {gtxid2}, 2, 0, 0, "o2"); |
| 493 | scenario.AdvanceTime(reqtime1 - MICROSECOND - scenario.Now()); |
| 494 | scenario.Check(peer, {gtxid2}, 2, 0, 0, "o3"); |
| 495 | scenario.AdvanceTime(MICROSECOND); |
| 496 | // Even with time going backwards in between announcements, the return value of GetRequestable is in |
| 497 | // announcement order. |
| 498 | scenario.Check(peer, {gtxid1, gtxid2}, 2, 0, 0, "o4"); |
| 499 | |
| 500 | scenario.DisconnectedPeer(peer); |
| 501 | scenario.Check(peer, {}, 0, 0, 0, "o5"); |
| 502 | } |
| 503 | |
| 504 | /** Add to scenario a test that verifies behavior related to both txid and wtxid with the same |
| 505 | * hash being announced. |
nothing calls this directly
no test coverage detected