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. */
| 453 | * config is an integer in [0, 4) inclusive, and selects the variant of the test. |
| 454 | */ |
| 455 | void BuildRequestOrderTest(Scenario& scenario, int config) |
| 456 | { |
| 457 | scenario.SetTestName(strprintf("RequestOrder(config=%i)", config)); |
| 458 | |
| 459 | auto peer = scenario.NewPeer(); |
| 460 | auto gtxid1 = scenario.NewGTxid(); |
| 461 | auto gtxid2 = scenario.NewGTxid(); |
| 462 | |
| 463 | auto reqtime2 = scenario.Now() + RandomTime8s(); |
| 464 | auto reqtime1 = reqtime2 + RandomTime8s(); |
| 465 | |
| 466 | scenario.ReceivedInv(peer, gtxid1, config & 1, reqtime1); |
| 467 | // Simulate time going backwards by giving the second announcement an earlier reqtime. |
| 468 | scenario.ReceivedInv(peer, gtxid2, config & 2, reqtime2); |
| 469 | |
| 470 | scenario.AdvanceTime(reqtime2 - MICROSECOND - scenario.Now()); |
| 471 | scenario.Check(peer, {}, 2, 0, 0, "o1"); |
| 472 | scenario.AdvanceTime(MICROSECOND); |
| 473 | scenario.Check(peer, {gtxid2}, 2, 0, 0, "o2"); |
| 474 | scenario.AdvanceTime(reqtime1 - MICROSECOND - scenario.Now()); |
| 475 | scenario.Check(peer, {gtxid2}, 2, 0, 0, "o3"); |
| 476 | scenario.AdvanceTime(MICROSECOND); |
| 477 | // Even with time going backwards in between announcements, the return value of GetRequestable is in |
| 478 | // announcement order. |
| 479 | scenario.Check(peer, {gtxid1, gtxid2}, 2, 0, 0, "o4"); |
| 480 | |
| 481 | scenario.DisconnectedPeer(peer); |
| 482 | scenario.Check(peer, {}, 0, 0, 0, "o5"); |
| 483 | } |
| 484 | |
| 485 | /** Add to scenario a test that verifies behavior related to both txid and wtxid with the same |
| 486 | * hash being announced. |
no test coverage detected