Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use boost assertions in bbf tests #300

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions crypto3/libs/blueprint/test/bbf/keccak_round.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ void test_bbf_keccak_round(const std::array<typename field_type::value_type, 25>
raw_input = {inner_state, message_chunks, RC};
auto B = bbf::circuit_builder<field_type, bbf::keccak_round, bool>(xor_with_mes);
auto [at, A, desc] = B.assign(raw_input);
bool is_satisfied = B.is_satisfied(at);
std::cout << "Is_satisfied = " << is_satisfied << std::endl;
assert(is_satisfied);
BOOST_TEST(B.is_satisfied(at), "constraints are not satisfied");
for (std::size_t i = 0; i < 25; i++) {
assert(expected_res[i] == A.inner_state[i]);
BOOST_CHECK(expected_res[i] == A.inner_state[i]);
}
}
template<typename BlueprintFieldType, bool xor_with_mes>
Expand Down Expand Up @@ -225,4 +223,4 @@ BOOST_AUTO_TEST_CASE(blueprint_plonk_hashes_keccak_round_bbf_not_random_pallas)
state = expected_result;
}
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
2 changes: 1 addition & 1 deletion crypto3/libs/blueprint/test/bbf/opcode_poc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void test_opcode_poc(
std::cout << "input_size = " << blocks.size() << std::endl;
auto B = circuit_builder<field_type,opcode_poc,std::size_t>(max_rows);
auto [at, A, desc] = B.assign(raw_input);
std::cout << "Is_satisfied = " << B.is_satisfied(at) << std::endl;
BOOST_TEST(B.is_satisfied(at), "constraints are not satisfied");
}


Expand Down
10 changes: 5 additions & 5 deletions crypto3/libs/blueprint/test/bbf/poseidon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ void test_poseidon(std::vector<typename BlueprintFieldType::value_type> public_i

auto B = bbf::circuit_builder<FieldType,bbf::components::flexible_poseidon>();
auto [at, A, desc] = B.assign(raw_input);
std::cout << "Is_satisfied = " << B.is_satisfied(at) << std::endl;
BOOST_TEST(B.is_satisfied(at));

for (std::uint32_t i = 0; i < public_input.size(); i++) {
std::cout << "input[" << i << "] : " << public_input[i].data << "\n";
std::cout << "expected[" << i << "]: " << expected_res[i].data << "\n";
std::cout << "real[" << i << "] : " << A.res[i] << "\n";
assert(expected_res[i] == A.res[i]);
BOOST_TEST_INFO("input: " << public_input[i].data);
BOOST_TEST_INFO("expected: " << expected_res[i].data);
BOOST_TEST_INFO("real: " << A.res[i]);
BOOST_TEST(A.res[i] == expected_res[i], "unexpected result for input " << i);
}
}

Expand Down
2 changes: 1 addition & 1 deletion crypto3/libs/blueprint/test/bbf/tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void test_bbf_tester(std::array<typename FieldType::value_type,8> public_input)

auto B = circuit_builder<FieldType,bbf_tester>();
auto [at, A, desc] = B.assign(raw_input);
std::cout << "Is_satisfied = " << B.is_satisfied(at) << std::endl;
BOOST_TEST(B.is_satisfied(at), "constraints are not satisfied");
}

static const std::size_t random_tests_amount = 10;
Expand Down