From: Razvan Becheriu Date: Fri, 16 Oct 2020 15:17:43 +0000 (+0300) Subject: [#1434] fixed unittests X-Git-Tag: Kea-1.9.1~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0598154899f9f65038cb8a2c5e449d64fa3d6ead;p=thirdparty%2Fkea.git [#1434] fixed unittests --- diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc index 5227fcebed..ce419a5212 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.cc +++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc @@ -704,6 +704,11 @@ Memfile_LeaseMgr::addLeaseInternal(const Lease4Ptr& lease) { } storage4_.insert(lease); + + // Update lease internal information with new values (allows update of the + // internal state between the creation of the Lease up to the point of + // insertion in the database). + lease->updateInternalTimestamp(); return (true); } @@ -735,6 +740,11 @@ Memfile_LeaseMgr::addLeaseInternal(const Lease6Ptr& lease) { } storage6_.insert(lease); + + // Update lease internal information with new values (allows update of the + // internal state between the creation of the Lease up to the point of + // insertion in the database). + lease->updateInternalTimestamp(); return (true); } @@ -1433,6 +1443,9 @@ Memfile_LeaseMgr::updateLease4Internal(const Lease4Ptr& lease) { lease_file4_->append(*lease); } + // Update lease internal information with new values. + lease->updateInternalTimestamp(); + // Use replace() to re-index leases. index.replace(lease_it, Lease4Ptr(new Lease4(*lease))); } @@ -1479,6 +1492,9 @@ Memfile_LeaseMgr::updateLease6Internal(const Lease6Ptr& lease) { lease_file6_->append(*lease); } + // Update lease internal information with new values. + lease->updateInternalTimestamp(); + // Use replace() to re-index leases. index.replace(lease_it, Lease6Ptr(new Lease6(*lease))); } diff --git a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc index 34c316a50f..be4b7e191e 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc @@ -3610,6 +3610,7 @@ TEST_F(AllocEngine6Test, globalHostReservedAddress) { // We verify the "time" change in case the lease returned to us // by expectOneLease ever becomes a copy and not what is in the lease mgr. --lease->cltt_; + --lease->old_cltt_; Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_, lease->addr_); ASSERT_TRUE(from_mgr); @@ -3674,6 +3675,7 @@ TEST_F(AllocEngine6Test, globalHostReservedPrefix) { // We verify the "time" change in case the lease returned to us // by expectOneLease ever becomes a copy and not what is in the lease mgr. --lease->cltt_; + --lease->old_cltt_; Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_, lease->addr_); ASSERT_TRUE(from_mgr);