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

add integration test for /elections/price endpoint #1140

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

altergui
Copy link
Contributor

@altergui altergui commented Oct 10, 2023

without fix #1138, this new test reproduces the bug in cost estimation:

go test ./test/ -run TestAPIElectionCost -count=1 -v
=== RUN   TestAPIElectionCost
    api.go:52: address: http://127.0.0.1:40415/
    vochain.go:139: starting vochain indexer
    apiclient.go:34: querying http://127.0.0.1:40415/accounts
    apiclient.go:34: querying http://127.0.0.1:40415/chain/info
    apiclient.go:34: querying http://127.0.0.1:40415/chain/transactions/count
    apiclient.go:34: querying http://127.0.0.1:40415/censuses/weighted
    apiclient.go:34: querying http://127.0.0.1:40415/censuses/50c4eaf182c18d3922bbd402e70bd26f2738e6c3608b93aa3876dd753bc9a3cf/publish
    apiclient.go:34: querying http://127.0.0.1:40415/elections/price
    apiclient.go:34: querying http://127.0.0.1:40415/accounts/0x8f6664A47be5bCc6E1A2b3698FB936aaCF044DF5
    apiclient.go:34: querying http://127.0.0.1:40415/elections
    apiclient.go:34: querying http://127.0.0.1:40415/chain/info
    apiclient.go:34: querying http://127.0.0.1:40415/chain/transactions/count
    apiclient.go:34: querying http://127.0.0.1:40415/accounts/0x8f6664A47be5bCc6E1A2b3698FB936aaCF044DF5
    api_test.go:353: 
        error:
          values are not equal
        comment:
          endpoint /elections/price predicted cost 6, but actual election creation costed 11
        got:
          uint64(4989)
        want:
          uint64(4994)
        stack:
          /home/user/src/vocdoni/vocdoni-node/test/api_test.go:353
            qt.Assert(t, balance,
                qt.Equals, initialBalance-predictedPrice,
                qt.Commentf("endpoint /elections/price predicted cost %d, "+
                    "but actual election creation costed %d", predictedPrice, initialBalance-balance))
          /home/user/src/vocdoni/vocdoni-node/test/api_test.go:260
            runAPIElectionCostWithParams(t,
                electionprice.ElectionParameters{
                    MaxCensusSize:    100,
                    ElectionDuration: 2000,
                    EncryptedVotes:   false,
                    AnonymousVotes:   false,
                    MaxVoteOverwrite: 1,
                },
                10000, 5000,
                5, 1000,
                6)
        
--- FAIL: TestAPIElectionCost (0.24s)
FAIL
FAIL	go.vocdoni.io/dvote/test	0.292s
FAIL

@altergui altergui force-pushed the feat/electionpricetest branch 2 times, most recently from c33fa87 to fd25455 Compare October 11, 2023 09:14
@altergui altergui marked this pull request as ready for review October 11, 2023 09:16
@altergui altergui requested a review from p4u October 11, 2023 09:26
@altergui altergui force-pushed the feat/electionpricetest branch from fd25455 to f31737c Compare October 11, 2023 09:27
@altergui altergui requested a review from mariajdab October 11, 2023 10:56
@altergui altergui merged commit 4a575a5 into main Oct 13, 2023
10 checks passed
@altergui altergui deleted the feat/electionpricetest branch October 13, 2023 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants