Skip to content

Commit

Permalink
added MsgRemoveFeeDenomParam tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freeelancer committed Feb 15, 2024
1 parent f8c27e7 commit 8c304e9
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 18 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,6 @@ replace (
github.com/cosmos/ibc-go/v7 => github.com/terra-money/ibc-go/v7 v7.3.1-terra.0
github.com/cosmos/ledger-cosmos-go => github.com/terra-money/ledger-terra-go v0.11.2
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/skip-mev/feemarket => github.com/terra-money/feemarket v0.0.0-20240215091618-212bc0ebe34e
github.com/skip-mev/feemarket => github.com/terra-money/feemarket v0.0.0-20240215105105-dc75f934f9ba
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,8 @@ github.com/terra-money/alliance v0.3.2 h1:MuL3RBw+jXFv4io5PhaBn7jRUBvlJLUzgpD6gx
github.com/terra-money/alliance v0.3.2/go.mod h1:HDiUexeXRUkLkLRw5jLQcHuVt1Sx43HfyVl0kfwW3JM=
github.com/terra-money/cosmos-sdk v0.47.6-terra.0 h1:BrK2cq8W5HsMT5siVdJCFDx1vcEMm+BGN5713FEm84g=
github.com/terra-money/cosmos-sdk v0.47.6-terra.0/go.mod h1:xTc1chW8HyUWCfrgGbjS5jNu9RzlPVrBNfbL9RmZUio=
github.com/terra-money/feemarket v0.0.0-20240215091618-212bc0ebe34e h1:U/laoqxVmwswACZNtQJlLgRf/Gx/kfQnd3deHnOJMTI=
github.com/terra-money/feemarket v0.0.0-20240215091618-212bc0ebe34e/go.mod h1:Gl4UMT4EKGUj/qq9fn4JtH8tsDDjVzzN/2VMK55SXdo=
github.com/terra-money/feemarket v0.0.0-20240215105105-dc75f934f9ba h1:bZhxyABS7PcsvSZx58Vv/IdaC0c/2RsdSX+3sgFbkPk=
github.com/terra-money/feemarket v0.0.0-20240215105105-dc75f934f9ba/go.mod h1:Gl4UMT4EKGUj/qq9fn4JtH8tsDDjVzzN/2VMK55SXdo=
github.com/terra-money/ibc-go/v7 v7.3.1-terra.0 h1:CF+iicqyI4BJsW2zjUrUrTxRRrPWFZC30VqvlRyVl28=
github.com/terra-money/ibc-go/v7 v7.3.1-terra.0/go.mod h1:wvx4pPBofe5ZdMNV3OFRxSI4auEP5Qfqf8JXLLNV04g=
github.com/terra-money/ledger-terra-go v0.11.2 h1:BVXZl+OhJOri6vFNjjVaTabRLApw9MuG7mxWL4V718c=
Expand Down
14 changes: 0 additions & 14 deletions integration-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

180 changes: 179 additions & 1 deletion integration-tests/src/modules/feemarket/feemarket.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Coins, Fee, MnemonicKey, MsgSend, MsgSubmitProposal, MsgVote } from "@terra-money/feather.js";
import { VoteOption } from "@terra-money/terra.proto/cosmos/gov/v1beta1/gov";
import { blockInclusion, getLCDClient, getMnemonics, votingPeriod } from "../../helpers";
import { FeemarketParams, MsgFeeDenomParam, MsgParams } from "@terra-money/feather.js/dist/core/feemarket";
import { FeemarketParams, MsgFeeDenomParam, MsgRemoveFeeDenomParam, MsgParams } from "@terra-money/feather.js/dist/core/feemarket";


describe("Feemarket Module (https://github.com/terra-money/feemarket/tree/v0.0.1-alpha.2-terra.0) ", () => {
Expand Down Expand Up @@ -205,6 +205,184 @@ describe("Feemarket Module (https://github.com/terra-money/feemarket/tree/v0.0.1
}
});

test('Must send a proposal to add fee denom for stake and validate it has been added correctly', async () => {
try {
// Create an state update proposal sign and submit on chain-1
let tx = await val1Wallet.createAndSignTx({
msgs: [new MsgSubmitProposal(
[new MsgFeeDenomParam(
'stake',
'1550000000000000',
'terra10d07y265gmmuvt4z0w9aw880jnsr700juxf95n',
)],
Coins.fromString("1000000000uluna"),
val1WalletAddress,
"metadata",
"title",
"summary"
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
let result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await blockInclusion();

// Check that the proposal was created successfully
let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any;
expect(txResult.code).toBe(0);

// Get the proposal id and validate exists
const proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]);
expect(proposalId).toBeDefined();

// Vote for the proposal
tx = await val1Wallet.createAndSignTx({
msgs: [new MsgVote(
proposalId,
val1WalletAddress,
VoteOption.VOTE_OPTION_YES
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await votingPeriod();

// Validate the tx vote was casted successflully
txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1")
expect(txResult.code).toBe(0);

// Query the feemarket state for uluna and validate the new values
const res = (await LCD.chain1.feemarket.feeDenomParam("test-1", "stake"))[0];
expect(res.feeDenom).toEqual("stake");
expect(res.baseFee.toNumber()).toBeGreaterThanOrEqual(0.00155);
expect(res.minBaseFee.toString()).toStrictEqual("0.00155");
}
catch (e: any) {
console.log(e)
expect(e).toBeUndefined();
}
});

test('Must send a proposal to remove fee denom for stake and validate it has been removed correctly', async () => {
try {
// Create an state update proposal sign and submit on chain-1
let tx = await val1Wallet.createAndSignTx({
msgs: [new MsgSubmitProposal(
[new MsgRemoveFeeDenomParam(
'stake',
'terra10d07y265gmmuvt4z0w9aw880jnsr700juxf95n',
)],
Coins.fromString("1000000000uluna"),
val1WalletAddress,
"metadata",
"title",
"summary"
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
let result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await blockInclusion();

// Check that the proposal was created successfully
let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any;
expect(txResult.code).toBe(0);

// Get the proposal id and validate exists
const proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]);
expect(proposalId).toBeDefined();

// Vote for the proposal
tx = await val1Wallet.createAndSignTx({
msgs: [new MsgVote(
proposalId,
val1WalletAddress,
VoteOption.VOTE_OPTION_YES
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await votingPeriod();

// Validate the tx vote was casted successflully
txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1")
expect(txResult.code).toBe(0);

// Query the feemarket state for uluna and validate the new values
try {
await LCD.chain1.feemarket.feeDenomParam("test-1", "stake");
} catch(e: any) {
expect(e.message).toBe("Request failed with status code 500");
return;
}
throw new Error('No error was thrown when trying to query the removed fee denom.')
}
catch (e: any) {
console.log(e)
expect(e.message).toBeUndefined();
}
});

test('Must send a proposal to remove default fee denom uluna and validate it will not be removed after execution', async () => {
try {
// Create an state update proposal sign and submit on chain-1
let tx = await val1Wallet.createAndSignTx({
msgs: [new MsgSubmitProposal(
[new MsgRemoveFeeDenomParam(
'uluna',
'terra10d07y265gmmuvt4z0w9aw880jnsr700juxf95n',
)],
Coins.fromString("1000000000uluna"),
val1WalletAddress,
"metadata",
"title",
"summary"
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
let result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await blockInclusion();

// Check that the proposal was created successfully
let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any;
expect(txResult.code).toBe(0);

// Get the proposal id and validate exists
const proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]);
expect(proposalId).toBeDefined();

// Vote for the proposal
tx = await val1Wallet.createAndSignTx({
msgs: [new MsgVote(
proposalId,
val1WalletAddress,
VoteOption.VOTE_OPTION_YES
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await votingPeriod();

// Validate the tx vote was casted successflully
txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1")
expect(txResult.code).toBe(0);

// Query the feemarket state for uluna and validate the new values
const res = (await LCD.chain1.feemarket.feeDenomParam("test-1", "uluna"))[0];
expect(res.feeDenom).toEqual("uluna");
expect(res.baseFee.toNumber()).toBeGreaterThanOrEqual(0.00155);
expect(res.minBaseFee.toString()).toStrictEqual("0.00155");
}
catch (e: any) {
console.log(e)
expect(e.message).toBeUndefined();
}
});

test('Must modify the fees back to the default values', async () => {
try {
// Create a FeemarketParams proposal change and
Expand Down

0 comments on commit 8c304e9

Please sign in to comment.