Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: chain manager cron allow managing schedules #ntrn-387 #342

Merged
merged 10 commits into from
Sep 17, 2024
4 changes: 4 additions & 0 deletions src/testcases/parallel/governance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
],
execution_stage: 'EXECUTION_STAGE_BEGIN_BLOCKER',
},
true, // just to check that bindings are ok

Check failure on line 326 in src/testcases/parallel/governance.test.ts

View workflow job for this annotation

GitHub Actions / Actions - lint

Delete `··`
);
});

Expand All @@ -334,6 +335,9 @@
'',
'1000',
{ name: 'proposal11' },
'single',
true,
true,
);
});

Expand Down
91 changes: 91 additions & 0 deletions src/testcases/run_in_band/chain_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ describe('Neutron / Chain Manager', () => {
limit: true,
},
},
{
cron_permission: {
add_schedule: true,
remove_schedule: true,
},
},
{
update_tokenfactory_params_permission: {
denom_creation_fee: true,
Expand Down Expand Up @@ -356,4 +362,89 @@ describe('Neutron / Chain Manager', () => {
expect(dexParams.params.goodTilPurgeAllowance).toEqual(50000n);
});
});

describe('ALLOW_ONLY: CRON add schedule / remove schedule', () => {
let proposalId: number;
const scheduleName = 'schedule1';

test('create addSchedule proposal', async () => {
proposalId = await subdaoMember1.submitAddSchedule(
chainManagerAddress,
'Add schedule',
'cron add schedule proposal. Will pass',
'1000',
{
name: 'schedule1',
period: 100,
msgs: [
{
contract: 'whatever',
msg: JSON.stringify({}),
},
],
execution_stage: 0,
},
);

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

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

test('execute timelocked addSchedule: 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 res = await cronQuerier.schedule({ name: scheduleName });
expect(res.schedule.name).toEqual(scheduleName);
expect(res.schedule.msgs.length).toEqual(1);
expect(res.schedule.period).toEqual(100n);
});

test('create removeSchedule proposal', async () => {
proposalId = await subdaoMember1.submitRemoveSchedule(
chainManagerAddress,
'Add schedule',
'cron add schedule proposal. Will pass',
'1000',
{ name: 'schedule1' },
);

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

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

test('execute timelocked removeSchedule: 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);

let exceptionThrown = false;
try {
await cronQuerier.schedule({ name: scheduleName });
} catch (error) {
expect(error.message).toMatch(/schedule not found: key not found/);
exceptionThrown = true;
}
expect(exceptionThrown).toBeTruthy();
});
});
});
Loading
Loading