feat(x/gov): optimistic proposals (#18620)

Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com>
This commit is contained in:
Julien Robert
2023-12-20 21:49:03 +00:00
committed by GitHub
co-authored by Facundo Medica
parent 4753d16ef4
commit eb3ea8db8a
25 changed files with 1594 additions and 589 deletions
@@ -22,9 +22,8 @@ func TestLegacyGRPCQueryTally(t *testing.T) {
addrs, _ := createValidators(t, f, []int64{5, 5, 5})
var (
req *v1beta1.QueryTallyResultRequest
expRes *v1beta1.QueryTallyResultResponse
proposal v1.Proposal
req *v1beta1.QueryTallyResultRequest
expRes *v1beta1.QueryTallyResultResponse
)
testCases := []struct {
@@ -33,29 +32,13 @@ func TestLegacyGRPCQueryTally(t *testing.T) {
expPass bool
expErrMsg string
}{
{
"create a proposal and get tally",
func() {
var err error
proposal, err = f.govKeeper.SubmitProposal(ctx, TestProposal, "", "test", "description", addrs[0], v1.ProposalType_PROPOSAL_TYPE_STANDARD)
assert.NilError(t, err)
assert.Assert(t, proposal.String() != "")
req = &v1beta1.QueryTallyResultRequest{ProposalId: proposal.Id}
tallyResult := v1beta1.EmptyTallyResult()
expRes = &v1beta1.QueryTallyResultResponse{
Tally: tallyResult,
}
},
true,
"",
},
{
"request tally after few votes",
func() {
proposal, err := f.govKeeper.SubmitProposal(ctx, TestProposal, "", "test", "description", addrs[0], v1.ProposalType_PROPOSAL_TYPE_STANDARD)
assert.NilError(t, err)
proposal.Status = v1.StatusVotingPeriod
err := f.govKeeper.SetProposal(ctx, proposal)
err = f.govKeeper.SetProposal(ctx, proposal)
assert.NilError(t, err)
assert.NilError(t, f.govKeeper.AddVote(ctx, proposal.Id, addrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), ""))
assert.NilError(t, f.govKeeper.AddVote(ctx, proposal.Id, addrs[1], v1.NewNonSplitVoteOption(v1.OptionYes), ""))