Skip to content

Commit 5a5b757

Browse files
committed
alloc bigger tx bufs
1 parent 19125db commit 5a5b757

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/common.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <common/parser.h>
2020
#include <sstream>
21+
#include <memory>
2122
#include <string>
2223
#include <fmt/core.h>
2324
#include "common.h"
@@ -131,13 +132,17 @@ void check_testcase(const testcase_t &tc, bool expert_mode) {
131132
parser_context_t ctx = {0};
132133
parser_error_t err = parser_unexpected_error;
133134

134-
uint8_t buffer[10000] = {0};
135-
const uint16_t bufferLen = parseHexString(buffer, sizeof(buffer), tc.blob.c_str());
135+
uint16_t bufferCap = 0xffff;
136+
std::unique_ptr<uint8_t> buffer{new uint8_t[bufferCap]};
137+
ASSERT_NE(buffer, nullptr) << "Failed to allocate tx buffer";
138+
139+
const uint16_t bufferLen = parseHexString(buffer.get(), bufferCap, tc.blob.c_str());
140+
ASSERT_NE(bufferLen, 0) << "Failed to parse tx from provided blob: " << tc.blob;
136141

137142
parser_tx_t tx_obj;
138143
memset(&tx_obj, 0, sizeof(tx_obj));
139144

140-
err = parser_parse(&ctx, buffer, bufferLen, &tx_obj);
145+
err = parser_parse(&ctx, buffer.get(), bufferLen, &tx_obj);
141146
ASSERT_EQ(err, parser_ok) << parser_getErrorDescription(err);
142147

143148
err = parser_validate(&ctx);

0 commit comments

Comments
 (0)