Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend end-to-end tests to cover more voting scenarios #863

Closed
8 tasks done
p4u opened this issue Mar 24, 2023 · 9 comments
Closed
8 tasks done

Extend end-to-end tests to cover more voting scenarios #863

p4u opened this issue Mar 24, 2023 · 9 comments
Assignees
Labels
apiv2 apiv2 ci enhancement New feature or request go Pull requests that update Go code

Comments

@p4u
Copy link
Member

p4u commented Mar 24, 2023

We need to extend the end-to-end tests with a new voting test named something like "test voting protocol". This test should cover various voting scenarios and capabilities of the Vocdoni protocol to ensure the correct behavior and stability of the system.

The test should include the following scenarios and verifications:

  • Secret Until The End Elections: the apiclient Vote method would transparently encrypt the vote if the election is secretUntilTheEnd (encrypt elections support for end2end test #846)

  • Max Vote Overwrite: Verify that the same voter can send up to N votes, and each new vote should override the previous one. This will ensure the maxVoteOverwrite feature works as intended.

  • Max Census Size Restriction: Test the behavior when creating an election with a maxCensusSize smaller than the actual census size. Ensure that no additional votes can be cast once the limit is reached, thus validating the maxCensusSize restriction feature.

  • Ballot Protocol: Test different ballotProtocol configurations and validate that the final results are computed correctly based on the configuration parameters (uniqueValues, costFromWeight, maxCount, maxValue, maxTotalCost, costExponent). This will ensure the versatility and correctness of the ballot protocol (see https://hackmd.io/Sd08WpUPSVu6DEK9hSA-6Q)

  • Election Status: Test and verify the transitions of an election (READY, PAUSED, RESULTS, etc.) to ensure that only allowed transitions work correctly. This will validate the robustness of the election status management.

  • Un-interruptible Enforcement: Check if the interruptible flag works as expected by ensuring that elections with this flag set to false cannot be interrupted. This will validate the proper enforcement of the un-interruptible feature.

  • Dynamic Census: Test the dynamic census flag and feature by verifying that it works as expected in various scenarios. This will ensure the correct functionality of the dynamic census feature.

  • CSP Election: this was implemented in vochaintest as csptest. migrate it to end2endtest

@altergui
Copy link
Contributor

i'm doing "Secret Until The End Elections" and @mariajdab will start with "Max Vote Overwrite" today

@p4u
Copy link
Member Author

p4u commented Mar 28, 2023

We should create a modular and flexible interface that all test implementations must follow. This will allow the main() function to call the interface methods of the selected test without having to modify the core code for each new test case.

Goals

  • Design and implement a flexible and modular interface for all Vochain-related tests.
  • Refactor the current integration testing program to use the new interface.
  • Update documentation and provide examples for using the new interface.

Interface

type VochainTest interface {
    Setup(api *apiclient.Client, config *Config) error
    Run() (duration time.Time, err error)
    Teardown() error
}

The VochainTest interface should include three methods: Setup, Run, and Teardown. The Setup method initializes the test environment and performs any prepare operation (such as building the Census), the Run method executes the test scenario, and the Teardown method cleans up any resources created during the test.

Example

You can then update the main function to call the interface methods of the selected test:

func main() {
	// ...
	// Parse flags, configure logger, etc.
	// ...

	var test VochainTest
	found := false
	for _, op := range ops {
		if op.name == c.operation {
			test = op.test
			found = true
		}
	}

	if !found {
		log.Fatal("no valid operation mode specified")
	}

	api, err := createAPI(c.host, c.accountKeys[0])
	if err != nil {
		log.Fatal(err)
	}

	err = test.Setup(api, &c)
	if err != nil {
		log.Fatal(err)
	}

	duration, err := test.Run()
	if err != nil {
		log.Fatal(err)
	}
	log.Infow("test finished", "duration", duration)
}

Test definition:

var ops = []struct {
	name        string
	description string
	example     string
	test        VochainTest
}{
	{
		name:        "merkleTreeVoting",
		description: "Perform a Merkle Tree Voting test",
		example:     "vocdoni -operation merkleTreeVoting",
		test:        &MerkleTreeVotingTest{},
	},
	// Add more tests here
}

This is just a proposal, feel free to design your own structure, but please explain the rationale behind your decisions.

@p4u p4u added enhancement New feature or request go Pull requests that update Go code ci apiv2 apiv2 labels Mar 28, 2023
@p4u
Copy link
Member Author

p4u commented Mar 31, 2023

How is this going? can you update on the status? any blockers?

@altergui
Copy link
Contributor

altergui commented Apr 18, 2023

progress in
#874
#873
#846

@p4u
Copy link
Member Author

p4u commented May 2, 2023

Please, @mariajdab @altergui mark as done (checkbox) once a test is merged into master

@p4u
Copy link
Member Author

p4u commented Jul 10, 2023

Regarding the Ballot Protocol test. How far did the implementation go?

How many of the following types of votings are being tested? https://blog.aragon.org/vocdoni-ballot-protocol/

@mariajdab
Copy link
Contributor

mariajdab commented Jul 10, 2023

Regarding the Ballot Protocol test. How far did the implementation go?

How many of the following types of votings are being tested? https://blog.aragon.org/vocdoni-ballot-protocol/

I think in the end2end test for ballot we are checking only the Quadratic Voting but using the default value of 1, so it could be updated to use 2 as costExponent. The focus of the current test was checking results when the constrain for valid votes exceeds maxValue, maxTotalCost and is not unique values.

@p4u
Copy link
Member Author

p4u commented Jul 11, 2023

With costExponent=1 this is not quadratic voting. Quadratic means exponent=2

The ballot protocol test proposed was meant to check that the different types of votes supported by the ballot protocol are correctly implemented.

At least the following should be checked:

  • quadratic voting
  • ranked choice
  • range voting
  • approval voting

To understand how these types of votes work, you can search them on Google (all are well known) and also check these documents: https://developer.vocdoni.io/protocol/ballot https://blog.aragon.org/vocdoni-ballot-protocol/ https://hackmd.io/Sd08WpUPSVu6DEK9hSA-6Q

If you need any clarification, do not hesitate to ask.

@altergui
Copy link
Contributor

epic work, hurray! congrats @mariajdab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apiv2 apiv2 ci enhancement New feature or request go Pull requests that update Go code
Projects
None yet
Development

No branches or pull requests

3 participants