Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Add missing unit tests for validators module [API section] getGeneratorsBetweenTimestamps #7267

Closed
Tracked by #7245
sitetester opened this issue Jun 29, 2022 · 1 comment
Assignees
Milestone

Comments

@sitetester
Copy link
Contributor

sitetester commented Jun 29, 2022

getGeneratorsBetweenTimestamps

  • all entries in generatorList are pairwise distinct - startTimestamp == genesisData.timestamp - endTimestamp == genesisData.timestamp + 3 * BLOCK_TIME" (return {generatorList[1]:1, generatorList[2]:1})

- Let a:=slot(startTimestamp) and b:=slot(endTimestamp) - all entries in generatorList are equal but the length of the list is larger than 1 - startTimestamp < endTimestamp - b = a + n, where n > 1

Expectation:
"return {generatorList[0]: n-1}
The returned object has only one entry.
The sum of all values is n-1."


"Let a:=slot(startTimestamp), b:=slot(endTimestamp) and L:=length(generatorList).

  • all entries in generatorList are pairwise distinct
  • startTimestamp < endTimestamp
  • b = a + n, where 1 < n < L
  • a % L < b % L"

Expectation:
"for the generators with index a%L < j < b%L the count is 1, and for all other generators, the count is 0.
The returned object has n-1 entries.
The sum of all values is n-1."


"Let a:=slot(startTimestamp), b:=slot(endTimestamp) and L:=length(generatorList).

  • all entries in generatorList are pairwise distinct
  • startTimestamp < endTimestamp
  • b = a + n, where n > L; n = k* L + n', with k >= 1; n' < L
  • a % L < b % L "

Expectation:
"for the generators with index a%L < j < b%L the count is k+1, and for all other generators, the count is k.
The returned object has L entries.
The sum of all values is n-1."


"Let a:=slot(startTimestamp), b:=slot(endTimestamp) and L:=length(generatorList). - all entries in generatorList are pairwise distinct - startTimestamp < endTimestamp - b = a + n, where 1 < n < L - a % L > b % L"

Expectation:
"for the generators with index b%L <= j <= a%L the count is 0, and for all other generators, the count is 1.
The returned object has n-1 entries.
The sum of all values is n-1."


"Let a:=slot(startTimestamp), b:=slot(endTimestamp) and L:=length(generatorList).

  • all entries in generatorList are pairwise distinct
  • startTimestamp < endTimestamp
  • b = a + n, where n > L; n = k* L + n', with k >= 1; n' < L
  • a % L > b % L "

Expectation:
"for the generators with index b%L <= j <= a%L the count is k, and for all other generators, the count is k+1.
The returned object has L entries.
The sum of all values is n-1."


"Let a:=slot(startTimestamp), b:=slot(endTimestamp) and L:=length(generatorList).

  • all entries in generatorList are pairwise distinct
  • startTimestamp < endTimestamp
  • b = a + L; basically set n=L
  • ==> a % L == b % L "

Expectation:
"for the generators with index j==a%L==b%L the count is 0, and for all other generators, the count is 1.
The returned object has L-1 entries.
The sum of all values is L-1."


"Let a:=slot(startTimestamp), b:=slot(endTimestamp) and L:=length(generatorList).

  • all entries in generatorList are pairwise distinct
  • startTimestamp < endTimestamp
  • b = a + k* L; basically set n= k*L
  • ==> a % L == b % L "

Expectation:
"for the generators with index j==a%L==b%L the count is k-1, and for all other generators, the count is k.
The returned object has L entries.
The sum of all values is n-1 = k*L-1."


"Repeat all tests from 76 to 81 but:

  • remove the condition: all entries in generatorList are pairwise distinct.
  • add the condition: all entries are pairwise distinct but the first one is repeated at the end."

Expectation:
we expect the same results as in tests 76-81 if we understand all slots assigned to the last entry of the generatorList to be assigned to the first entry (so that this entry gets the sum of the two values)


Which version(s) does this affect? (Environment, OS, etc...)
Lisk SDK development branch

@Madhulearn Madhulearn added this to the Sprint 85 milestone Dec 19, 2022
@Madhulearn Madhulearn modified the milestones: Sprint 85, Sprint 86 Jan 3, 2023
@Madhulearn Madhulearn modified the milestones: Sprint 86, Sprint 87 Jan 17, 2023
@Madhulearn Madhulearn modified the milestones: Sprint 87, Sprint 88 Jan 30, 2023
@Madhulearn Madhulearn modified the milestones: Sprint 88, Sprint 89 Feb 13, 2023
@Madhulearn Madhulearn modified the milestones: Sprint 89, Sprint 90 Feb 28, 2023
@shuse2 shuse2 removed this from the Sprint 90 milestone Mar 2, 2023
@Madhulearn Madhulearn added this to the Sprint 94 milestone Apr 24, 2023
@Madhulearn Madhulearn modified the milestones: Sprint 94, Sprint 95 May 9, 2023
@Madhulearn Madhulearn modified the milestones: Sprint 95, Sprint 96 May 22, 2023
@Madhulearn Madhulearn removed this from the Sprint 96 milestone May 22, 2023
@shuse2 shuse2 removed the type: bug label May 23, 2023
@Madhulearn Madhulearn added this to the Sprint 107 milestone Oct 24, 2023
@has5aan
Copy link
Contributor

has5aan commented Oct 31, 2023

Suggested improvements have been made under issue #8115.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants