diff --git a/integration-tests/package-lock.json b/integration-tests/package-lock.json index 6d7427ed..ccaf43cc 100644 --- a/integration-tests/package-lock.json +++ b/integration-tests/package-lock.json @@ -9,7 +9,7 @@ "version": "v2.6.2", "license": "MIT", "dependencies": { - "@terra-money/feather.js": "^1.2.1", + "@terra-money/feather.js": "^2.0.0-beta.1", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" }, @@ -1803,9 +1803,9 @@ } }, "node_modules/@terra-money/feather.js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-1.2.1.tgz", - "integrity": "sha512-OyXkWriNwb0lCF45eMmtjdOPEmfGKJxgGSnxpM7VxD0Vqr1qqtlcYyQG9wOHXNQrExvZv+uo922B2ZA4S77HsQ==", + "version": "2.0.0-beta.1", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.1.tgz", + "integrity": "sha512-cT8pNNvVEql9vni5SVk4d3+FBqVD9/D+A+qOhXJAvOs0cOG6NFEKmpBbhJlGegqlnr+Gksxp5bJ0YO2XYac2Vw==", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", @@ -7008,9 +7008,9 @@ } }, "@terra-money/feather.js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-1.2.1.tgz", - "integrity": "sha512-OyXkWriNwb0lCF45eMmtjdOPEmfGKJxgGSnxpM7VxD0Vqr1qqtlcYyQG9wOHXNQrExvZv+uo922B2ZA4S77HsQ==", + "version": "2.0.0-beta.1", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.1.tgz", + "integrity": "sha512-cT8pNNvVEql9vni5SVk4d3+FBqVD9/D+A+qOhXJAvOs0cOG6NFEKmpBbhJlGegqlnr+Gksxp5bJ0YO2XYac2Vw==", "requires": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", diff --git a/integration-tests/package.json b/integration-tests/package.json index 56ea3592..381ed2a0 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -30,7 +30,7 @@ "typescript": "^5.2.2" }, "dependencies": { - "@terra-money/feather.js": "^1.2.1", + "@terra-money/feather.js": "^2.0.0-beta.1", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" } diff --git a/integration-tests/src/modules/gov.test.ts b/integration-tests/src/modules/gov.test.ts index 68a2f6b9..a7cab5ce 100644 --- a/integration-tests/src/modules/gov.test.ts +++ b/integration-tests/src/modules/gov.test.ts @@ -1,21 +1,21 @@ import { getMnemonics } from "../helpers/mnemonics"; import { getLCDClient } from "../helpers/lcd.connection"; -import { Coins, MsgVote, Fee, MsgSubmitProposal } from "@terra-money/feather.js"; +import { Coins, MsgVote, Fee, MsgSubmitProposal, Proposal, Int } from "@terra-money/feather.js"; import { blockInclusion, votingPeriod } from "../helpers/const"; -import { VoteOption } from "@terra-money/terra.proto/cosmos/gov/v1beta1/gov"; +import { ProposalStatus, VoteOption } from "@terra-money/terra.proto/cosmos/gov/v1beta1/gov"; -describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/v0.3.x) ", () => { +describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/release/v0.47.x/x/gov) ", () => { // Prepare environment clients, accounts and wallets const LCD = getLCDClient(); const accounts = getMnemonics(); const val2Wallet = LCD.chain2.wallet(accounts.val2); const val2WalletAddress = val2Wallet.key.accAddress("terra"); + let proposalId = 0; // Will be populated on "Must submit a proposal on chain" test('Must contain the expected module params', async () => { try { - // Query Alliance module params + // Query All gov module params const moduleParams = await LCD.chain2.gov.params("test-2"); - // Validate that the params were set correctly on genesis expect(moduleParams) .toStrictEqual({ @@ -36,6 +36,111 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/ "voting_params": { "voting_period": "4s", }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, + }); + + // Query tally module params + const tallyParams = await LCD.chain2.gov.tallyParams("test-2"); + // Validate that the params were set correctly on genesis + expect(tallyParams) + .toStrictEqual({ + "deposit_params": null, + "voting_params": null, + "tally_params": { + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, + }); + + // Query voting gov module params + const votingParams = await LCD.chain2.gov.votingParams("test-2"); + // Validate that the params were set correctly on genesis + expect(votingParams) + .toStrictEqual({ + "deposit_params": null, + "tally_params": null, + "voting_params": { + "voting_period": "4s", + }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, + }); + + + // Query deposit gov module params + const depositParams = await LCD.chain2.gov.depositParams("test-2"); + // Validate that the params were set correctly on genesis + expect(depositParams) + .toStrictEqual({ + "voting_params": null, + "tally_params": null, + "deposit_params": { + "max_deposit_period": "172800s", + "min_deposit": [ + { + "amount": "10000000", + "denom": "uluna", + }, + ], + }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, }); } catch (e) { @@ -44,7 +149,7 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/ } }); - test('Must submit a proposal on chain', async () => { + test('Must submit an empty proposal on chain', async () => { try { const msgProposal = new MsgSubmitProposal( [], @@ -67,7 +172,7 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/ expect(txResult.code).toBe(0); // Get the proposal id and validate exists - let proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]); + proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]); expect(proposalId) // Vote for the proposal @@ -92,5 +197,42 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/ // Query the alliance and check if it exists const res = await LCD.chain2.gov.proposals("test-2"); expect(res).toBeDefined(); + }); + + describe("After submitting the proposal on chain", () => { + test('Must query the proposals', async () => { + // Query the alliance and check if it exists + const res = await LCD.chain2.gov.proposals("test-2"); + let proposal; + for (const prop of res.proposals) { + if (prop.id === proposalId){ + proposal = prop; + } + } + expect(proposal).toBeDefined(); + proposal = proposal as Proposal; + expect(proposal.id).toBe(proposalId); + expect(proposal.proposer).toBe(val2WalletAddress); + expect(proposal.metadata).toBe("metadata"); + expect(proposal.title).toBe("title"); + expect(proposal.summary).toBe("summary"); + expect(proposal.messages.length).toBe(0); + expect(proposal.total_deposit).toStrictEqual(Coins.fromString("1000000000uluna")); + expect(proposal.submit_time.getTime()).toBeLessThan(Date.now()); + expect(proposal.voting_start_time?.getTime()).toBeLessThan(Date.now()); + expect(proposal.deposit_end_time?.getTime()).toBeGreaterThan(Date.now()); + expect(proposal.voting_end_time?.getTime()).toBeLessThan(Date.now()); + expect(proposal.status).toBe(ProposalStatus.PROPOSAL_STATUS_PASSED) + }); + + test('Must query the tally', async () => { + // Query the alliance and check if it exists + const res = await LCD.chain2.gov.tally("test-2", proposalId); + expect(res).toBeDefined(); + expect(res.yes_count).toStrictEqual(new Int(27000000000)); + expect(res.abstain_count).toStrictEqual(new Int(0)); + expect(res.no_count).toStrictEqual(new Int(0)); + expect(res.no_with_veto_count).toStrictEqual(new Int(0)); + }); }) }); \ No newline at end of file