Skip to content

Commit

Permalink
Add basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFeickert committed Apr 16, 2024
1 parent bd687b0 commit ab7c285
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/libspark/test/spend_transaction_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,50 @@ BOOST_AUTO_TEST_CASE(generate_verify)
// Verify
transaction.setCoverSets(cover_set_data);
BOOST_CHECK(SpendTransaction::verify(transaction, cover_sets));

// Produe a claim for this spend transaction
std::vector<unsigned char> claim_identifier = random_char_vector();
std::vector<unsigned char> claim_message = random_char_vector();
ChaumProof claim_proof;
SpendTransaction::proveClaim(
full_view_key,
spend_key,
transaction,
spend_coin_data,
claim_identifier,
claim_message,
claim_proof
);

// Verify the claim against the correct data
BOOST_CHECK(
SpendTransaction::verifyClaim(
transaction,
claim_identifier,
claim_message,
claim_proof
)
);

// (Fail to) verify the claim against an evil identifier
BOOST_CHECK(
!SpendTransaction::verifyClaim(
transaction,
random_char_vector(),
claim_message,
claim_proof
)
);

// (Fail to) verify the claim against an evil message
BOOST_CHECK(
!SpendTransaction::verifyClaim(
transaction,
claim_identifier,
random_char_vector(),
claim_proof
)
);
}

BOOST_AUTO_TEST_SUITE_END()
Expand Down

0 comments on commit ab7c285

Please sign in to comment.