Skip to content

Commit

Permalink
lint & more explicit namings & small ref
Browse files Browse the repository at this point in the history
  • Loading branch information
quasisamurai committed Sep 26, 2024
1 parent f777034 commit 10b1869
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"test:dex_bindings": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/dex_bindings --bail 1",
"test:chain_manager": "vitest --run src/testcases/run_in_band/chain_manager --bail 1",
"test:feemarket": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/feemarket --bail 1",
"test:rate_limit": "vitest --run src/testcases/run_in_band/rate_limit --bail 1",
"test:ibc_rate_limit": "vitest --run src/testcases/run_in_band/ibc_rate_limit --bail 1",
"lint": "eslint ./src",
"fmt": "eslint ./src --fix",
"build:neutronjsplus": "[ -d './node_modules/@neutron-org/neutronjsplus/dist' ] || tsc -p ./node_modules/@neutron-org/neutronjsplus/tsconfig.json",
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const CONTRACTS = {
LOCKDROP_VAULT_CL: 'lockdrop_vault_for_cl_pools.wasm',
MARKETMAP: 'marketmap.wasm',
ORACLE: 'oracle.wasm',
RATE_LIMITER: 'rate_limiter.wasm',
IBC_RATE_LIMITER: 'rate_limiter.wasm',
};

export const NEUTRON_PREFIX = process.env.NEUTRON_ADDRESS_PREFIX || 'neutron';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ describe('Neutron / IBC transfer', () => {
let neutronQuerier: NeutronQuerier;
let ibcQuerier: IbcQueryClient;

let amount: string;

beforeAll(async (suite: RunnerTestSuite) => {
testState = await LocalState.create(config, inject('mnemonics'), suite);

Expand Down Expand Up @@ -112,7 +114,7 @@ describe('Neutron / IBC transfer', () => {
1,
1,
);
rlContract = await neutronClient.create(CONTRACTS.RATE_LIMITER, {
rlContract = await neutronClient.create(CONTRACTS.IBC_RATE_LIMITER, {
gov_module: neutronWallet.address,
ibc_module: ADMIN_MODULE_ADDRESS,
paths: [quota],
Expand Down Expand Up @@ -160,13 +162,13 @@ describe('Neutron / IBC transfer', () => {
expect(res.code).toEqual(0);
});

describe('Rate limit params proposal', () => {
describe('IBC rate limit params proposal', () => {
const proposalId = 1;
test('create proposal', async () => {
await daoMember1.submitUpdateParamsRateLimitProposal(
chainManagerAddress,
'Proposal #1',
'Param change proposal. Setup rate limit contract',
'Param change proposal. Setup IBC rate limit contract',
{
contract_address: rlContract,
},
Expand All @@ -185,7 +187,7 @@ describe('Neutron / IBC transfer', () => {
});
});

describe('Rate limits', () => {
describe('IBC Rate limits', () => {
describe('setup ibc contract', () => {
test('transfer to contract', async () => {
const res = await neutronClient.sendTokens(
Expand Down Expand Up @@ -273,14 +275,16 @@ describe('Neutron / IBC transfer', () => {
});

test('IBC send via contract(s) should be limited as well', async () => {
await expect(neutronClient.execute(ibcContract, {
send: {
channel: TRANSFER_CHANNEL,
to: gaiaWallet.address,
denom: NEUTRON_DENOM,
amount: '1000001',
},
})).rejects.toThrow(/IBC Rate Limit exceeded for channel-0/);
await expect(
neutronClient.execute(ibcContract, {
send: {
channel: TRANSFER_CHANNEL,
to: gaiaWallet.address,
denom: NEUTRON_DENOM,
amount: '1000001',
},
}),
).rejects.toThrow(/IBC Rate Limit exceeded for channel-0/);
});

test('IBC transfer from a different wallet to ensure that limiting is working for different address (non-contract)', async () => {
Expand Down Expand Up @@ -398,12 +402,12 @@ describe('Neutron / IBC transfer', () => {
});
});

test('IBC transfer to limit (hits the limit)', async () => {
test('IBC transfer exceeds the limit', async () => {
const uatomibcSupply = await bankQuerier.supplyOf({
denom: UATOM_IBC_TO_NEUTRON_DENOM,
});

const amount = (
amount = (
BigInt(uatomibcSupply.amount.amount) / BigInt(100) +
BigInt(1)
).toString();
Expand Down Expand Up @@ -468,7 +472,7 @@ describe('Neutron / IBC transfer', () => {
value: NeutronMsgTransfer.fromPartial({
sourcePort: 'transfer',
sourceChannel: TRANSFER_CHANNEL,
token: { denom: UATOM_IBC_TO_NEUTRON_DENOM, amount: '10' },
token: { denom: UATOM_IBC_TO_NEUTRON_DENOM, amount: amount },
sender: neutronWallet.address,
receiver: gaiaWallet.address,
timeoutHeight: {
Expand Down

0 comments on commit 10b1869

Please sign in to comment.