Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Oct 6, 2023
1 parent 35be3e4 commit 4a38ffa
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
12 changes: 10 additions & 2 deletions src/helpers/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,15 @@ export class DaoMember {
): Promise<TimeLockSingleChoiceProposal> {
await this.voteYes(proposalId, customModule);
await this.executeProposal(proposalId, customModule);
return await this.dao.getTimelockedProposal(proposalId, customModule);
return await getWithAttempts(
this.dao.chain.blockWaiter,
async () =>
await this.dao.getTimelockedProposal(proposalId, customModule),
async (response) => {

Check failure on line 956 in src/helpers/dao.ts

View workflow job for this annotation

GitHub Actions / Actions - lint

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
return response.id && +response.id > 0;
},
5,
);
}

async executeTimelockedProposal(
Expand Down Expand Up @@ -1442,7 +1450,7 @@ export const deploySubdao = async (
mainDaoCoreAddress: string,
overrulePreProposeAddress: string,
securityDaoAddr: string,
closeProposalOnExecutionFailure: boolean,
closeProposalOnExecutionFailure = true,
): Promise<Dao> => {
const coreCodeId = await cm.storeWasm(NeutronContract.SUBDAO_CORE);
const cw4VotingCodeId = await cm.storeWasm(NeutronContract.CW4_VOTING);
Expand Down
7 changes: 1 addition & 6 deletions src/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,4 @@ export type ContractAdminResponse = {
};
};

export type ProposalFailedExecutionErrorResponse = {
errors: {
height: number;
error: string;
}[];
};
export type ProposalFailedExecutionErrorResponse = string;
1 change: 1 addition & 0 deletions src/testcases/parallel/overrule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('Neutron / Subdao', () => {
daoContracts.core.address,
daoContracts.proposals.overrule?.pre_propose?.address || '',
neutronAccount1.wallet.address.toString(),
false, // do not close proposal on failure since otherwise we wont get an error exception from submsgs
);

subdaoMember1 = new DaoMember(neutronAccount1, subDao);
Expand Down
18 changes: 7 additions & 11 deletions src/testcases/parallel/subdao.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@ describe('Neutron / Subdao', () => {
expect(timelockedProp.status).toEqual('execution_failed');
expect(timelockedProp.msgs).toHaveLength(1);

const res = await subDao.getTimelockedProposalErrors(proposalId);
expect(res.errors.length).toEqual(1);
expect(res.errors[0].error).toEqual('codespace: sdk, code: 5'); // 'insufficient funds' error
expect(res.errors[0].height).toBeGreaterThan(0);
const error = await subDao.getTimelockedProposalErrors(proposalId);
expect(error).toEqual('codespace: sdk, code: 5'); // 'insufficient funds' error
});

test('execute timelocked(ExecutionFailed): WrongStatus error', async () => {
Expand Down Expand Up @@ -194,7 +192,6 @@ describe('Neutron / Subdao', () => {
});

test('execute timelocked 2: execution failed', async () => {
// from here
await neutronAccount1.msgSend(subDao.contracts.core.address, '100000'); // fund the subdao treasury
const balance2 = await neutronAccount2.queryDenomBalance(NEUTRON_DENOM);

Expand All @@ -207,9 +204,8 @@ describe('Neutron / Subdao', () => {
expect(timelockedProp.status).toEqual('execution_failed');
expect(timelockedProp.msgs).toHaveLength(1);

const res = await subDao.getTimelockedProposalErrors(proposalId2);
expect(res.errors.length).toEqual(1);
expect(res.errors[0].error).toEqual('codespace: undefined, code: 1');
const error = await subDao.getTimelockedProposalErrors(proposalId2);
expect(error).toEqual('codespace: undefined, code: 1');

// check that goodMessage failed as well
const balance2After = await neutronAccount2.queryDenomBalance(
Expand Down Expand Up @@ -292,9 +288,9 @@ describe('Neutron / Subdao', () => {
expect(timelockedProp.status).toEqual('timelocked');
expect(timelockedProp.msgs).toHaveLength(1);

const res = await subDao.getTimelockedProposalErrors(proposalId3);
// do not have errors because we did not have reply
expect(res.errors.length).toEqual(0);
const error = await subDao.getTimelockedProposalErrors(proposalId3);
// do not have an error because we did not have reply
expect(error).toEqual(null);

await neutronAccount1.msgSend(subDao.contracts.core.address, '300000');

Expand Down

0 comments on commit 4a38ffa

Please sign in to comment.