Skip to content

Commit

Permalink
[CASESession] refactoring and improving testability of Sigma1 sending…
Browse files Browse the repository at this point in the history
… and handling, and Sigma2 Sending (#36679)

* Removing networking bits from CASESession ParseSigma1 and creating EncodeSigma1

* integrating comments

* Refactoring HandleSigma1_and_SendSigma2 and functions called within it

* Adding Encrypted2 datalen check

* renaming variables

* Making Parsing and Encoding methods protected

* Converting TLV tags to enum class

* Making structs protected and making Unit Test inherit CASESession

* integrating comments

* Integrating comments in TestCASESession

* integrate comments on CASESession

* Integrating more comments

* Using a Variant for the NextStep logic in HandleSigma1, to either send a Sigma message or a status report

* fixing clang-tidy error

* more comments

* comments integration
  • Loading branch information
Alami-Amine authored Dec 23, 2024
1 parent 017e8b5 commit 4865e5e
Show file tree
Hide file tree
Showing 4 changed files with 850 additions and 376 deletions.
27 changes: 27 additions & 0 deletions src/lib/support/CodeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,33 @@
} \
} while (false)

/**
* @def ReturnErrorVariantOnFailure(expr)
*
* @brief
* This is for use when the calling function returns a Variant type. It returns a CHIP_ERROR variant with the corresponding error
* code if the expression returns an error.
*
* Example usage:
*
* @code
* ReturnErrorVariantOnFailure(NextStep, ParseSigma1(tlvReader, parsedSigma1));
* @endcode
*
* @param[in] variantType The Variant type that the calling function returns.
* @param[in] expr An expression to be tested.
*/
#define ReturnErrorVariantOnFailure(variantType, expr) \
do \
{ \
auto __err = (expr); \
if (!::chip::ChipError::IsSuccess(__err)) \
{ \
return variantType::Create<CHIP_ERROR>(__err); \
} \
} while (false)

/**
* @def ReturnLogErrorOnFailure(expr)
*
Expand Down
Loading

0 comments on commit 4865e5e

Please sign in to comment.