Skip to content

Commit c716d69

Browse files
committed
Add basic tests
1 parent 16c63a4 commit c716d69

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/libspark/test/spend_transaction_test.cpp

+44
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,50 @@ BOOST_AUTO_TEST_CASE(generate_verify)
129129
for (const auto set_data : cover_set_data)
130130
cover_sets[set_data.first] = set_data.second.cover_set;
131131
BOOST_CHECK(SpendTransaction::verify(transaction, cover_sets));
132+
133+
// Produe a claim for this spend transaction
134+
std::vector<unsigned char> claim_identifier = random_char_vector();
135+
std::vector<unsigned char> claim_message = random_char_vector();
136+
ChaumProof claim_proof;
137+
SpendTransaction::proveClaim(
138+
full_view_key,
139+
spend_key,
140+
transaction,
141+
spend_coin_data,
142+
claim_identifier,
143+
claim_message,
144+
claim_proof
145+
);
146+
147+
// Verify the claim against the correct data
148+
BOOST_CHECK(
149+
SpendTransaction::verifyClaim(
150+
transaction,
151+
claim_identifier,
152+
claim_message,
153+
claim_proof
154+
)
155+
);
156+
157+
// (Fail to) verify the claim against an evil identifier
158+
BOOST_CHECK(
159+
!SpendTransaction::verifyClaim(
160+
transaction,
161+
random_char_vector(),
162+
claim_message,
163+
claim_proof
164+
)
165+
);
166+
167+
// (Fail to) verify the claim against an evil message
168+
BOOST_CHECK(
169+
!SpendTransaction::verifyClaim(
170+
transaction,
171+
claim_identifier,
172+
random_char_vector(),
173+
claim_proof
174+
)
175+
);
132176
}
133177

134178
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)