Skip to content

Commit

Permalink
Merge pull request #1673 from cboh4/cboh4/fix-integration-tests
Browse files Browse the repository at this point in the history
adapt integration tests
  • Loading branch information
iKapitonau authored Aug 16, 2024
2 parents b05bd9b + 64b0c6d commit 5fb0161
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
2 changes: 1 addition & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@types/node": "18.7.9",
"jest": "28.1.3",
"prettier": "2.7.1",
"secretjs": "2.0.0-beta.1",
"secretjs": "2.0.0-beta.3",
"ts-jest": "28.0.8",
"ts-node": "10.9.1",
"typescript": "4.7.4"
Expand Down
59 changes: 37 additions & 22 deletions integration-tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ beforeAll(async () => {
for (let i = 0; i < mnemonics.length; i++) {
const mnemonic = mnemonics[i];
const walletAmino = new AminoWallet(mnemonic);
const walletProto = new Wallet(mnemonic);
accounts[i] = {
address: walletAmino.address,
mnemonic: mnemonic,
walletAmino,
walletProto: new Wallet(mnemonic),
walletProto,
secretjs: new SecretNetworkClient({
url: "http://localhost:1317",
wallet: walletAmino,
walletAddress: walletAmino.address,
wallet: walletProto,
walletAddress: walletProto.address,
chainId: "secretdev-1",
}),
};
Expand All @@ -101,15 +102,16 @@ beforeAll(async () => {
for (let i = 0; i < mnemonics.length; i++) {
const mnemonic = mnemonics[i];
const walletAmino = new AminoWallet(mnemonic);
const walletProto = new Wallet(mnemonic);
accounts2[i] = {
address: walletAmino.address,
mnemonic: mnemonic,
walletAmino,
walletProto: new Wallet(mnemonic),
walletProto,
secretjs: new SecretNetworkClient({
url: "http://localhost:2317",
wallet: walletAmino,
walletAddress: walletAmino.address,
wallet: walletProto,
walletAddress: walletProto.address,
chainId: "secretdev-2",
}),
};
Expand All @@ -129,7 +131,7 @@ beforeAll(async () => {
secretjs: new SecretNetworkClient({
url: "http://localhost:1317",
chainId: "secretdev-1",
wallet: wallet,
wallet: walletProto,
walletAddress: address,
}),
};
Expand Down Expand Up @@ -497,20 +499,25 @@ describe("tx broadcast multi", () => {
});
});

describe.skip("GovMsgVote", () => {
describe("GovMsgVote", () => {
let proposalId: number;

beforeAll(async () => {

let tx = await accounts[0].secretjs.tx.gov.submitProposal(
{
type: ProposalType.TextProposal,
type: ProposalType.Proposal,
proposer: accounts[0].address,
// on localsecret min deposit is 10 SCRT
initial_deposit: stringToCoins("10000000uscrt"),
content: {
title: "Hi",
description: "Hello",
},
messages: [],
metadata: "some_metadatas",
summary: "summary",
title: "title"
},
{
broadcastCheckIntervalMs: 100,
Expand All @@ -523,7 +530,7 @@ describe.skip("GovMsgVote", () => {
expect(tx.code).toBe(TxResultCode.Success);

proposalId = Number(
tx.jsonLog?.[0].events
tx.events
.find((e) => e.type === "submit_proposal")
?.attributes.find((a) => a.key === "proposal_id")?.value
);
Expand Down Expand Up @@ -553,16 +560,20 @@ describe.skip("GovMsgVote", () => {

console.log(JSON.stringify(tx, null, 2));

const { attributes } = tx.jsonLog[0].events.find(
const { attributes } = tx.events.find(
(x) => x.type === "proposal_vote"
);
expect(attributes).toContainEqual({
const proposal_id = attributes.find((x) => x.key === "proposal_id");
expect(proposal_id).toStrictEqual({
key: "proposal_id",
value: String(proposalId),
index: true,
});
expect(attributes).toContainEqual({
const option = attributes.find((x) => x.key === "option");
expect(option).toStrictEqual({
key: "option",
value: '{"option":1,"weight":"1.000000000000000000"}',
value: '[{"option":1,"weight":"1.000000000000000000"}]',
index: true,
});
});

Expand All @@ -582,8 +593,8 @@ describe.skip("GovMsgVote", () => {
{ gasLimit: 250_000 }
);

expect(tx.code).toBe(2 /* Gov ErrUnknownProposal */);
expect(tx.rawLog).toContain(`${proposalId + 1e6}: unknown proposal`);
expect(tx.code).toBe(3 /* Gov ErrInvalidSequence */);
expect(tx.rawLog).toContain(`${proposalId + 1e6}: inactive proposal`);
});
});

Expand All @@ -608,16 +619,20 @@ describe.skip("GovMsgVote", () => {
}
expect(tx.code).toBe(TxResultCode.Success);

const { attributes } = tx.jsonLog[0].events.find(
const { attributes } = tx.events.find(
(x) => x.type === "proposal_vote"
);
expect(attributes).toContainEqual({
const proposal_id = attributes.find((x) => x.key === "proposal_id");
expect(proposal_id).toStrictEqual({
key: "proposal_id",
index: true,
value: String(proposalId),
});
expect(attributes).toContainEqual({
const option = attributes.find((x) => x.key === "option");
expect(option).toStrictEqual({
index: true,
key: "option",
value: '{"option":1,"weight":"1.000000000000000000"}',
value: '[{"option":1,"weight":"1.000000000000000000"}]',
});
});

Expand All @@ -637,8 +652,8 @@ describe.skip("GovMsgVote", () => {
{ gasLimit: 250_000 }
);

expect(tx.code).toBe(2 /* Gov ErrUnknownProposal */);
expect(tx.rawLog).toContain(`${proposalId + 1e6}: unknown proposal`);
expect(tx.code).toBe(3 /* Gov ErrInvalidSequence */);
expect(tx.rawLog).toContain(`${proposalId + 1e6}: inactive proposal`);
});
});
});
Expand Down

0 comments on commit 5fb0161

Please sign in to comment.