Skip to content

Commit

Permalink
chore(avm-circuit): tests use OpCode enum's instead of hardcoded valu…
Browse files Browse the repository at this point in the history
…es (#4554)
  • Loading branch information
dbanks12 committed Feb 12, 2024
1 parent d172f0b commit ca4dd60
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 146 deletions.
11 changes: 11 additions & 0 deletions barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_opcode.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "AvmMini_opcode.hpp"

#include <cstdint>
#include <iomanip>
#include <sstream>

namespace avm_trace {

Expand Down Expand Up @@ -150,4 +153,12 @@ bool Bytecode::has_in_tag(OpCode const op_code)
}
}

std::string to_hex(OpCode opcode)
{
std::ostringstream stream;
// pad with 0s to fill exactly 2 hex characters
stream << std::setfill('0') << std::setw(2) << std::hex << (static_cast<uint8_t>(opcode) & 0xFF);
return stream.str();
}

} // namespace avm_trace
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <cstddef>
#include <cstdint>
#include <string>
#include <unordered_map>

namespace avm_trace {
Expand Down Expand Up @@ -102,4 +103,6 @@ class Bytecode {
static const std::unordered_map<OpCode, size_t> OPERANDS_NUM;
};

std::string to_hex(OpCode opcode);

} // namespace avm_trace
Loading

0 comments on commit ca4dd60

Please sign in to comment.