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
| 161 | * backwards (but note that the ordering of this event only follows the scenario's m_now. |
| 162 | */ |
| 163 | void Check(NodeId peer, const std::vector<GenTxid>& expected, size_t candidates, size_t inflight, |
| 164 | size_t completed, const std::string& checkname, |
| 165 | std::chrono::microseconds offset = std::chrono::microseconds{0}) |
| 166 | { |
| 167 | const auto comment = m_testname + " " + checkname; |
| 168 | auto& runner = m_runner; |
| 169 | const auto now = m_now; |
| 170 | assert(offset.count() <= 0); |
| 171 | runner.actions.emplace_back(m_now, [=, &runner]() { |
| 172 | std::vector<std::pair<NodeId, GenTxid>> expired_now; |
| 173 | auto ret = runner.txrequest.GetRequestable(peer, now + offset, &expired_now); |
| 174 | for (const auto& entry : expired_now) { |
| 175 | runner.expired.insert(entry); |
| 176 | } |
| 177 | runner.txrequest.SanityCheck(); |
| 178 | runner.txrequest.PostGetRequestableSanityCheck(now + offset); |
| 179 | size_t total = candidates + inflight + completed; |
| 180 | size_t real_total = runner.txrequest.Count(peer); |
| 181 | size_t real_candidates = runner.txrequest.CountCandidates(peer); |
| 182 | size_t real_inflight = runner.txrequest.CountInFlight(peer); |
| 183 | BOOST_CHECK_MESSAGE(real_total == total, strprintf("[%s] total %i (%i expected)", comment, real_total, total)); |
| 184 | BOOST_CHECK_MESSAGE(real_inflight == inflight, strprintf("[%s] inflight %i (%i expected)", comment, real_inflight, inflight)); |
| 185 | BOOST_CHECK_MESSAGE(real_candidates == candidates, strprintf("[%s] candidates %i (%i expected)", comment, real_candidates, candidates)); |
| 186 | BOOST_CHECK_MESSAGE(ret == expected, strprintf("[%s] mismatching requestables", comment)); |
| 187 | }); |
| 188 | } |
| 189 | |
| 190 | /** Verify that an announcement for gtxid by peer has expired some time before this check is scheduled. |
| 191 | * |
no test coverage detected