aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests/apply_permutation.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-09-12 21:41:30 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-09-18 11:23:15 +0100
commit6137a0b94d86e9f1c3321969da1c74f1d5e72b4f (patch)
tree5f22756053d60d8200e138192c94cd918911871e /tests/unit_tests/apply_permutation.cpp
parentcore: sort ins and outs key key image and public key, respectively (diff)
downloadmonero-6137a0b94d86e9f1c3321969da1c74f1d5e72b4f.tar.xz
blockchain: reject unsorted ins and outs from v7
This ensures no information is leaked by the ordering
Diffstat (limited to '')
-rw-r--r--tests/unit_tests/apply_permutation.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/unit_tests/apply_permutation.cpp b/tests/unit_tests/apply_permutation.cpp
index 888a00746..a008b74ee 100644
--- a/tests/unit_tests/apply_permutation.cpp
+++ b/tests/unit_tests/apply_permutation.cpp
@@ -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) {}
+}