Skip to content

Commit

Permalink
Add fail test.
Browse files Browse the repository at this point in the history
  • Loading branch information
suyash67 committed Mar 23, 2023
1 parent b358d4d commit 692683b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,36 @@ TEST(stdlib_bool, must_imply_multiple)
}
}

TEST(stdlib_bool, must_imply_multiple_fails)
{
honk::StandardHonkComposer composer = honk::StandardHonkComposer();

/**
* Given x = 15:
* (x > 10)
* => (x > 8)
* => (x > 5)
* ≠> (x > 18)
*/
for (size_t j = 0; j < 2; ++j) { // ignore when both lhs and rhs are constants
bool is_constant = (bool)(j % 2);

size_t x = 15;
bool main = (bool)(x > 10);
bool_t main_ct = is_constant ? bool_t(main) : (witness_t(&composer, main));

std::vector<std::pair<bool_t, std::string>> conditions;
conditions.push_back(std::make_pair(witness_t(&composer, x > 8), "x > 8"));
conditions.push_back(std::make_pair(witness_t(&composer, x > 5), "x > 5"));
conditions.push_back(std::make_pair(witness_t(&composer, x > 18), "x > 18"));

main_ct.must_imply(conditions);

EXPECT_EQ(composer.failed(), true);
EXPECT_EQ(composer.err(), "multi implication fail: x > 18");
}
}

TEST(stdlib_bool, test_simple_proof)
{
honk::StandardHonkComposer composer = honk::StandardHonkComposer();
Expand Down

0 comments on commit 692683b

Please sign in to comment.