From e49a4236dc24401263fa7e881c062838c00801d3 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Thu, 4 May 2023 19:59:48 +0400 Subject: [PATCH 1/2] add ugly rescueeer address check --- package.json | 3 ++- src/helpers/dao.ts | 7 +++++++ src/testcases/parallel/dao_assert.test.ts | 24 +++++++++++++---------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 07916b6b..c4bf9bd8 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "test": "yarn test:parallel && yarn test:run_in_band", "test:parallel": "jest -b src/testcases/parallel", + "test:dao_assert": "jest -b src/testcases/parallel/dao_assert", "test:run_in_band": "yarn test:tge:auction && yarn test:tge:airdrop && yarn test:tge:credits && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:subdao && yarn test:reserve && yarn test:overrule && yarn test:ibc_hooks", "test:simple": "jest -b src/testcases/parallel/simple", "test:interchaintx": "jest -b src/testcases/run_in_band/interchaintx", @@ -83,4 +84,4 @@ "engines": { "node": ">=11.0 <17" } -} \ No newline at end of file +} diff --git a/src/helpers/dao.ts b/src/helpers/dao.ts index a2a41aad..9ab44407 100644 --- a/src/helpers/dao.ts +++ b/src/helpers/dao.ts @@ -268,6 +268,13 @@ export const getDaoContracts = async ( }; }; +export const getDaoAdmin = async ( + cm: CosmosWrapper, + daoAddress: string, +): Promise => { + const daoInfo = await cm.getContractInfo(daoAddress); + return daoInfo['contract_info']['admin']; +} export const getSubDaoContracts = async ( cm: CosmosWrapper, daoAddress: string, diff --git a/src/testcases/parallel/dao_assert.test.ts b/src/testcases/parallel/dao_assert.test.ts index 4d662fc9..753b86dd 100644 --- a/src/testcases/parallel/dao_assert.test.ts +++ b/src/testcases/parallel/dao_assert.test.ts @@ -5,6 +5,7 @@ import { DaoContracts, VotingVaultsModule, getTreasuryContract, + getDaoAdmin, } from '../../helpers/dao'; import { getContractsHashes } from '../../helpers/env'; import { NeutronContract } from '../../helpers/types'; @@ -22,6 +23,7 @@ describe('DAO / Check', () => { let votingModuleAddress: string; let votingVaultsNtrnAddress: string; let treasuryContract: string; + let rescueeerAddress: string; beforeAll(async () => { testState = new TestStateLocalCosmosTestNet(); @@ -47,6 +49,8 @@ describe('DAO / Check', () => { votingVaultsNtrnAddress = (daoContracts.voting as VotingVaultsModule).vaults .neutron.address; treasuryContract = await getTreasuryContract(neutronChain); + // since we consider rescueeer as a dao admin, we simply get its address w this ugly way + rescueeerAddress = await getDaoAdmin(neutronChain, daoCoreAddress); }); describe('Checking the association of proposal & preproposal modules with the Dao', () => { @@ -140,16 +144,16 @@ describe('DAO / Check', () => { await verifyAdmin( neutronChain, votingVaultsNtrnAddress, - daoContracts.core.address, + rescueeerAddress, ); await verifyLabel(neutronChain, daoContracts, votingVaultsNtrnAddress); }); - test('Dao is the admin of himself', async () => { + test('Dao is not the admin of himself, should be rescueeer', async () => { await verifyAdmin( neutronChain, daoContracts.core.address, - daoContracts.core.address, + rescueeerAddress, ); await verifyLabel(neutronChain, daoContracts, daoContracts.core.address); }); @@ -231,17 +235,17 @@ describe('DAO / Check', () => { describe('Test subdaos', () => { test('Check subdaos contracts admins and labels', async () => { for (const subdaoIndex in daoContracts.subdaos) { - const sudao = daoContracts.subdaos[subdaoIndex]; + const subdao = daoContracts.subdaos[subdaoIndex]; + await verifyAdmin(neutronChain, subdao.core.address, rescueeerAddress); const contractsList = [ - sudao.core.address, - sudao.proposals.single.address, - sudao.proposals.single.pre_propose.address, - sudao.voting.address, + subdao.proposals.single.address, + subdao.proposals.single.pre_propose.address, + subdao.voting.address, // (sudao.voting as VotingCw4Module).cw4group.address, // todo fix this ]; - if (sudao.proposals.single.pre_propose.timelock.address) { + if (subdao.proposals.single.pre_propose.timelock.address) { contractsList.push( - sudao.proposals.single.pre_propose.timelock.address, + subdao.proposals.single.pre_propose.timelock.address, ); } for (const contractAddress of contractsList) { From 6a99ad5fec8160ba10151c58aad3cf45cc2e60b7 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Thu, 4 May 2023 20:24:03 +0400 Subject: [PATCH 2/2] lint --- src/helpers/dao.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/helpers/dao.ts b/src/helpers/dao.ts index 9ab44407..04c27d0a 100644 --- a/src/helpers/dao.ts +++ b/src/helpers/dao.ts @@ -273,8 +273,9 @@ export const getDaoAdmin = async ( daoAddress: string, ): Promise => { const daoInfo = await cm.getContractInfo(daoAddress); - return daoInfo['contract_info']['admin']; -} + return daoInfo['contract_info']['admin']; +}; + export const getSubDaoContracts = async ( cm: CosmosWrapper, daoAddress: string,