From 76a27f58b66e801feef1c836c66753ffd172c13d Mon Sep 17 00:00:00 2001
From: "Eduardo Ramos Testillano (eramedu)"
 <eduardo.ramos.testillano@ericsson.com>
Date: Sun, 9 Jun 2019 05:21:25 +0200
Subject: [PATCH] Fix answer condition from message

Answer was wrongly calculated from message, then
always answer was true when request, and false
when answer.

Also adds a trace to get the wait for request value.
---
 source/testing/TestStep.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/source/testing/TestStep.cpp b/source/testing/TestStep.cpp
index 4a75f3b..07ed6b3 100644
--- a/source/testing/TestStep.cpp
+++ b/source/testing/TestStep.cpp
@@ -345,7 +345,7 @@ throw() {
     xmlmsg += "\n";
   }
   else {
-    xmlmsg = "<unable to decode, check traces>"; 
+    xmlmsg = "<unable to decode, check traces>";
   }
 
   if (msg != "") result->createAttribute("Message", msg);
@@ -368,12 +368,16 @@ bool TestStepSendxml::do_execute() throw() {
   try {
 
     if (a_waitForRequestStepNumber != -1) {
+      bool thisIsAnswer = anna::diameter::codec::functions::isAnswer(getMsgDataBlock());
+      LOGDEBUG(
+         std::string trace = anna::functions::asString("'Wait For Request' step number for this %s: %d", (thisIsAnswer ? "answer":"request"), a_waitForRequestStepNumber);
+         anna::Logger::debug(trace, ANNA_FILE_LOCATION);
+      );
 
       // Referenced request in the 'wait for request step':
       tsw = static_cast<const TestStepWait*>(a_testCase->getStep(a_waitForRequestStepNumber));
       const anna::DataBlock &referenceRequest = tsw->getMsgDataBlock();
       std::string sessionIdReferenceRequest = anna::diameter::helpers::base::functions::getSessionId(referenceRequest);
-      bool thisIsAnswer = anna::diameter::codec::functions::isRequest(getMsgDataBlock());
 
       if (thisIsAnswer) { // is an answer: try to copy sequence information; alert about Session-Id discrepance
         anna::diameter::HopByHop hbh = anna::diameter::codec::functions::getHopByHop(referenceRequest);
@@ -600,7 +604,7 @@ throw() {
       xmlmsg += "\n";
     }
     else {
-      xmlmsg = "<unable to decode, check traces>"; 
+      xmlmsg = "<unable to decode, check traces>";
     }
   }
 
-- 
2.20.1