mukan-sdk/x/group/keeper/tally_test.go
Mukan Erkin Törük abb1ff956e
Some checks are pending
Build SimApp / build (amd64) (push) Waiting to run
Build SimApp / build (arm64) (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Build & Push / build (push) Waiting to run
Run Gosec / Gosec (push) Waiting to run
Lint / golangci-lint (push) Waiting to run
Checks dependencies and mocks generation / Check go mod tidy (push) Waiting to run
Checks dependencies and mocks generation / Check up to date mocks (push) Waiting to run
System Tests / setup (push) Waiting to run
System Tests / test-system (push) Blocked by required conditions
System Tests / test-system-legacy (push) Blocked by required conditions
Tests / Code Coverage / split-test-files (push) Waiting to run
Tests / Code Coverage / tests (00) (push) Blocked by required conditions
Tests / Code Coverage / tests (01) (push) Blocked by required conditions
Tests / Code Coverage / tests (02) (push) Blocked by required conditions
Tests / Code Coverage / tests (03) (push) Blocked by required conditions
Tests / Code Coverage / test-integration (push) Waiting to run
Tests / Code Coverage / test-e2e (push) Waiting to run
Tests / Code Coverage / repo-analysis (push) Blocked by required conditions
Tests / Code Coverage / test-sim-nondeterminism (push) Waiting to run
Tests / Code Coverage / test-clientv2 (push) Waiting to run
Tests / Code Coverage / test-core (push) Waiting to run
Tests / Code Coverage / test-depinject (push) Waiting to run
Tests / Code Coverage / test-errors (push) Waiting to run
Tests / Code Coverage / test-math (push) Waiting to run
Tests / Code Coverage / test-schema (push) Waiting to run
Tests / Code Coverage / test-collections (push) Waiting to run
Tests / Code Coverage / test-cosmovisor (push) Waiting to run
Tests / Code Coverage / test-confix (push) Waiting to run
Tests / Code Coverage / test-store (push) Waiting to run
Tests / Code Coverage / test-log (push) Waiting to run
Tests / Code Coverage / test-x-tx (push) Waiting to run
Tests / Code Coverage / test-x-nft (push) Waiting to run
Tests / Code Coverage / test-x-circuit (push) Waiting to run
Tests / Code Coverage / test-x-feegrant (push) Waiting to run
Tests / Code Coverage / test-x-evidence (push) Waiting to run
Tests / Code Coverage / test-x-upgrade (push) Waiting to run
Tests / Code Coverage / test-tools-benchmark (push) Waiting to run
refactor: complete sovereign stack cleanup — all github.com upstream refs purged
2026-05-11 03:46:06 +03:00

87 lines
2.1 KiB
Go

package keeper_test
import (
"context"
"time"
sdk "git.cw.tr/mukan-network/mukan-sdk/types"
banktypes "git.cw.tr/mukan-network/mukan-sdk/x/bank/types"
"git.cw.tr/mukan-network/mukan-sdk/x/group"
)
func (s *TestSuite) TestTally() {
addrs := s.addrs
addr2 := addrs[1]
msgSend1 := &banktypes.MsgSend{
FromAddress: s.groupPolicyAddr.String(),
ToAddress: addr2.String(),
Amount: sdk.Coins{sdk.NewInt64Coin("test", 100)},
}
proposers := []string{addr2.String()}
specs := map[string]struct {
srcBlockTime time.Time
setupProposal func(ctx context.Context) uint64
expErr bool
expTallyResult group.TallyResult
}{
"invalid proposal id": {
setupProposal: func(ctx context.Context) uint64 {
return 123
},
expErr: true,
},
"proposal with no votes": {
setupProposal: func(ctx context.Context) uint64 {
msgs := []sdk.Msg{msgSend1}
return submitProposal(ctx, s, msgs, proposers)
},
expTallyResult: group.DefaultTallyResult(),
},
"withdrawn proposal": {
setupProposal: func(ctx context.Context) uint64 {
msgs := []sdk.Msg{msgSend1}
proposalID := submitProposal(ctx, s, msgs, proposers)
_, err := s.groupKeeper.WithdrawProposal(ctx, &group.MsgWithdrawProposal{
ProposalId: proposalID,
Address: proposers[0],
})
s.Require().NoError(err)
return proposalID
},
expErr: true,
},
"proposal with some votes": {
setupProposal: func(ctx context.Context) uint64 {
msgs := []sdk.Msg{msgSend1}
return submitProposalAndVote(ctx, s, msgs, proposers, group.VOTE_OPTION_YES)
},
expTallyResult: group.TallyResult{
YesCount: "2",
NoCount: "0",
NoWithVetoCount: "0",
AbstainCount: "0",
},
},
}
for msg, spec := range specs {
s.Run(msg, func() {
sdkCtx, _ := s.sdkCtx.CacheContext()
pID := spec.setupProposal(sdkCtx)
req := &group.QueryTallyResultRequest{
ProposalId: pID,
}
res, err := s.groupKeeper.TallyResult(sdkCtx, req)
if spec.expErr {
s.Require().Error(err)
} else {
s.Require().NoError(err)
s.Require().Equal(res.Tally, spec.expTallyResult)
}
})
}
}