mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Merge remote-tracking branch 'origin/dao-permute-blindvotelist-if-not-majority-hash' into dao-permute-blindvotelist-if-not-majority-hash
This commit is contained in:
commit
7a6cce615a
@ -60,7 +60,7 @@ public class PermutationUtil {
|
||||
* With 20 items we reach about 1 million iterations and it takes about 0.5 sec.
|
||||
* To avoid performance issues we added the maxIterations parameter to stop once the number of iterations has
|
||||
* reached the maxIterations and return in such a case the list of permutations we have been able to create.
|
||||
* Depending on the type of object which is stored in the list the memory usage should to be considered as well for
|
||||
* Depending on the type of object which is stored in the list the memory usage should be considered as well for
|
||||
* choosing the right maxIterations value.
|
||||
*
|
||||
* @param list List from which we create permutations
|
||||
|
@ -51,7 +51,7 @@ public class PermutationTest {
|
||||
assertTrue(expected.toString().equals(result.toString()));
|
||||
|
||||
// remove first
|
||||
indicesToRemove = indicesToRemove = Collections.singletonList(0);
|
||||
indicesToRemove = Collections.singletonList(0);
|
||||
expected = new ArrayList<>(list);
|
||||
expected.remove(0);
|
||||
result = PermutationUtil.getPartialList(list, indicesToRemove);
|
||||
@ -65,31 +65,31 @@ public class PermutationTest {
|
||||
assertTrue(expected.toString().equals(result.toString()));
|
||||
|
||||
// remove all
|
||||
indicesToRemove = indicesToRemove = Arrays.asList(0, 1, 2, 3, 4, 5);
|
||||
indicesToRemove = Arrays.asList(0, 1, 2, 3, 4, 5);
|
||||
expected = new ArrayList<>();
|
||||
result = PermutationUtil.getPartialList(list, indicesToRemove);
|
||||
assertTrue(expected.toString().equals(result.toString()));
|
||||
|
||||
// wrong sorting of indices
|
||||
indicesToRemove = indicesToRemove = Arrays.asList(4, 0, 1);
|
||||
indicesToRemove = Arrays.asList(4, 0, 1);
|
||||
expected = expected = new ArrayList<>(Arrays.asList(blindVote2, blindVote3, blindVote5));
|
||||
result = PermutationUtil.getPartialList(list, indicesToRemove);
|
||||
assertTrue(expected.toString().equals(result.toString()));
|
||||
|
||||
// wrong sorting of indices
|
||||
indicesToRemove = indicesToRemove = Arrays.asList(0, 0);
|
||||
expected = expected = new ArrayList<>(Arrays.asList(blindVote1, blindVote2, blindVote3, blindVote4, blindVote5));
|
||||
indicesToRemove = Arrays.asList(0, 0);
|
||||
expected = new ArrayList<>(Arrays.asList(blindVote1, blindVote2, blindVote3, blindVote4, blindVote5));
|
||||
result = PermutationUtil.getPartialList(list, indicesToRemove);
|
||||
assertTrue(expected.toString().equals(result.toString()));
|
||||
|
||||
// don't remove as invalid index
|
||||
indicesToRemove = indicesToRemove = Collections.singletonList(9);
|
||||
indicesToRemove = Collections.singletonList(9);
|
||||
expected = new ArrayList<>(list);
|
||||
result = PermutationUtil.getPartialList(list, indicesToRemove);
|
||||
assertTrue(expected.toString().equals(result.toString()));
|
||||
|
||||
// don't remove as invalid index
|
||||
indicesToRemove = indicesToRemove = Collections.singletonList(-2);
|
||||
indicesToRemove = Collections.singletonList(-2);
|
||||
expected = new ArrayList<>(list);
|
||||
result = PermutationUtil.getPartialList(list, indicesToRemove);
|
||||
assertTrue(expected.toString().equals(result.toString()));
|
||||
|
Loading…
Reference in New Issue
Block a user