Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "fw/forwarder.hpp" |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 8 | #include "tests/face/dummy-face.hpp" |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 9 | #include "dummy-strategy.hpp" |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 10 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 11 | #include "tests/test-common.hpp" |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 12 | #include "tests/core/limited-io.hpp" |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 13 | |
| 14 | namespace nfd { |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 15 | namespace tests { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 16 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 17 | BOOST_FIXTURE_TEST_SUITE(FwForwarder, BaseFixture) |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 18 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 19 | BOOST_AUTO_TEST_CASE(SimpleExchange) |
| 20 | { |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 21 | Forwarder forwarder; |
| 22 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 23 | Name nameA ("ndn:/A"); |
| 24 | Name nameAB ("ndn:/A/B"); |
| 25 | Name nameABC("ndn:/A/B/C"); |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 26 | shared_ptr<Interest> interestAB = makeInterest(nameAB); |
| 27 | interestAB->setInterestLifetime(4000); |
| 28 | shared_ptr<Data> dataABC = makeData(nameABC); |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 29 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 30 | shared_ptr<DummyFace> face1 = make_shared<DummyFace>(); |
| 31 | shared_ptr<DummyFace> face2 = make_shared<DummyFace>(); |
| 32 | face1->afterSend += bind(&boost::asio::io_service::stop, &g_io); |
| 33 | face2->afterSend += bind(&boost::asio::io_service::stop, &g_io); |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 34 | forwarder.addFace(face1); |
| 35 | forwarder.addFace(face2); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 36 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 37 | Fib& fib = forwarder.getFib(); |
| 38 | std::pair<shared_ptr<fib::Entry>, bool> fibInsertResult = |
| 39 | fib.insert(Name("ndn:/A")); |
| 40 | shared_ptr<fib::Entry> fibEntry = fibInsertResult.first; |
| 41 | fibEntry->addNextHop(face2, 0); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 42 | |
Junxiao Shi | b289cc1 | 2014-03-15 12:19:05 -0700 | [diff] [blame^] | 43 | BOOST_CHECK_EQUAL(forwarder.getCounters().getInInterest (), 0); |
| 44 | BOOST_CHECK_EQUAL(forwarder.getCounters().getOutInterest(), 0); |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 45 | face1->receiveInterest(*interestAB); |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 46 | g_io.run(); |
| 47 | g_io.reset(); |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 48 | BOOST_REQUIRE_EQUAL(face2->m_sentInterests.size(), 1); |
| 49 | BOOST_CHECK(face2->m_sentInterests[0].getName().equals(nameAB)); |
Junxiao Shi | 06887ac | 2014-02-13 20:15:42 -0700 | [diff] [blame] | 50 | BOOST_CHECK_EQUAL(face2->m_sentInterests[0].getIncomingFaceId(), face1->getId()); |
Junxiao Shi | b289cc1 | 2014-03-15 12:19:05 -0700 | [diff] [blame^] | 51 | BOOST_CHECK_EQUAL(forwarder.getCounters().getInInterest (), 1); |
| 52 | BOOST_CHECK_EQUAL(forwarder.getCounters().getOutInterest(), 1); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 53 | |
Junxiao Shi | b289cc1 | 2014-03-15 12:19:05 -0700 | [diff] [blame^] | 54 | BOOST_CHECK_EQUAL(forwarder.getCounters().getInData (), 0); |
| 55 | BOOST_CHECK_EQUAL(forwarder.getCounters().getOutData(), 0); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 56 | face2->receiveData(*dataABC); |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 57 | g_io.run(); |
| 58 | g_io.reset(); |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 59 | BOOST_REQUIRE_EQUAL(face1->m_sentDatas.size(), 1); |
| 60 | BOOST_CHECK(face1->m_sentDatas[0].getName().equals(nameABC)); |
Junxiao Shi | 06887ac | 2014-02-13 20:15:42 -0700 | [diff] [blame] | 61 | BOOST_CHECK_EQUAL(face1->m_sentDatas[0].getIncomingFaceId(), face2->getId()); |
Junxiao Shi | b289cc1 | 2014-03-15 12:19:05 -0700 | [diff] [blame^] | 62 | BOOST_CHECK_EQUAL(forwarder.getCounters().getInData (), 1); |
| 63 | BOOST_CHECK_EQUAL(forwarder.getCounters().getOutData(), 1); |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 66 | class ScopeLocalhostIncomingTestForwarder : public Forwarder |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 67 | { |
| 68 | public: |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 69 | ScopeLocalhostIncomingTestForwarder() |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 70 | { |
| 71 | } |
| 72 | |
| 73 | virtual void |
| 74 | onDataUnsolicited(Face& inFace, const Data& data) |
| 75 | { |
| 76 | ++m_onDataUnsolicited_count; |
| 77 | } |
| 78 | |
| 79 | protected: |
| 80 | virtual void |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 81 | dispatchToStrategy(shared_ptr<pit::Entry> pitEntry, function<void(fw::Strategy*)> f) |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 82 | { |
| 83 | ++m_dispatchToStrategy_count; |
| 84 | } |
| 85 | |
| 86 | public: |
| 87 | int m_dispatchToStrategy_count; |
| 88 | int m_onDataUnsolicited_count; |
| 89 | }; |
| 90 | |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 91 | BOOST_AUTO_TEST_CASE(ScopeLocalhostIncoming) |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 92 | { |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 93 | ScopeLocalhostIncomingTestForwarder forwarder; |
| 94 | shared_ptr<Face> face1 = make_shared<DummyLocalFace>(); |
| 95 | shared_ptr<Face> face2 = make_shared<DummyFace>(); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 96 | forwarder.addFace(face1); |
| 97 | forwarder.addFace(face2); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 98 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 99 | // local face, /localhost: OK |
| 100 | forwarder.m_dispatchToStrategy_count = 0; |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 101 | shared_ptr<Interest> i1 = makeInterest("/localhost/A1"); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 102 | forwarder.onIncomingInterest(*face1, *i1); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 103 | BOOST_CHECK_EQUAL(forwarder.m_dispatchToStrategy_count, 1); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 104 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 105 | // non-local face, /localhost: violate |
| 106 | forwarder.m_dispatchToStrategy_count = 0; |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 107 | shared_ptr<Interest> i2 = makeInterest("/localhost/A2"); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 108 | forwarder.onIncomingInterest(*face2, *i2); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 109 | BOOST_CHECK_EQUAL(forwarder.m_dispatchToStrategy_count, 0); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 110 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 111 | // local face, non-/localhost: OK |
| 112 | forwarder.m_dispatchToStrategy_count = 0; |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 113 | shared_ptr<Interest> i3 = makeInterest("/A3"); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 114 | forwarder.onIncomingInterest(*face1, *i3); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 115 | BOOST_CHECK_EQUAL(forwarder.m_dispatchToStrategy_count, 1); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 116 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 117 | // non-local face, non-/localhost: OK |
| 118 | forwarder.m_dispatchToStrategy_count = 0; |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 119 | shared_ptr<Interest> i4 = makeInterest("/A4"); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 120 | forwarder.onIncomingInterest(*face2, *i4); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 121 | BOOST_CHECK_EQUAL(forwarder.m_dispatchToStrategy_count, 1); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 122 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 123 | // local face, /localhost: OK |
| 124 | forwarder.m_onDataUnsolicited_count = 0; |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 125 | shared_ptr<Data> d1 = makeData("/localhost/B1"); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 126 | forwarder.onIncomingData(*face1, *d1); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 127 | BOOST_CHECK_EQUAL(forwarder.m_onDataUnsolicited_count, 1); |
| 128 | |
| 129 | // non-local face, /localhost: OK |
| 130 | forwarder.m_onDataUnsolicited_count = 0; |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 131 | shared_ptr<Data> d2 = makeData("/localhost/B2"); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 132 | forwarder.onIncomingData(*face2, *d2); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 133 | BOOST_CHECK_EQUAL(forwarder.m_onDataUnsolicited_count, 0); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 134 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 135 | // local face, non-/localhost: OK |
| 136 | forwarder.m_onDataUnsolicited_count = 0; |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 137 | shared_ptr<Data> d3 = makeData("/B3"); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 138 | forwarder.onIncomingData(*face1, *d3); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 139 | BOOST_CHECK_EQUAL(forwarder.m_onDataUnsolicited_count, 1); |
| 140 | |
| 141 | // non-local face, non-/localhost: OK |
| 142 | forwarder.m_onDataUnsolicited_count = 0; |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 143 | shared_ptr<Data> d4 = makeData("/B4"); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 144 | forwarder.onIncomingData(*face2, *d4); |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 145 | BOOST_CHECK_EQUAL(forwarder.m_onDataUnsolicited_count, 1); |
| 146 | } |
| 147 | |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 148 | BOOST_AUTO_TEST_CASE(ScopeLocalhostOutgoing) |
| 149 | { |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 150 | Forwarder forwarder; |
| 151 | shared_ptr<DummyLocalFace> face1 = make_shared<DummyLocalFace>(); |
| 152 | shared_ptr<DummyFace> face2 = make_shared<DummyFace>(); |
| 153 | shared_ptr<Face> face3 = make_shared<DummyLocalFace>(); |
| 154 | forwarder.addFace(face1); |
| 155 | forwarder.addFace(face2); |
| 156 | forwarder.addFace(face3); |
| 157 | Pit& pit = forwarder.getPit(); |
| 158 | |
| 159 | // local face, /localhost: OK |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 160 | shared_ptr<Interest> interestA1 = makeInterest("/localhost/A1"); |
| 161 | shared_ptr<pit::Entry> pitA1 = pit.insert(*interestA1).first; |
| 162 | pitA1->insertOrUpdateInRecord(face3, *interestA1); |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 163 | face1->m_sentInterests.clear(); |
| 164 | forwarder.onOutgoingInterest(pitA1, *face1); |
| 165 | BOOST_CHECK_EQUAL(face1->m_sentInterests.size(), 1); |
| 166 | |
| 167 | // non-local face, /localhost: violate |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 168 | shared_ptr<Interest> interestA2 = makeInterest("/localhost/A2"); |
| 169 | shared_ptr<pit::Entry> pitA2 = pit.insert(*interestA2).first; |
| 170 | pitA2->insertOrUpdateInRecord(face3, *interestA2); |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 171 | face2->m_sentInterests.clear(); |
| 172 | forwarder.onOutgoingInterest(pitA2, *face2); |
| 173 | BOOST_CHECK_EQUAL(face2->m_sentInterests.size(), 0); |
| 174 | |
| 175 | // local face, non-/localhost: OK |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 176 | shared_ptr<Interest> interestA3 = makeInterest("/A3"); |
| 177 | shared_ptr<pit::Entry> pitA3 = pit.insert(*interestA3).first; |
| 178 | pitA3->insertOrUpdateInRecord(face3, *interestA3); |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 179 | face1->m_sentInterests.clear(); |
| 180 | forwarder.onOutgoingInterest(pitA3, *face1); |
| 181 | BOOST_CHECK_EQUAL(face1->m_sentInterests.size(), 1); |
| 182 | |
| 183 | // non-local face, non-/localhost: OK |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 184 | shared_ptr<Interest> interestA4 = makeInterest("/A4"); |
| 185 | shared_ptr<pit::Entry> pitA4 = pit.insert(*interestA4).first; |
| 186 | pitA4->insertOrUpdateInRecord(face3, *interestA4); |
Junxiao Shi | 9b27bd2 | 2014-02-26 20:29:58 -0700 | [diff] [blame] | 187 | face2->m_sentInterests.clear(); |
| 188 | forwarder.onOutgoingInterest(pitA4, *face2); |
| 189 | BOOST_CHECK_EQUAL(face2->m_sentInterests.size(), 1); |
| 190 | |
| 191 | // local face, /localhost: OK |
| 192 | face1->m_sentDatas.clear(); |
| 193 | forwarder.onOutgoingData(Data("/localhost/B1"), *face1); |
| 194 | BOOST_CHECK_EQUAL(face1->m_sentDatas.size(), 1); |
| 195 | |
| 196 | // non-local face, /localhost: OK |
| 197 | face2->m_sentDatas.clear(); |
| 198 | forwarder.onOutgoingData(Data("/localhost/B2"), *face2); |
| 199 | BOOST_CHECK_EQUAL(face2->m_sentDatas.size(), 0); |
| 200 | |
| 201 | // local face, non-/localhost: OK |
| 202 | face1->m_sentDatas.clear(); |
| 203 | forwarder.onOutgoingData(Data("/B3"), *face1); |
| 204 | BOOST_CHECK_EQUAL(face1->m_sentDatas.size(), 1); |
| 205 | |
| 206 | // non-local face, non-/localhost: OK |
| 207 | face2->m_sentDatas.clear(); |
| 208 | forwarder.onOutgoingData(Data("/B4"), *face2); |
| 209 | BOOST_CHECK_EQUAL(face2->m_sentDatas.size(), 1); |
| 210 | } |
| 211 | |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 212 | BOOST_AUTO_TEST_CASE(StrategyDispatch) |
| 213 | { |
| 214 | LimitedIo limitedIo; |
| 215 | Forwarder forwarder; |
| 216 | shared_ptr<Face> face1 = make_shared<DummyFace>(); |
| 217 | shared_ptr<Face> face2 = make_shared<DummyFace>(); |
| 218 | forwarder.addFace(face1); |
| 219 | forwarder.addFace(face2); |
| 220 | |
| 221 | StrategyChoice& strategyChoice = forwarder.getStrategyChoice(); |
| 222 | shared_ptr<DummyStrategy> strategyP = make_shared<DummyStrategy>( |
| 223 | boost::ref(forwarder), "ndn:/strategyP"); |
| 224 | shared_ptr<DummyStrategy> strategyQ = make_shared<DummyStrategy>( |
| 225 | boost::ref(forwarder), "ndn:/strategyQ"); |
| 226 | strategyChoice.install(strategyP); |
| 227 | strategyChoice.install(strategyQ); |
| 228 | strategyChoice.insert("ndn:/" , strategyP->getName()); |
| 229 | strategyChoice.insert("ndn:/B", strategyQ->getName()); |
| 230 | |
| 231 | shared_ptr<Interest> interest1 = makeInterest("ndn:/A/1"); |
| 232 | strategyP->m_afterReceiveInterest_count = 0; |
| 233 | strategyP->m_interestOutFace = face2; |
| 234 | forwarder.onInterest(*face1, *interest1); |
| 235 | BOOST_CHECK_EQUAL(strategyP->m_afterReceiveInterest_count, 1); |
| 236 | |
| 237 | shared_ptr<Interest> interest2 = makeInterest("ndn:/B/2"); |
| 238 | strategyQ->m_afterReceiveInterest_count = 0; |
| 239 | strategyQ->m_interestOutFace = face2; |
| 240 | forwarder.onInterest(*face1, *interest2); |
| 241 | BOOST_CHECK_EQUAL(strategyQ->m_afterReceiveInterest_count, 1); |
| 242 | |
| 243 | limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(5)); |
| 244 | |
| 245 | shared_ptr<Data> data1 = makeData("ndn:/A/1/a"); |
| 246 | strategyP->m_beforeSatisfyPendingInterest_count = 0; |
| 247 | forwarder.onData(*face2, *data1); |
| 248 | BOOST_CHECK_EQUAL(strategyP->m_beforeSatisfyPendingInterest_count, 1); |
| 249 | |
| 250 | shared_ptr<Data> data2 = makeData("ndn:/B/2/b"); |
| 251 | strategyQ->m_beforeSatisfyPendingInterest_count = 0; |
| 252 | forwarder.onData(*face2, *data2); |
| 253 | BOOST_CHECK_EQUAL(strategyQ->m_beforeSatisfyPendingInterest_count, 1); |
| 254 | |
| 255 | shared_ptr<Interest> interest3 = makeInterest("ndn:/A/3"); |
| 256 | interest3->setInterestLifetime(30); |
| 257 | forwarder.onInterest(*face1, *interest3); |
| 258 | shared_ptr<Interest> interest4 = makeInterest("ndn:/B/4"); |
| 259 | interest4->setInterestLifetime(5000); |
| 260 | forwarder.onInterest(*face1, *interest4); |
| 261 | |
| 262 | strategyP->m_beforeExpirePendingInterest_count = 0; |
| 263 | strategyQ->m_beforeExpirePendingInterest_count = 0; |
| 264 | limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(100)); |
| 265 | BOOST_CHECK_EQUAL(strategyP->m_beforeExpirePendingInterest_count, 1); |
| 266 | BOOST_CHECK_EQUAL(strategyQ->m_beforeExpirePendingInterest_count, 0); |
| 267 | } |
| 268 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 269 | BOOST_AUTO_TEST_SUITE_END() |
| 270 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 271 | } // namespace tests |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 272 | } // namespace nfd |