Skip to content

Commit 422d805

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/slinky
2 parents 225ac02 + f57f9bc commit 422d805

File tree

4 files changed

+447
-5
lines changed

4 files changed

+447
-5
lines changed

src/helpers/gaia.ts

+59
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@ import {
33
MsgDelegate,
44
MsgUndelegate,
55
} from '@neutron-org/neutronjsplus/dist/proto/cosmos_sdk/cosmos/staking/v1beta1/tx_pb';
6+
import {
7+
MsgSubmitProposal,
8+
MsgVote,
9+
} from '@neutron-org/neutronjsplus/dist/proto/cosmos_sdk/cosmos/gov/v1beta1/tx_pb';
610
import {
711
packAnyMsg,
812
WalletWrapper,
913
} from '@neutron-org/neutronjsplus/dist/cosmos';
1014
import Long from 'long';
15+
import {
16+
TextProposal,
17+
VoteOption,
18+
} from '@neutron-org/neutronjsplus/dist/proto/cosmos_sdk/cosmos/gov/v1beta1/gov_pb';
1119

1220
export const msgDelegate = async (
1321
wallet: WalletWrapper,
@@ -48,5 +56,56 @@ export const msgUndelegate = async (
4856
},
4957
[packAnyMsg('/cosmos.staking.v1beta1.MsgUndelegate', msgUndelegate)],
5058
);
59+
60+
return res?.tx_response;
61+
};
62+
63+
export const msgSubmitProposal = async (
64+
wallet: WalletWrapper,
65+
proposer: string,
66+
amount = '0',
67+
): Promise<BroadcastTx200ResponseTxResponse> => {
68+
const msgSubmitProposal = new MsgSubmitProposal({
69+
proposer,
70+
content: {
71+
typeUrl: '/cosmos.gov.v1beta1.TextProposal',
72+
value: new TextProposal({
73+
title: 'mock',
74+
description: 'mock',
75+
}).toBinary(),
76+
},
77+
initialDeposit: [{ denom: wallet.chain.denom, amount: '10000000' }],
78+
});
79+
const res = await wallet.execTx(
80+
{
81+
gas_limit: Long.fromString('500000'),
82+
amount: [{ denom: wallet.chain.denom, amount: amount }],
83+
},
84+
[packAnyMsg('/cosmos.gov.v1beta1.MsgSubmitProposal', msgSubmitProposal)],
85+
);
86+
87+
return res?.tx_response;
88+
};
89+
90+
export const msgVote = async (
91+
wallet: WalletWrapper,
92+
voter: string,
93+
proposalId: number,
94+
amount = '0',
95+
): Promise<BroadcastTx200ResponseTxResponse> => {
96+
const msgVote = new MsgVote({
97+
voter,
98+
proposalId: BigInt(proposalId),
99+
option: VoteOption.YES,
100+
});
101+
102+
const res = await wallet.execTx(
103+
{
104+
gas_limit: Long.fromString('500000'),
105+
amount: [{ denom: wallet.chain.denom, amount: amount }],
106+
},
107+
[packAnyMsg('/cosmos.gov.v1beta1.MsgVote', msgVote)],
108+
);
109+
51110
return res?.tx_response;
52111
};

src/testcases/parallel/overrule.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616

1717
const config = require('../../config.json');
1818

19-
describe('Neutron / Subdao', () => {
19+
describe('Neutron / Subdao Overrule', () => {
2020
let testState: TestStateLocalCosmosTestNet;
2121
let neutronChain: CosmosWrapper;
2222
let neutronAccount1: WalletWrapper;

src/testcases/parallel/subdao.test.ts

+88-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ import {
1818
TimelockConfig,
1919
TimelockProposalListResponse,
2020
} from '@neutron-org/neutronjsplus/dist/dao';
21-
import { Wallet } from '@neutron-org/neutronjsplus/dist/types';
21+
import {
22+
SingleChoiceProposal,
23+
Wallet,
24+
} from '@neutron-org/neutronjsplus/dist/types';
2225
import { BroadcastTx200ResponseTxResponse } from '@cosmos-client/core/cjs/openapi/api';
2326
import cosmosclient from '@cosmos-client/core';
24-
import { waitSeconds } from '@neutron-org/neutronjsplus/dist/wait';
27+
import {
28+
getWithAttempts,
29+
waitSeconds,
30+
} from '@neutron-org/neutronjsplus/dist/wait';
2531
import {
2632
paramChangeProposal,
2733
sendProposal,
@@ -480,6 +486,86 @@ describe('Neutron / Subdao', () => {
480486
});
481487
});
482488

489+
describe('Timelock3: Closed overruled proposal should not prevent execution', () => {
490+
let proposalId: number;
491+
beforeAll(async () => {
492+
proposalId = await subdaoMember1.submitUpdateSubDaoConfigProposal(
493+
{
494+
name: 'dao name after timelock3',
495+
},
496+
'single2',
497+
);
498+
499+
// move proposal to the timelocked state where it can be overruled
500+
const timelockedProp = await subdaoMember1.supportAndExecuteProposal(
501+
proposalId,
502+
'single2',
503+
);
504+
505+
expect(timelockedProp.id).toEqual(proposalId);
506+
expect(timelockedProp.status).toEqual('timelocked');
507+
expect(timelockedProp.msgs).toHaveLength(1);
508+
});
509+
510+
test('close rejected overrule proposal', async () => {
511+
const overruleProposalId = await mainDao.getOverruleProposalId(
512+
subDao.contracts.proposals.single2.pre_propose.timelock!.address,
513+
proposalId,
514+
);
515+
516+
// wait 20 seconds
517+
await waitSeconds(20);
518+
519+
const propOverruledTest =
520+
await mainDao.chain.queryContract<SingleChoiceProposal>(
521+
mainDaoMember.dao.contracts.proposals.overrule?.address,
522+
{
523+
proposal: {
524+
proposal_id: overruleProposalId,
525+
},
526+
},
527+
);
528+
expect(propOverruledTest.proposal.status).toEqual('rejected');
529+
530+
await subdaoMember1.user.executeContract(
531+
mainDaoMember.dao.contracts.proposals.overrule.address,
532+
JSON.stringify({
533+
close: { proposal_id: overruleProposalId },
534+
}),
535+
);
536+
537+
const propOverruledTest2 = await getWithAttempts(
538+
neutronChain.blockWaiter,
539+
async () =>
540+
await mainDao.chain.queryContractWithWait<SingleChoiceProposal>(
541+
mainDaoMember.dao.contracts.proposals.overrule?.address,
542+
{
543+
proposal: {
544+
proposal_id: overruleProposalId,
545+
},
546+
},
547+
),
548+
async (p) => p.proposal.status === 'closed',
549+
5,
550+
);
551+
552+
expect(propOverruledTest2.proposal.status).toEqual('closed');
553+
});
554+
555+
test('execute timelocked: success', async () => {
556+
await waitSeconds(20);
557+
await subdaoMember1.executeTimelockedProposal(proposalId, 'single2');
558+
559+
const timelockedProp = await subDao.getTimelockedProposal(
560+
proposalId,
561+
'single2',
562+
);
563+
expect(timelockedProp.id).toEqual(proposalId);
564+
expect(timelockedProp.status).toEqual('executed');
565+
expect(timelockedProp.msgs).toHaveLength(1);
566+
});
567+
});
568+
483569
describe('Non-timelock typed duration pause proposal: Succeed creation', () => {
484570
let proposalId: number;
485571

0 commit comments

Comments
 (0)