Skip to content

Commit

Permalink
feat: privileged subdaos
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Zavgorodnii committed Feb 12, 2024
1 parent 2e85ee3 commit 1d91096
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 16 deletions.
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 @@ -156,14 +156,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 @@ -546,12 +550,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
2 changes: 1 addition & 1 deletion src/testcases/run_in_band/globalfee.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Neutron / Global Fee', () => {
neutronChain,
testState.wallets.qaNeutron.genQaWal1,
);
const daoCoreAddress = (await neutronChain.getChainAdmins())[0];
const daoCoreAddress = await neutronChain.getNeutronDAOCore();
const daoContracts = await getDaoContracts(neutronChain, daoCoreAddress);
daoMain = new Dao(neutronChain, daoContracts);
daoMember = new DaoMember(neutronAccount, daoMain);
Expand Down
4 changes: 2 additions & 2 deletions src/testcases/run_in_band/interchain_kv_query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const acceptInterchainqueriesParamsChangeProposal = async (
key: string,
value: string,
) => {
const daoCoreAddress = (await cm.chain.getChainAdmins())[0];
const daoCoreAddress = await cm.chain.getNeutronDAOCore();
const daoContracts = await getDaoContracts(cm.chain, daoCoreAddress);
const dao = new Dao(cm.chain, daoContracts);
const daoMember = new DaoMember(cm, dao);
Expand Down Expand Up @@ -265,7 +265,7 @@ describe('Neutron / Interchain KV Query', () => {
);
gaiaAccount = new WalletWrapper(gaiaChain, testState.wallets.cosmos.demo2);

const daoCoreAddress = (await neutronChain.getChainAdmins())[0];
const daoCoreAddress = await neutronChain.getNeutronDAOCore();
const daoContracts = await getDaoContracts(neutronChain, daoCoreAddress);
const dao = new Dao(neutronChain, daoContracts);
const daoMember = new DaoMember(neutronAccount, dao);
Expand Down
2 changes: 1 addition & 1 deletion src/testcases/run_in_band/parameters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Neutron / Parameters', () => {
neutronChain,
testState.wallets.qaNeutron.genQaWal1,
);
const daoCoreAddress = (await neutronChain.getChainAdmins())[0];
const daoCoreAddress = await neutronChain.getNeutronDAOCore();
const daoContracts = await getDaoContracts(neutronChain, daoCoreAddress);
dao = new Dao(neutronChain, daoContracts);
daoMember1 = new DaoMember(neutronAccount, dao);
Expand Down
4 changes: 2 additions & 2 deletions src/testcases/run_in_band/reserve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Neutron / Treasury', () => {
mainDaoAddr.toString(),
securityDaoAddr.toString(),
);
treasury = (await neutronChain.getChainAdmins())[0];
treasury = await neutronChain.getNeutronDAOCore();
});

describe('some corner cases', () => {
Expand Down Expand Up @@ -409,7 +409,7 @@ describe('Neutron / Treasury', () => {
mainDaoAddr.toString(),
securityDaoAddr.toString(),
);
treasury = (await neutronChain.getChainAdmins())[0];
treasury = await neutronChain.getNeutronDAOCore();
reserve = await setupReserve(neutronAccount1, {
mainDaoAddress: mainDaoAddr.toString(),
securityDaoAddress: securityDaoAddr.toString(),
Expand Down
2 changes: 1 addition & 1 deletion src/testcases/run_in_band/tge.auction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('Neutron / TGE / Auction', () => {

testState.wallets.qaNeutronFive.genQaWal1,
);
const daoCoreAddress = (await neutronChain.getChainAdmins())[0];
const daoCoreAddress = await neutronChain.getNeutronDAOCore();
const daoContracts = await getDaoContracts(neutronChain, daoCoreAddress);
daoMain = new Dao(neutronChain, daoContracts);
daoMember1 = new DaoMember(cmInstantiator, daoMain);
Expand Down

0 comments on commit 1d91096

Please sign in to comment.