lte/gateway/c/session_manager/test/test_session_credit.cpp
// The maximum of reported usage is NOT capped by what is granted even when an
// user overused.
The maximum of reported usage is NOT capped by what is granted even when an
user overused.
The maximum of reported usage is NOT capped by what is granted even when an user overused .
TEST(test_collect_updates_when_overusing, test_session_credit) {
  SessionCredit credit;
  SessionCreditUpdateCriteria uc{};
  GrantedUnits gsu;
  uint64_t grant = 1000;
  create_granted_units(&grant, NULL, NULL, &gsu);
  credit.receive_credit(gsu, &uc);
  credit.add_used_credit(510, 500, &uc);
  EXPECT_TRUE(credit.is_quota_exhausted(0.8));
  RequestedUnits ru = credit.get_requested_credits_units();
  EXPECT_EQ(ru.total(), 1000);
  auto update = credit.get_usage_for_reporting(&uc);
  EXPECT_EQ(update.bytes_tx, 510);
  EXPECT_EQ(update.bytes_rx, 500);
  EXPECT_TRUE(credit.is_reporting());
  EXPECT_TRUE(uc.reporting);
  EXPECT_EQ(credit.get_credit(REPORTING_TX), 510);
  EXPECT_EQ(credit.get_credit(REPORTING_RX), 500);
  EXPECT_EQ(uc.bucket_deltas[REPORTING_TX], 0);
  EXPECT_EQ(uc.bucket_deltas[REPORTING_RX], 0);
}
TEST ( test_collect_updates_when_overusing , test_session_credit ) { SessionCredit credit ; SessionCreditUpdateCriteria uc { } ; GrantedUnits gsu ; uint64_t grant = 1000 ; create_granted_units ( & grant , NULL , NULL , & gsu ) ; credit . receive_credit ( gsu , & uc ) ; credit . add_used_credit ( 510 , 500 , & uc ) ; EXPECT_TRUE ( credit . is_quota_exhausted ( 0.8 ) ) ; RequestedUnits ru = credit . get_requested_credits_units ( ) ; EXPECT_EQ ( ru . total ( ) , 1000 ) ; auto update = credit . get_usage_for_reporting ( & uc ) ; EXPECT_EQ ( update . bytes_tx , 510 ) ; EXPECT_EQ ( update . bytes_rx , 500 ) ; EXPECT_TRUE ( credit . is_reporting ( ) ) ; EXPECT_TRUE ( uc . reporting ) ; EXPECT_EQ ( credit . get_credit ( REPORTING_TX ) , 510 ) ; EXPECT_EQ ( credit . get_credit ( REPORTING_RX ) , 500 ) ; EXPECT_EQ ( uc . bucket_deltas [ REPORTING_TX ] , 0 ) ; EXPECT_EQ ( uc . bucket_deltas [ REPORTING_RX ] , 0 ) ; }
The maximum of reported usage is NOT capped by what is granted even when an
user overused.
The maximum of reported usage is NOT capped by what is granted even when an user overused .
// Only track how much has been reported. The currently reporting amount // should be held in memory only.