fw: reorder function params to make the strategy API more uniform
Also add a non-const overload of Face::getCounters to avoid const_cast
Refs: #5173
Change-Id: Iff0bfbdedb90e68a373090cf3f247d9a7501f58d
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index e3b3a19..12ced16 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.cpp
@@ -165,14 +165,14 @@
pitA->insertOrUpdateInRecord(*face1, *interestA1);
auto interestA2 = makeInterest("/A", false, nullopt, 1698);
- auto outA2 = forwarder.onOutgoingInterest(pitA, *face2, *interestA2);
+ auto outA2 = forwarder.onOutgoingInterest(*interestA2, *face2, pitA);
BOOST_REQUIRE(outA2 != nullptr);
BOOST_CHECK_EQUAL(outA2->getLastNonce(), 1698);
// This packet will be dropped because HopLimit=0
auto interestA3 = makeInterest("/A", false, nullopt, 9876);
interestA3->setHopLimit(0);
- auto outA3 = forwarder.onOutgoingInterest(pitA, *face2, *interestA3);
+ auto outA3 = forwarder.onOutgoingInterest(*interestA3, *face2, pitA);
BOOST_CHECK(outA3 == nullptr);
BOOST_REQUIRE_EQUAL(face2->sentInterests.size(), 1);
@@ -275,47 +275,47 @@
// local face, /localhost: OK
strategy.afterReceiveInterest_count = 0;
auto i1 = makeInterest("/localhost/A1");
- forwarder.onIncomingInterest(FaceEndpoint(*face1, 0), *i1);
+ forwarder.onIncomingInterest(*i1, FaceEndpoint(*face1, 0));
BOOST_CHECK_EQUAL(strategy.afterReceiveInterest_count, 1);
// non-local face, /localhost: violate
strategy.afterReceiveInterest_count = 0;
auto i2 = makeInterest("/localhost/A2");
- forwarder.onIncomingInterest(FaceEndpoint(*face2, 0), *i2);
+ forwarder.onIncomingInterest(*i2, FaceEndpoint(*face2, 0));
BOOST_CHECK_EQUAL(strategy.afterReceiveInterest_count, 0);
// local face, non-/localhost: OK
strategy.afterReceiveInterest_count = 0;
auto i3 = makeInterest("/A3");
- forwarder.onIncomingInterest(FaceEndpoint(*face1, 0), *i3);
+ forwarder.onIncomingInterest(*i3, FaceEndpoint(*face1, 0));
BOOST_CHECK_EQUAL(strategy.afterReceiveInterest_count, 1);
// non-local face, non-/localhost: OK
strategy.afterReceiveInterest_count = 0;
auto i4 = makeInterest("/A4");
- forwarder.onIncomingInterest(FaceEndpoint(*face2, 0), *i4);
+ forwarder.onIncomingInterest(*i4, FaceEndpoint(*face2, 0));
BOOST_CHECK_EQUAL(strategy.afterReceiveInterest_count, 1);
BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 0);
// local face, /localhost: OK
auto d1 = makeData("/localhost/B1");
- forwarder.onIncomingData(FaceEndpoint(*face1, 0), *d1);
+ forwarder.onIncomingData(*d1, FaceEndpoint(*face1, 0));
BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 1);
// non-local face, /localhost: violate
auto d2 = makeData("/localhost/B2");
- forwarder.onIncomingData(FaceEndpoint(*face2, 0), *d2);
+ forwarder.onIncomingData(*d2, FaceEndpoint(*face2, 0));
BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 1);
// local face, non-/localhost: OK
auto d3 = makeData("/B3");
- forwarder.onIncomingData(FaceEndpoint(*face1, 0), *d3);
+ forwarder.onIncomingData(*d3, FaceEndpoint(*face1, 0));
BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 2);
// non-local face, non-/localhost: OK
auto d4 = makeData("/B4");
- forwarder.onIncomingData(FaceEndpoint(*face2, 0), *d4);
+ forwarder.onIncomingData(*d4, FaceEndpoint(*face2, 0));
BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 3);
}
@@ -330,31 +330,31 @@
auto interest1 = makeInterest("/A/1");
strategyA.afterReceiveInterest_count = 0;
strategyA.interestOutFace = face2;
- forwarder.onIncomingInterest(FaceEndpoint(*face1, 0), *interest1);
+ forwarder.onIncomingInterest(*interest1, FaceEndpoint(*face1, 0));
BOOST_CHECK_EQUAL(strategyA.afterReceiveInterest_count, 1);
auto interest2 = makeInterest("/B/2", true);
strategyB.afterReceiveInterest_count = 0;
strategyB.interestOutFace = face2;
- forwarder.onIncomingInterest(FaceEndpoint(*face1, 0), *interest2);
+ forwarder.onIncomingInterest(*interest2, FaceEndpoint(*face1, 0));
BOOST_CHECK_EQUAL(strategyB.afterReceiveInterest_count, 1);
this->advanceClocks(1_ms, 5_ms);
auto data1 = makeData("/A/1");
strategyA.beforeSatisfyInterest_count = 0;
- forwarder.onIncomingData(FaceEndpoint(*face2, 0), *data1);
+ forwarder.onIncomingData(*data1, FaceEndpoint(*face2, 0));
BOOST_CHECK_EQUAL(strategyA.beforeSatisfyInterest_count, 1);
auto data2 = makeData("/B/2/b");
strategyB.beforeSatisfyInterest_count = 0;
- forwarder.onIncomingData(FaceEndpoint(*face2, 0), *data2);
+ forwarder.onIncomingData(*data2, FaceEndpoint(*face2, 0));
BOOST_CHECK_EQUAL(strategyB.beforeSatisfyInterest_count, 1);
auto interest3 = makeInterest("/A/3", false, 30_ms);
- forwarder.onIncomingInterest(FaceEndpoint(*face1, 0), *interest3);
+ forwarder.onIncomingInterest(*interest3, FaceEndpoint(*face1, 0));
auto interest4 = makeInterest("/B/4", false, 5_s);
- forwarder.onIncomingInterest(FaceEndpoint(*face1, 0), *interest4);
+ forwarder.onIncomingInterest(*interest4, FaceEndpoint(*face1, 0));
}
BOOST_AUTO_TEST_CASE(IncomingData)
@@ -378,7 +378,7 @@
pitC->insertOrUpdateInRecord(*face4, *interestC);
auto dataD = makeData("/A/B/C/D");
- forwarder.onIncomingData(FaceEndpoint(*face3, 0), *dataD);
+ forwarder.onIncomingData(*dataD, FaceEndpoint(*face3, 0));
this->advanceClocks(1_ms, 5_ms);
BOOST_CHECK_EQUAL(face1->sentData.size(), 1);
@@ -446,14 +446,14 @@
auto nack1 = makeNack(*interest1, lp::NackReason::CONGESTION);
strategyA.afterReceiveNack_count = 0;
strategyB.afterReceiveNack_count = 0;
- forwarder.onIncomingNack(FaceEndpoint(*face1, 0), nack1);
+ forwarder.onIncomingNack(nack1, FaceEndpoint(*face1, 0));
BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 1);
BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
auto nack2 = makeNack(*interest2, lp::NackReason::CONGESTION);
strategyA.afterReceiveNack_count = 0;
strategyB.afterReceiveNack_count = 0;
- forwarder.onIncomingNack(FaceEndpoint(*face1, 0), nack2);
+ forwarder.onIncomingNack(nack2, FaceEndpoint(*face1, 0));
BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0);
BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 1);
@@ -467,7 +467,7 @@
auto nack3 = makeNack(*makeInterest("/yEcw5HhdM", false, nullopt, 243), lp::NackReason::CONGESTION);
strategyA.afterReceiveNack_count = 0;
strategyB.afterReceiveNack_count = 0;
- forwarder.onIncomingNack(FaceEndpoint(*face1, 0), nack3);
+ forwarder.onIncomingNack(nack3, FaceEndpoint(*face1, 0));
BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0);
BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
@@ -479,7 +479,7 @@
auto nack4a = makeNack(*interest4, lp::NackReason::CONGESTION);
strategyA.afterReceiveNack_count = 0;
strategyB.afterReceiveNack_count = 0;
- forwarder.onIncomingNack(FaceEndpoint(*face2, 0), nack4a);
+ forwarder.onIncomingNack(nack4a, FaceEndpoint(*face2, 0));
BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0);
BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
@@ -487,7 +487,7 @@
auto nack4b = makeNack(*makeInterest("/Etab4KpY", false, nullopt, 294), lp::NackReason::CONGESTION);
strategyA.afterReceiveNack_count = 0;
strategyB.afterReceiveNack_count = 0;
- forwarder.onIncomingNack(FaceEndpoint(*face1, 0), nack4b);
+ forwarder.onIncomingNack(nack4b, FaceEndpoint(*face1, 0));
BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0);
BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
@@ -495,7 +495,7 @@
pit4->insertOrUpdateOutRecord(*face3, *interest4);
strategyA.afterReceiveNack_count = 0;
strategyB.afterReceiveNack_count = 0;
- forwarder.onIncomingNack(FaceEndpoint(*face3, 0), nack4a);
+ forwarder.onIncomingNack(nack4a, FaceEndpoint(*face3, 0));
BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0);
BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
}
@@ -522,7 +522,7 @@
pit1->insertOrUpdateInRecord(*face1, *interest1);
face2->sentNacks.clear();
- BOOST_CHECK(!forwarder.onOutgoingNack(pit1, *face2, nackHeader));
+ BOOST_CHECK(!forwarder.onOutgoingNack(nackHeader, *face2, pit1));
BOOST_CHECK_EQUAL(face2->sentNacks.size(), 0);
// send Nack with correct Nonce
@@ -534,7 +534,7 @@
face1->sentNacks.clear();
face2->sentNacks.clear();
- BOOST_CHECK(forwarder.onOutgoingNack(pit2, *face1, nackHeader));
+ BOOST_CHECK(forwarder.onOutgoingNack(nackHeader, *face1, pit2));
BOOST_REQUIRE_EQUAL(face1->sentNacks.size(), 1);
BOOST_CHECK_EQUAL(face1->sentNacks.back().getReason(), lp::NackReason::CONGESTION);
BOOST_CHECK_EQUAL(face1->sentNacks.back().getInterest().getNonce(), 152);
@@ -545,7 +545,7 @@
BOOST_CHECK(inRecord2a == pit2->in_end());
// send Nack with correct Nonce
- BOOST_CHECK(forwarder.onOutgoingNack(pit2, *face2, nackHeader));
+ BOOST_CHECK(forwarder.onOutgoingNack(nackHeader, *face2, pit2));
BOOST_CHECK_EQUAL(face1->sentNacks.size(), 1);
BOOST_REQUIRE_EQUAL(face2->sentNacks.size(), 1);
BOOST_CHECK_EQUAL(face2->sentNacks.back().getReason(), lp::NackReason::CONGESTION);
@@ -560,7 +560,7 @@
pit2->insertOrUpdateInRecord(*face3, *interest2c);
face3->sentNacks.clear();
- BOOST_CHECK(!forwarder.onOutgoingNack(pit2, *face3, nackHeader));
+ BOOST_CHECK(!forwarder.onOutgoingNack(nackHeader, *face3, pit2));
BOOST_CHECK_EQUAL(face3->sentNacks.size(), 0);
// don't send Nack to face with invalid ID
@@ -568,7 +568,7 @@
pit1->insertOrUpdateInRecord(*face4, *interest1b);
face4->sentNacks.clear();
- BOOST_CHECK(!forwarder.onOutgoingNack(pit1, *face4, nackHeader));
+ BOOST_CHECK(!forwarder.onOutgoingNack(nackHeader, *face4, pit1));
BOOST_CHECK_EQUAL(face4->sentNacks.size(), 0);
}
@@ -643,7 +643,6 @@
// interest should be forwarded only once, as long as Nonce is in Dead Nonce List
BOOST_ASSERT(25_ms * 40 < forwarder.getDeadNonceList().getLifetime());
this->advanceClocks(25_ms, 40);
-
BOOST_CHECK_EQUAL(face2->sentInterests.size(), 1);
// It's unnecessary to check that Interest with duplicate Nonce can be forwarded again
@@ -658,12 +657,12 @@
auto face1 = addFace();
auto interest = makeInterest("/hcLSAsQ9A", false, 2_s, 61883075);
- DeadNonceList& dnl = forwarder.getDeadNonceList();
+ auto& dnl = forwarder.getDeadNonceList();
dnl.add(interest->getName(), interest->getNonce());
- Pit& pit = forwarder.getPit();
- BOOST_REQUIRE_EQUAL(pit.size(), 0);
+ auto& pit = forwarder.getPit();
+ BOOST_CHECK_EQUAL(pit.size(), 0);
- forwarder.onIncomingInterest(FaceEndpoint(*face1, 0), *interest);
+ forwarder.onIncomingInterest(*interest, FaceEndpoint(*face1, 0));
this->advanceClocks(100_ms, 20_s);
BOOST_CHECK_EQUAL(pit.size(), 0);
}
@@ -674,7 +673,7 @@
auto data = makeData("/A");
BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 0);
- forwarder.onIncomingData(FaceEndpoint(*face1, 0), *data);
+ forwarder.onIncomingData(*data, FaceEndpoint(*face1, 0));
this->advanceClocks(1_ms, 10_ms);
BOOST_CHECK_EQUAL(forwarder.getCounters().nUnsolicitedData, 1);
}