From 3e146c891eed7fe6412ae84a4e7aae8c63213d33 Mon Sep 17 00:00:00 2001
From: jgromes <jan.gromes>
Date: Sun, 19 Jan 2025 21:45:32 +0100
Subject: [PATCH] [CI] Fix SPI log wipe

---
 extras/test/unit/include/TestHal.hpp | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/extras/test/unit/include/TestHal.hpp b/extras/test/unit/include/TestHal.hpp
index 389bef13..56b90cb6 100644
--- a/extras/test/unit/include/TestHal.hpp
+++ b/extras/test/unit/include/TestHal.hpp
@@ -47,6 +47,9 @@ class TestHal : public RadioLibHal {
         this->gpio[i].event = false;
         this->gpio[i].func = PIN_UNASSIGNED;
       }
+
+      // wipe history log
+      this->spiLogWipe();
     }
 
     void term() override {
@@ -181,10 +184,6 @@ class TestHal : public RadioLibHal {
 
     void spiBeginTransaction() {
       HAL_LOG("TestHal::spiBeginTransaction()");
-
-      // wipe history log
-      memset(this->spiLog, 0x00, TEST_HAL_SPI_LOG_LENGTH);
-      this->spiLogPtr = this->spiLog;
     }
 
     void spiTransfer(uint8_t* out, size_t len, uint8_t* in) {
@@ -228,7 +227,14 @@ class TestHal : public RadioLibHal {
 
     // method to compare buffer to the internal SPI log, for verifying SPI transactions
     int spiLogMemcmp(const void* in, size_t n) {
-      return(memcmp(this->spiLog, in, n));
+      int ret = memcmp(this->spiLog, in, n);
+      this->spiLogWipe();
+      return(ret);
+    }
+
+    void spiLogWipe() {
+      memset(this->spiLog, 0x00, TEST_HAL_SPI_LOG_LENGTH);
+      this->spiLogPtr = this->spiLog;
     }
 
     // method that "connects" the emualted radio hardware to this HAL