Skip to content

Commit

Permalink
Merge pull request #314 from neutron-org/feat/whitelist-tf-hooks
Browse files Browse the repository at this point in the history
feat: whitelist tf hooks
  • Loading branch information
pr0n00gler authored Jul 4, 2024
2 parents 601f061 + 8e7c707 commit 43b9d50
Show file tree
Hide file tree
Showing 5 changed files with 1,053 additions and 786 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"test": "yarn test:parallel && yarn test:run_in_band",
"test:parallel": "jest -b src/testcases/parallel",
"test:run_in_band": "yarn test:tge:auction && yarn test:tge:credits && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:dex_stargate && yarn test:dex_bindings && yarn test:slinky && yarn test:chain_manager && yarn test:feemarket && yarn test:globalfee",
"test:run_in_band": "yarn test:tge:auction && yarn test:tge:credits && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:dex_stargate && yarn test:dex_bindings && yarn test:slinky && yarn test:chain_manager && yarn test:feemarket && yarn test:globalfee && yarn test:tokenfactory",
"test:simple": "jest -b src/testcases/parallel/simple",
"test:slinky": "jest -b src/testcases/run_in_band/slinky",
"test:stargate_queries": "jest -b src/testcases/parallel/stargate_queries",
Expand All @@ -24,7 +24,7 @@
"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:tokenfactory": "jest -b src/testcases/run_in_band/tokenfactory",
"test:overrule": "jest -b src/testcases/parallel/overrule",
"test:tge:vesting_lp_vault": "jest -b src/testcases/parallel/tge.vesting_lp_vault",
"test:tge:credits_vault": "jest -b src/testcases/parallel/tge.credits_vault",
Expand All @@ -47,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.1",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#40c2c30434e63ab989e42408a94034589d5985d8",
"@types/lodash": "^4.14.182",
"@types/long": "^5.0.0",
"axios": "^0.27.2",
Expand Down Expand Up @@ -93,4 +93,4 @@
"engines": {
"node": ">=16.0 <17"
}
}
}
83 changes: 76 additions & 7 deletions src/testcases/run_in_band/chain_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import {
import { Wallet } from '@neutron-org/neutronjsplus/dist/types';
import cosmosclient from '@cosmos-client/core';
import { waitSeconds } from '@neutron-org/neutronjsplus/dist/wait';
import { updateCronParamsProposal } from '@neutron-org/neutronjsplus/dist/proposal';
import {
updateCronParamsProposal,
updateTokenfactoryParamsProposal,
} from '@neutron-org/neutronjsplus/dist/proposal';

import config from '../../config.json';

Expand Down Expand Up @@ -128,7 +131,7 @@ describe('Neutron / Chain Manager', () => {
});
});

describe('Add an ALLOW_ONLY strategy (Cron module parameter updates, legacy param changes)', () => {
describe('Add an ALLOW_ONLY strategy (Cron module parameter updates, Tokenfactory module parameter updates, legacy param changes)', () => {
let proposalId: number;
test('create proposal', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
Expand All @@ -152,11 +155,17 @@ describe('Neutron / Chain Manager', () => {
},
},
{
update_params_permission: {
cron_update_params_permission: {
security_address: true,
limit: true,
},
update_cron_params_permission: {
security_address: true,
limit: true,
},
},
{
update_tokenfactory_params_permission: {
denom_creation_fee: true,
denom_creation_gas_consume: true,
fee_collector_address: true,
whitelisted_hooks: true,
},
},
],
Expand Down Expand Up @@ -219,4 +228,64 @@ describe('Neutron / Chain Manager', () => {
expect(cronParams.params.limit).toEqual('42');
});
});

describe('ALLOW_ONLY: change TOKENFACTORY parameters', () => {
let proposalId: number;
beforeAll(async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
proposalId = await subdaoMember1.submitUpdateParamsTokenfactoryProposal(
chainManagerAddress,
'Proposal #2',
'Cron update params proposal. Will pass',
updateTokenfactoryParamsProposal({
denom_creation_fee: [{ denom: 'untrn', amount: '1' }],
denom_creation_gas_consume: 20,
fee_collector_address:
'neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2',
whitelisted_hooks: [
{
code_id: 1,
denom_creator: 'neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2',
},
],
}),
'1000',
);

const timelockedProp = await subdaoMember1.supportAndExecuteProposal(
proposalId,
);

expect(timelockedProp.id).toEqual(proposalId);
expect(timelockedProp.status).toEqual('timelocked');
expect(timelockedProp.msgs).toHaveLength(1);
});

test('execute timelocked: success', async () => {
await waitSeconds(10);

await subdaoMember1.executeTimelockedProposal(proposalId);
const timelockedProp = await subDao.getTimelockedProposal(proposalId);
expect(timelockedProp.id).toEqual(proposalId);
expect(timelockedProp.status).toEqual('executed');
expect(timelockedProp.msgs).toHaveLength(1);

const tokenfactoryParams = await neutronChain.queryTokenfactoryParams();
expect(tokenfactoryParams.params.denom_creation_fee).toEqual([
{ denom: 'untrn', amount: '1' },
]);
expect(tokenfactoryParams.params.denom_creation_gas_consume).toEqual(
'20',
);
expect(tokenfactoryParams.params.fee_collector_address).toEqual(
'neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2',
);
expect(tokenfactoryParams.params.whitelisted_hooks).toEqual([
{
code_id: '1',
denom_creator: 'neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2',
},
]);
});
});
});
16 changes: 11 additions & 5 deletions src/testcases/run_in_band/parameters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
updateFeerefunderParamsProposal,
updateInterchainqueriesParamsProposal,
updateInterchaintxsParamsProposal,
updateTokenfacoryParamsProposal,
updateTokenfactoryParamsProposal,
updateTransferParamsProposal,
} from '@neutron-org/neutronjsplus/dist/proposal';

Expand Down Expand Up @@ -127,10 +127,11 @@ describe('Neutron / Parameters', () => {
chainManagerAddress,
'Proposal #2',
'Tokenfactory params proposal',
updateTokenfacoryParamsProposal({
updateTokenfactoryParamsProposal({
fee_collector_address: await neutronChain.getNeutronDAOCore(),
denom_creation_fee: null,
denom_creation_fee: [{ denom: 'untrn', amount: '1' }],
denom_creation_gas_consume: 100000,
whitelisted_hooks: [],
}),
'1000',
);
Expand All @@ -156,13 +157,18 @@ describe('Neutron / Parameters', () => {
test('check if params changed after proposal execution', async () => {
const paramsAfter = await neutronChain.queryTokenfactoryParams();

expect(paramsAfter.params.denom_creation_fee).toEqual(
expect(paramsAfter.params.denom_creation_fee).not.toEqual(
paramsBefore.params.denom_creation_fee,
);
expect(paramsAfter.params.denom_creation_gas_consume).not.toEqual(
paramsBefore.params.denom_creation_gas_consume,
);
expect(paramsAfter.params.denom_creation_fee).toHaveLength(0);
expect(paramsAfter.params.denom_creation_fee).toEqual([
{
denom: 'untrn',
amount: '1',
},
]);
expect(paramsAfter.params.denom_creation_gas_consume).toEqual('100000');
});
});
Expand Down
Loading

0 comments on commit 43b9d50

Please sign in to comment.