From 69fce8837d354ccffc99c2daa4b574def524511e Mon Sep 17 00:00:00 2001 From: Steven Landers Date: Thu, 21 Mar 2024 13:45:17 -0400 Subject: [PATCH] re-align test changes --- internal/mempool/mempool_test.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/internal/mempool/mempool_test.go b/internal/mempool/mempool_test.go index 03bb3f7b4..b440503d3 100644 --- a/internal/mempool/mempool_test.go +++ b/internal/mempool/mempool_test.go @@ -3,6 +3,7 @@ package mempool import ( "bytes" "context" + "encoding/json" "errors" "fmt" "math/rand" @@ -945,17 +946,24 @@ func TestAppendCheckTxErr(t *testing.T) { } t.Cleanup(client.Wait) txmp := setup(t, client, 500) - existingLogData := `[{"log":"existing error log"}]` - newLogData := "sample error log" + existingData := `[{"log":"existing error log"}]` // Append new error - actualResult := txmp.AppendCheckTxErr(existingLogData, newLogData) - expectedResult := fmt.Sprintf(`[{"log":"existing error log"},{"log":"%s"}]`, newLogData) + result := txmp.AppendCheckTxErr(existingData, "sample error msg") - require.Equal(t, expectedResult, actualResult) + // Unmarshal the result + var data []map[string]interface{} + err := json.Unmarshal([]byte(result), &data) + require.NoError(t, err) + require.Equal(t, len(data), 2) + require.Equal(t, data[1]["log"], "sample error msg") // Append new error to empty log - actualResult = txmp.AppendCheckTxErr("", newLogData) + result = txmp.AppendCheckTxErr("", "sample error msg") - require.Equal(t, `[{"log":"sample error log"}]`, actualResult) + // Unmarshal the result + err = json.Unmarshal([]byte(result), &data) + require.NoError(t, err) + require.Equal(t, len(data), 1) + require.Equal(t, data[0]["log"], "sample error msg") }