From fdc00d090684bb2696e3fa8ea8600973310dc00e Mon Sep 17 00:00:00 2001 From: stoffu Date: Mon, 9 Sep 2019 11:44:06 +0900 Subject: unit tests: replace global var with lambda returning static local var Fixes assertion failure (curstate == 1) in random.c in debug mode --- tests/unit_tests/ringdb.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/unit_tests/ringdb.cpp') diff --git a/tests/unit_tests/ringdb.cpp b/tests/unit_tests/ringdb.cpp index ab634ea82..626616acc 100644 --- a/tests/unit_tests/ringdb.cpp +++ b/tests/unit_tests/ringdb.cpp @@ -65,11 +65,11 @@ static std::pair generate_output() } -static const crypto::chacha_key KEY_1 = generate_chacha_key(); -static const crypto::chacha_key KEY_2 = generate_chacha_key(); -static const crypto::key_image KEY_IMAGE_1 = generate_key_image(); -static const std::pair OUTPUT_1 = generate_output(); -static const std::pair OUTPUT_2 = generate_output(); +#define KEY_1 []{ static const crypto::chacha_key KEY_1 = generate_chacha_key(); return KEY_1; }() +#define KEY_2 []{ static const crypto::chacha_key KEY_2 = generate_chacha_key(); return KEY_2; }() +#define KEY_IMAGE_1 []{ static const crypto::key_image KEY_IMAGE_1 = generate_key_image(); return KEY_IMAGE_1; }() +#define OUTPUT_1 []{ static const std::pair OUTPUT_1 = generate_output(); return OUTPUT_1; }() +#define OUTPUT_2 []{ static const std::pair OUTPUT_2 = generate_output(); return OUTPUT_2; }() class RingDB: public tools::ringdb { -- cgit v1.2.3