Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
test_utils.hpp
Go to the documentation of this file.
1#pragma once
4#include <gtest/gtest.h>
5
7
21template <typename Builder> void check_circuit_and_gate_count(Builder& builder, uint32_t expected_gates_without_base)
22{
23 if (!builder.circuit_finalized) {
24 builder.finalize_circuit(/*ensure_nonzero=*/false);
25 }
26
27 // Add base gates: Ultra adds 1, Mega adds 4
28 uint32_t base_gates = 1; // Default for Ultra
30 base_gates = 4; // Mega
31 }
32 uint32_t expected_gates = expected_gates_without_base + base_gates;
33
34 uint32_t actual_gates = static_cast<uint32_t>(builder.get_num_finalized_gates());
35 EXPECT_EQ(actual_gates, expected_gates)
36 << "Gate count changed! Expected: " << expected_gates << " (" << expected_gates_without_base << " + "
37 << base_gates << " base), Actual: " << actual_gates;
38
39 // Ensure no failure flags and run the circuit checker
40 EXPECT_FALSE(builder.failed());
41 EXPECT_TRUE(CircuitChecker::check(builder));
42}
43
44} // namespace bb::stdlib::test_utils
static bool check(const Builder &circuit)
Check the witness satisifies the circuit.
AluTraceBuilder builder
Definition alu.test.cpp:123
void check_circuit_and_gate_count(Builder &builder, uint32_t expected_gates_without_base)
Utility function for gate count checking and circuit verification.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13