Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josemarinas committed Nov 16, 2023
1 parent 20a5363 commit a510317
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 40 deletions.
4 changes: 2 additions & 2 deletions modules/client/test/integration/client/decoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,10 @@ describe("Client", () => {
"0x1234567890123456789012345678901234567890",
applyUpdateParams,
);
expect(actions.length).toBe(3);
expect(actions.length).toBe(5);
const decodedApplyUpdateParams = client.decoding
.applyUpdateAction(
actions[1].data,
actions[2].data,
);
expect(applyUpdateParams.versionTag.build).toBe(
decodedApplyUpdateParams.versionTag.build,
Expand Down
105 changes: 67 additions & 38 deletions modules/client/test/integration/client/methods.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// mocks need to be at the top of the imports
import { mockedIPFSClient } from "../../mocks/aragon-sdk-ipfs";
import * as mockedGraphqlRequest from "../../mocks/graphql-request";

import * as ganacheSetup from "../../helpers/ganache-setup";
import * as deployContracts from "../../helpers/deployContracts";
import * as deployV1Contracts from "../../helpers/deploy-v1-contracts";
Expand Down Expand Up @@ -30,6 +29,7 @@ import {
DaoDepositSteps,
DaoQueryParams,
DaoSortBy,
DaoUpdateProposalInvalidityCause,
DepositParams,
HasPermissionParams,
PluginPreparationQueryParams,
Expand Down Expand Up @@ -2007,43 +2007,72 @@ describe("Client", () => {
});
});
describe("isDaoUpdateValid", () => {
// it("Should return true for a valid update", async () => {
// const context = new Context();
// const client = new Client(context);
// let initializeFromAction: DaoAction;
// let upgradeToAndCallAction: DaoAction;
// initializeFromAction = client.encoding.initializeFromAction(
// daoAddress,
// {
// initData: new Uint8Array(),
// previousVersion: [1, 0, 0],
// },
// );
// upgradeToAndCallAction = client.encoding.upgradeToAndCallAction(
// daoAddressV1,
// {
// data: initializeFromAction.data,
// implementationAddress: "0x1234567890123456789012345678901234567890",
// },
// );
// const mockedClient = mockedGraphqlRequest.getMockedInstance(
// client.graphql.getClient(),
// );
// mockedClient.request.mockResolvedValueOnce({
// iproposal: {
// dao: {
// id: daoAddress,
// },
// allowFailureMap: "0",
// actions: toSubgraphActions([upgradeToAndCallAction]),
// },
// });
// const res = await client.methods.isDaoUpdateValid(
// TEST_MULTISIG_PROPOSAL_ID,
// );
// expect(res.isValid).toBe(true);
// expect(res.causes).toMatchObject([]);
// });
let client: Client;
let initializeFromAction: DaoAction;
let upgradeToAndCallAction: DaoAction;
beforeAll(() => {
const context = new Context(contextParamsLocalChain);
client = new Client(context);
initializeFromAction = client.encoding.initializeFromAction(
daoAddressV1,
{
initData: new Uint8Array(),
previousVersion: [1, 0, 0],
},
);
});
it("Should return true for a valid update", async () => {
const implementationAddress = await client.methods.getDaoImplementation(
client.web3.getAddress("daoFactoryAddress"),
);
upgradeToAndCallAction = client.encoding.upgradeToAndCallAction(
daoAddressV1,
{
data: initializeFromAction.data,
implementationAddress,
},
);
const mockedClient = mockedGraphqlRequest.getMockedInstance(
client.graphql.getClient(),
);
mockedClient.request.mockResolvedValueOnce({
iproposal: {
dao: {
id: daoAddressV1,
},
allowFailureMap: "0",
actions: toSubgraphActions([upgradeToAndCallAction]),
},
});
const res = await client.methods.isDaoUpdateValid(
TEST_MULTISIG_PROPOSAL_ID,
);
expect(res.isValid).toBe(true);
expect(res.causes).toMatchObject([]);
});
it("Should PROPOSAL_NOT_FOUND when the proposal is null", async () => {
const implementationAddress = await client.methods.getDaoImplementation(
client.web3.getAddress("daoFactoryAddress"),
);
upgradeToAndCallAction = client.encoding.upgradeToAndCallAction(
daoAddressV1,
{
data: initializeFromAction.data,
implementationAddress,
},
);
const mockedClient = mockedGraphqlRequest.getMockedInstance(
client.graphql.getClient(),
);
mockedClient.request.mockResolvedValueOnce({
iproposal: null,
});
const res = await client.methods.isDaoUpdateValid(
TEST_MULTISIG_PROPOSAL_ID,
);
expect(res.isValid).toBe(false);
expect(res.causes).toMatchObject([DaoUpdateProposalInvalidityCause.PROPOSAL_NOT_FOUND]);
});
});
});
});

0 comments on commit a510317

Please sign in to comment.