blockchain: reject unsorted ins and outs from v7

This ensures no information is leaked by the ordering
This commit is contained in:
moneromooo-monero 2017-09-12 21:41:30 +01:00
parent 16afab900d
commit 6137a0b94d
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
3 changed files with 76 additions and 1 deletions

View file

@ -43,3 +43,32 @@ TEST(apply_permutation, reorder)
tools::apply_permutation({3, 5, 6, 1, 2, 4, 0}, v);
ASSERT_EQ(v, std::vector<int>({1, 2, 4, 4, 6, 7, 8}));
}
TEST(apply_permutation, bad_size)
{
std::vector<int> v_large = {8, 4, 6, 1, 7, 2, 4, 9};
std::vector<int> v_small = {8, 4, 6, 1, 7, 2};
try
{
tools::apply_permutation({3, 5, 6, 1, 2, 4, 0}, v_large);
ASSERT_FALSE(true);
}
catch (const std::exception &e) {}
try
{
tools::apply_permutation({3, 5, 6, 1, 2, 4, 0}, v_small);
ASSERT_FALSE(true);
}
catch (const std::exception &e) {}
}
TEST(apply_permutation, bad_permutation)
{
std::vector<int> v = {8, 4, 6, 1, 7, 2, 4};
try
{
tools::apply_permutation({3, 5, 6, 1, 2, 4, 1}, v);
ASSERT_FALSE(true);
}
catch (const std::exception &e) {}
}