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

feat!: expedited proposal min deposit param #254

Merged
merged 56 commits into from
Jun 20, 2022
Merged
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
5fd6d11
make proto-all
p0mvn May 19, 2022
ebc98bd
make proto-all with IsExpedited flag
p0mvn May 19, 2022
4498298
expedited_voting_period on voting params
p0mvn May 19, 2022
c964a0d
go mod tidy
p0mvn May 19, 2022
68d3724
add IsExpedited flag to all proposals
p0mvn May 19, 2022
e74b6ce
implement the foundation for expedited proposals
p0mvn May 20, 2022
de4f187
add validation for voting period params
p0mvn May 20, 2022
2be2b33
validate tally params - expedited must be greater than or equal to re…
p0mvn May 20, 2022
de6d0d4
fix cli
p0mvn May 20, 2022
14ac4ee
fix problems with querying tally params
p0mvn May 20, 2022
c9f61a4
TestProposalPassedEndblocker for expedited
p0mvn May 20, 2022
6f6d34d
update TestCmdParams
p0mvn May 20, 2022
2e2f96d
fix TestMigrate v040
p0mvn May 20, 2022
c46a1e6
fix TestGRPCQueryProposal
p0mvn May 20, 2022
39344ce
fix v043 TestMigrateJSON
p0mvn May 20, 2022
fe53f96
fix TestRandomizedGenState
p0mvn May 20, 2022
ddfda7c
fix TestSimulateMsgSubmitProposal
p0mvn May 20, 2022
83bad19
TestExpeditedToRegularConversion
p0mvn May 20, 2022
3f949da
fix TestIntegrationTestSuite/TestCmdParams/text_output
p0mvn May 20, 2022
45eb715
test TestExpeditedProposal_PassAndConversionToRegular
p0mvn May 20, 2022
324fb3e
attempt to fix TestAppStateDeterminism
p0mvn May 20, 2022
b90072a
fix TestRandomizedGenState after changing rand generation bounds
p0mvn May 20, 2022
ead97d0
fix TestParamChanges
p0mvn May 20, 2022
13a09c5
Merge branch 'osmosis-main' into roman/emergency-voting
p0mvn May 20, 2022
63272d2
Update x/gov/abci.go
p0mvn May 20, 2022
5f53f22
Update x/gov/abci.go
p0mvn May 20, 2022
83cb447
Update x/gov/types/keys.go
p0mvn May 20, 2022
15fab45
refactor to have isExpedited flag on the proposal struct
p0mvn Jun 2, 2022
5a348e8
fix tests
p0mvn Jun 2, 2022
11cad5f
Merge branch 'osmosis-main' into roman/emergency-voting
p0mvn Jun 2, 2022
9fab856
clean up proto files and remove is_expedited from CommunityPoolSpendP…
p0mvn Jun 2, 2022
91fbb54
fix migrate tests
p0mvn Jun 2, 2022
47d3cae
fix proto
p0mvn Jun 3, 2022
9ffefd0
Update x/gov/abci.go
p0mvn Jun 3, 2022
6896268
Update proto/cosmos/gov/v1beta1/gov.proto
p0mvn Jun 3, 2022
3cc294a
expedited vote threshold must be strictly greater than regular
p0mvn Jun 3, 2022
69d7f3b
fix Cmd tests
p0mvn Jun 3, 2022
7c12628
fix another cmd test
p0mvn Jun 3, 2022
68528ce
Add spec for emergency voting (#249)
mattverse Jun 5, 2022
1430846
Update x/gov/types/keys.go
p0mvn Jun 6, 2022
a7d05e0
remove redundant isExpedited flag from ContentFromProposalType
p0mvn Jun 6, 2022
3d13fa5
Update x/gov/abci.go
p0mvn Jun 6, 2022
3bccb4d
Merge branch 'osmosis-main' into roman/emergency-voting
p0mvn Jun 7, 2022
001433f
feat: expedited proposal min deposit param
p0mvn Jun 7, 2022
f59e04d
fix TestMigrateJSON
p0mvn Jun 7, 2022
e35dabb
improve TestProposalHandler to test validation of invalid min expedit…
p0mvn Jun 7, 2022
96bc750
fix abci tests
p0mvn Jun 7, 2022
781138d
fix migrate_test.go
p0mvn Jun 7, 2022
b8fdc1a
fix more cli tests
p0mvn Jun 7, 2022
55e3810
fix TestRandomizedGenState
p0mvn Jun 8, 2022
8c5646c
Merge branch 'osmosis-main' into roman/expedited-deposit
p0mvn Jun 17, 2022
b1ae23d
fix merge issue
p0mvn Jun 17, 2022
4fecadb
Update x/gov/types/proposal.go
p0mvn Jun 17, 2022
6fe17ac
Merge branch 'osmosis-main' into roman/expedited-deposit
p0mvn Jun 17, 2022
a409a00
Merge branch 'osmosis-main' into roman/expedited-deposit
p0mvn Jun 17, 2022
6e9e75b
Update x/gov/abci_test.go
p0mvn Jun 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test TestExpeditedProposal_PassAndConversionToRegular
  • Loading branch information
p0mvn committed May 20, 2022
commit 45eb715830c05d34ce7b0922fd87bda82f9e643f
65 changes: 53 additions & 12 deletions x/gov/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,26 @@ func TestProposalPassedEndblocker(t *testing.T) {
}
}

func TestExpeditedToRegularConversion(t *testing.T) {
func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) {
testcases := []struct {
name string
// flag indicating whether the expedited proposal passes.
isExpeditedPasses bool
// flag indicating whether the converted regular proposal is expected to eventually pass
isRegularEventuallyPassing bool
}{
{
name: "expedited to regular - regular eventually passes",
name: "expedited passes and not converted to regular",
isExpeditedPasses: true,
},
{
name: "expedited fails, converted to regular - regular eventually passes",
isExpeditedPasses: false,
isRegularEventuallyPassing: true,
},
{
name: "expedited to regular - regular eventually fails",
name: "expedited fails, converted to regular - regular eventually fails",
isExpeditedPasses: false,
isRegularEventuallyPassing: false,
},
}
Expand Down Expand Up @@ -480,10 +488,38 @@ func TestExpeditedToRegularConversion(t *testing.T) {

activeQueue.Close()

if tc.isExpeditedPasses {
// Validator votes YES, letting the expedited proposal pass.
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
require.NoError(t, err)
}

// Here the expedited proposal is converted to regular after expiry.
gov.EndBlocker(ctx, app.GovKeeper)

activeQueue = app.GovKeeper.ActiveProposalQueueIterator(ctx, ctx.BlockHeader().Time)

if tc.isExpeditedPasses {
require.False(t, activeQueue.Valid())

proposal, ok = app.GovKeeper.GetProposal(ctx, activeProposalID)
require.True(t, ok)

require.Equal(t, types.StatusPassed, proposal.Status)

submitterEventualBalance := app.BankKeeper.GetAllBalances(ctx, addrs[0])
depositorEventualBalance := app.BankKeeper.GetAllBalances(ctx, addrs[1])

eventualModuleAccCoins := app.BankKeeper.GetAllBalances(ctx, macc.GetAddress())

// Module account has refunded the deposit
require.Equal(t, initialModuleAccCoins, eventualModuleAccCoins)

require.Equal(t, submitterInitialBalance, submitterEventualBalance)
require.Equal(t, depositorInitialBalance, depositorEventualBalance)
return
}

// Expedited proposal should be converted to a regular proposal instead.
require.True(t, activeQueue.Valid())

Expand Down Expand Up @@ -518,6 +554,7 @@ func TestExpeditedToRegularConversion(t *testing.T) {
require.True(t, activeQueue.Valid())

if tc.isRegularEventuallyPassing {
// Validator votes YES, letting the converted regular proposal pass.
err = app.GovKeeper.AddVote(ctx, proposal.ProposalId, addrs[0], types.NewNonSplitVoteOption(types.OptionYes))
require.NoError(t, err)
}
Expand All @@ -532,24 +569,28 @@ func TestExpeditedToRegularConversion(t *testing.T) {
submitterEventualBalance := app.BankKeeper.GetAllBalances(ctx, addrs[0])
depositorEventualBalance := app.BankKeeper.GetAllBalances(ctx, addrs[1])

// Module account has refunded the deposit
require.Equal(t, initialModuleAccCoins, eventualModuleAccCoins)

require.Equal(t, submitterInitialBalance, submitterEventualBalance)
require.Equal(t, depositorInitialBalance, depositorEventualBalance)

activeQueue = app.GovKeeper.ActiveProposalQueueIterator(ctx, ctx.BlockHeader().Time)
require.False(t, activeQueue.Valid())

proposal, ok = app.GovKeeper.GetProposal(ctx, activeProposalID)
require.True(t, ok)

if !tc.isRegularEventuallyPassing {
require.Equal(t, types.StatusRejected, proposal.Status)
if tc.isRegularEventuallyPassing {
// Module account has refunded the deposit
require.Equal(t, initialModuleAccCoins, eventualModuleAccCoins)
require.Equal(t, submitterInitialBalance, submitterEventualBalance)
require.Equal(t, depositorInitialBalance, depositorEventualBalance)

require.Equal(t, types.StatusPassed, proposal.Status)
return
}

require.Equal(t, types.StatusPassed, proposal.Status)
// Not enough votes - module account has burned the deposit
require.Equal(t, initialModuleAccCoins, eventualModuleAccCoins)
require.Equal(t, submitterInitialBalance.Sub(proposalCoins), submitterEventualBalance)
require.Equal(t, depositorInitialBalance.Sub(proposalCoins), depositorEventualBalance)

require.Equal(t, types.StatusRejected, proposal.Status)
})
}
}
Expand Down