Skip to content

Commit

Permalink
Merge pull request #266 from neutron-org/feat/privileged-subdaos
Browse files Browse the repository at this point in the history
feat: privileged subdaos #NTRN-211
  • Loading branch information
pr0n00gler authored May 13, 2024
2 parents e1112a7 + 1a5e767 commit 4c5f30b
Show file tree
Hide file tree
Showing 12 changed files with 621 additions and 308 deletions.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:globalfee": "jest -b src/testcases/run_in_band/globalfee",
"test:ibc_hooks": "jest -b src/testcases/run_in_band/ibc_hooks",
"test:parameters": "jest -b src/testcases/run_in_band/parameters",
"test:chain_manager": "jest -b src/testcases/run_in_band/chain_manager",
"test:tokenfactory": "jest -b src/testcases/parallel/tokenfactory",
"test:overrule": "jest -b src/testcases/parallel/overrule",
"test:tge:vesting_lp_vault": "jest -b src/testcases/parallel/tge.vesting_lp_vault",
Expand All @@ -46,7 +47,7 @@
"@cosmos-client/core": "^0.47.4",
"@cosmos-client/cosmwasm": "^0.40.3",
"@cosmos-client/ibc": "^1.2.1",
"@neutron-org/neutronjsplus": "0.4.0",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#35a66ac1e24b1224a57f335eddf7ba250f784a13",
"@types/lodash": "^4.14.182",
"@types/long": "^5.0.0",
"axios": "^0.27.2",
Expand Down Expand Up @@ -85,11 +86,9 @@
"eslint --max-warnings=0",
"jest --bail --findRelatedTests"
],
"./**/*.{ts,tsx,js,jsx,md,json}": [
"prettier --write"
]
"./**/*.{ts,tsx,js,jsx,md,json}": ["prettier --write"]
},
"engines": {
"node": ">=16.0 <17"
}
}
}
2 changes: 1 addition & 1 deletion src/testcases/parallel/dao_assert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('DAO / Check', () => {
testState.blockWaiter1,
NEUTRON_DENOM,
);
const daoCoreAddress = (await neutronChain.getChainAdmins())[0]; //add assert for some addresses
const daoCoreAddress = await neutronChain.getNeutronDAOCore(); //add assert for some addresses
daoContracts = await getDaoContracts(neutronChain, daoCoreAddress);
proposalSingleAddress = daoContracts.proposals.single.address;
preProposalSingleAddress =
Expand Down
42 changes: 41 additions & 1 deletion src/testcases/parallel/governance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Neutron / Governance', () => {
neutronChain,
testState.wallets.qaNeutron.genQaWal1,
);
const daoCoreAddress = (await neutronChain.getChainAdmins())[0];
const daoCoreAddress = await neutronChain.getNeutronDAOCore();
const daoContracts = await getDaoContracts(neutronChain, daoCoreAddress);
mainDao = new Dao(neutronChain, daoContracts);
daoMember1 = new DaoMember(neutronAccount, mainDao);
Expand Down Expand Up @@ -151,7 +151,9 @@ describe('Neutron / Governance', () => {

describe('create several proposals', () => {
test('create proposal #1, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitParameterChangeProposal(
chainManagerAddress,
'Proposal #1',
'Param change proposal. This one will pass',
'icahost',
Expand All @@ -162,7 +164,9 @@ describe('Neutron / Governance', () => {
});

test('create proposal #2, will be rejected', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitParameterChangeProposal(
chainManagerAddress,
'Proposal #2',
'Param change proposal. This one will not pass',
'icahost',
Expand All @@ -188,7 +192,9 @@ describe('Neutron / Governance', () => {
});

test('create proposal #4, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitSoftwareUpgradeProposal(
chainManagerAddress,
'Proposal #4',
'Software upgrade proposal. Will pass',
'Plan #1',
Expand All @@ -199,15 +205,19 @@ describe('Neutron / Governance', () => {
});

test('create proposal #5, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitCancelSoftwareUpgradeProposal(
chainManagerAddress,
'Proposal #5',
'Software upgrade proposal. Will pass',
'1000',
);
});

test('create proposal #6, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitClientUpdateProposal(
chainManagerAddress,
'Proposal #6',
'UpdateClient proposal. Will pass',
'07-tendermint-2',
Expand All @@ -217,7 +227,9 @@ describe('Neutron / Governance', () => {
});

test('create proposal #7, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitPinCodesProposal(
chainManagerAddress,
'Proposal #7',
'Pin codes proposal. Will pass',
[1, 2],
Expand All @@ -226,7 +238,9 @@ describe('Neutron / Governance', () => {
});

test('create proposal #8, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitUnpinCodesProposal(
chainManagerAddress,
'Proposal #8',
'Unpin codes proposal. Will pass',
[1, 2],
Expand All @@ -235,7 +249,9 @@ describe('Neutron / Governance', () => {
});

test('create proposal #9, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitUpdateAdminProposal(
chainManagerAddress,
'Proposal #9',
'Update admin proposal. Will pass',
ADMIN_MODULE_ADDRESS,
Expand All @@ -246,7 +262,9 @@ describe('Neutron / Governance', () => {
});

test('create proposal #10, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitClearAdminProposal(
chainManagerAddress,
'Proposal #10',
'Clear admin proposal. Will pass',
ADMIN_MODULE_ADDRESS,
Expand All @@ -257,7 +275,9 @@ describe('Neutron / Governance', () => {

// add schedule with valid message format
test('create proposal #11, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitAddSchedule(
chainManagerAddress,
'Proposal #11',
'',
'1000',
Expand All @@ -274,7 +294,9 @@ describe('Neutron / Governance', () => {

// remove schedule
test('create proposal #12, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitRemoveSchedule(
chainManagerAddress,
'Proposal #12',
'',
'1000',
Expand All @@ -284,7 +306,9 @@ describe('Neutron / Governance', () => {

// add schedule with 3 messages, first returns error, second in incorrect format, third is valid
test('create proposal #13, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitAddSchedule(
chainManagerAddress,
'Proposal #13',
'',
'1000',
Expand All @@ -309,7 +333,9 @@ describe('Neutron / Governance', () => {

// add schedule with 3 messages, first is valid, second returns error
test('create proposal #14, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitAddSchedule(
chainManagerAddress,
'Proposal #14',
'',
'1000',
Expand All @@ -332,7 +358,9 @@ describe('Neutron / Governance', () => {
for (let i = 0; i < 40; i++)
await neutronAccount.storeWasm(NeutronContract.RESERVE);
const codeids = Array.from({ length: 40 }, (_, i) => i + 1);
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitPinCodesProposal(
chainManagerAddress,
'Proposal #15',
'Pin codes proposal. Will pass',
codeids,
Expand All @@ -341,7 +369,9 @@ describe('Neutron / Governance', () => {
});

test('create proposal #16, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitParameterChangeProposal(
chainManagerAddress,
'Proposal #16',
'Param change proposal. This one will not pass',
'icahost',
Expand All @@ -363,7 +393,9 @@ describe('Neutron / Governance', () => {
});

test('create proposal #18, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitPinCodesCustomAuthorityProposal(
chainManagerAddress,
'Proposal #18',
'Pin codes proposal with wrong authority. This one will pass & fail on execution',
[1, 2],
Expand All @@ -373,15 +405,19 @@ describe('Neutron / Governance', () => {
});

test('create proposal #19, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitBankSendProposal(
chainManagerAddress,
'Proposal #19',
'Submit bank send proposal. This one will pass & fail on execution due type is not whitelisted',
'1000',
);
});

test('create multi-choice proposal #1, will be picked choice 1', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitMultiChoiceParameterChangeProposal(
chainManagerAddress,
[
{
title: 'title',
Expand All @@ -405,7 +441,9 @@ describe('Neutron / Governance', () => {
});

test('create proposal #20, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitUpdateParamsInterchaintxsProposal(
chainManagerAddress,
'Proposal #20',
'Update interchaintxs params',
updateInterchaintxsParamsProposal({
Expand All @@ -416,7 +454,9 @@ describe('Neutron / Governance', () => {
});

test('create multi-choice proposal #2, will be rejected', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitMultiChoiceParameterChangeProposal(
chainManagerAddress,
[
{
title: 'title',
Expand Down
21 changes: 14 additions & 7 deletions src/testcases/parallel/subdao.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,18 @@ describe('Neutron / Subdao', () => {

let proposalId2: number;
test('proposal timelock 2 with two messages, one of them fails', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
// pack two messages in one proposal
const failMessage = paramChangeProposal({
title: 'paramchange',
description: 'paramchange',
subspace: 'icahost',
key: 'HostEnabled',
value: '123123123', // expected boolean, provided number
});
const failMessage = paramChangeProposal(
{
title: 'paramchange',
description: 'paramchange',
subspace: 'icahost',
key: 'HostEnabled',
value: '123123123', // expected boolean, provided number
},
chainManagerAddress,
);
const goodMessage = sendProposal({
to: neutronAccount2.wallet.address.toString(),
denom: NEUTRON_DENOM,
Expand Down Expand Up @@ -632,12 +636,15 @@ describe('Neutron / Subdao', () => {
let proposalId: number;

test('Non-timelock schedule proposal: Succeed creation', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
proposalId = await subdaoMember1.submitRemoveSchedule(
chainManagerAddress,
'Proposal #12',
'',
'1000',
'proposal11',
'single_nt_pause',
false,
);
await subdaoMember1.voteYes(proposalId, 'single_nt_pause');

Expand Down
Loading

0 comments on commit 4c5f30b

Please sign in to comment.