Schedule calls to verify the TxRequestTracker's state at the Scheduler's current time. * * @param peer The peer whose state will be inspected. * @param expected The expected return value for GetRequestable(peer) * @param candidates The expected return value CountCandidates(peer) * @param inflight The expected return value CountInFlight(peer) * @param complet
| 146 | * backwards (but note that the ordering of this event only follows the scenario's m_now. |
| 147 | */ |
| 148 | void Check(NodeId peer, const std::vector<GenTxid>& expected, size_t candidates, size_t inflight, |
| 149 | size_t completed, const std::string& checkname, |
| 150 | std::chrono::microseconds offset = std::chrono::microseconds{0}) |
| 151 | { |
| 152 | const auto comment = m_testname + " " + checkname; |
| 153 | auto& runner = m_runner; |
| 154 | const auto now = m_now; |
| 155 | assert(offset.count() <= 0); |
| 156 | runner.actions.emplace_back(m_now, [=,&runner]() { |
| 157 | std::vector<std::pair<NodeId, GenTxid>> expired_now; |
| 158 | auto ret = runner.txrequest.GetRequestable(peer, now + offset, &expired_now); |
| 159 | for (const auto& entry : expired_now) runner.expired.insert(entry); |
| 160 | runner.txrequest.SanityCheck(); |
| 161 | runner.txrequest.PostGetRequestableSanityCheck(now + offset); |
| 162 | size_t total = candidates + inflight + completed; |
| 163 | size_t real_total = runner.txrequest.Count(peer); |
| 164 | size_t real_candidates = runner.txrequest.CountCandidates(peer); |
| 165 | size_t real_inflight = runner.txrequest.CountInFlight(peer); |
| 166 | BOOST_CHECK_MESSAGE(real_total == total, strprintf("[" + comment + "] total %i (%i expected)", real_total, total)); |
| 167 | BOOST_CHECK_MESSAGE(real_inflight == inflight, strprintf("[" + comment + "] inflight %i (%i expected)", real_inflight, inflight)); |
| 168 | BOOST_CHECK_MESSAGE(real_candidates == candidates, strprintf("[" + comment + "] candidates %i (%i expected)", real_candidates, candidates)); |
| 169 | BOOST_CHECK_MESSAGE(ret == expected, "[" + comment + "] mismatching requestables"); |
| 170 | }); |
| 171 | } |
| 172 | |
| 173 | /** Verify that an announcement for gtxid by peer has expired some time before this check is scheduled. |
| 174 | * |
no test coverage detected