Skip to content

Commit

Permalink
Merge pull request #283 from neutron-org/feat/sdk-50
Browse files Browse the repository at this point in the history
sdk 50 NTRN-230
  • Loading branch information
pr0n00gler authored Jun 11, 2024
2 parents 8569ee7 + 9ca78a3 commit 089e42c
Show file tree
Hide file tree
Showing 23 changed files with 1,131 additions and 4,928 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"scripts": {
"test": "yarn test:parallel && yarn test:run_in_band",
"test:parallel": "jest -b src/testcases/parallel",
"test:run_in_band": "yarn test:tge:auction && yarn test:tge:airdrop && yarn test:tge:credits && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:dex_stargate && yarn test:globalfee && yarn test:dex_bindings && yarn test:pob && yarn test:chain_manager",
"test:run_in_band": "yarn test:tge:auction && yarn test:tge:credits && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:dex_stargate && yarn test:dex_bindings && yarn test:slinky && yarn test:chain_manager && yarn test:feemarket && yarn test:globalfee",
"test:simple": "jest -b src/testcases/parallel/simple",
"test:slinky": "jest -b src/testcases/run_in_band/slinky",
"test:stargate_queries": "jest -b src/testcases/parallel/stargate_queries",
"test:interchaintx": "jest -b src/testcases/run_in_band/interchaintx",
"test:interchain_kv_query": "jest -b src/testcases/run_in_band/interchain_kv_query",
Expand All @@ -16,12 +17,10 @@
"test:reserve": "jest -b src/testcases/run_in_band/reserve",
"test:governance": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/parallel/governance",
"test:subdao": "jest -b src/testcases/parallel/subdao",
"test:tge:airdrop": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/tge.airdrop",
"test:tge:auction": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/tge.auction",
"test:tge:credits": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/tge.credits",
"test:tokenomics": "jest -b src/testcases/run_in_band/tokenomics",
"test:dao": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/parallel/dao_assert",
"test:globalfee": "jest -b src/testcases/run_in_band/globalfee",
"test:ibc_hooks": "jest -b src/testcases/run_in_band/ibc_hooks",
"test:parameters": "jest -b src/testcases/run_in_band/parameters",
"test:chain_manager": "jest -b src/testcases/run_in_band/chain_manager",
Expand All @@ -33,8 +32,9 @@
"test:voting_registry": "jest -b src/testcases/parallel/voting_registry",
"test:float": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/float",
"test:dex_stargate": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/dex_stargate",
"test:pob": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/pob",
"test:dex_bindings": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/dex_bindings",
"test:feemarket": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/feemarket",
"test:globalfee": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 jest -b src/testcases/run_in_band/globalfee",
"gen:proto": "bash ./gen-proto.sh",
"lint": "eslint ./src",
"fmt": "eslint ./src --fix",
Expand All @@ -47,7 +47,7 @@
"@cosmos-client/core": "^0.47.4",
"@cosmos-client/cosmwasm": "^0.40.3",
"@cosmos-client/ibc": "^1.2.1",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#35a66ac1e24b1224a57f335eddf7ba250f784a13",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#58eb19ae11067de3bd73d0c4cd2889aca422d079",
"@types/lodash": "^4.14.182",
"@types/long": "^5.0.0",
"axios": "^0.27.2",
Expand Down
1 change: 1 addition & 0 deletions setup/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 16.20.0
7 changes: 5 additions & 2 deletions setup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ build-hermes:
build-relayer:
cd $(APP_DIR)/neutron-query-relayer/ && make build-docker

build-all: build-gaia build-neutron build-hermes build-relayer
build-slinky:
@docker buildx build --load --build-context app=https://github.com/skip-mev/slinky.git#v1.0.0 -t skip-mev/slinky-e2e-oracle -f dockerbuilds/Dockerfile.slinky .

start-cosmopark: build-neutron build-relayer
build-all: build-gaia build-neutron build-hermes build-relayer build-slinky

start-cosmopark:
@$(COMPOSE) up -d

start-cosmopark-no-rebuild:
Expand Down
15 changes: 14 additions & 1 deletion setup/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
neutron-node:
image: neutron-node
Expand All @@ -12,6 +11,8 @@ services:
- 8090:9090
environment:
- RUN_BACKGROUND=0
- ORACLE_ADDRESS=oracle:8080
- FEEMARKET_ENABLED=false
networks:
- neutron-testing

Expand Down Expand Up @@ -78,6 +79,18 @@ services:
networks:
- neutron-testing

oracle:
image: skip-mev/slinky-e2e-oracle
entrypoint: [
"slinky",
"--market-map-endpoint", "neutron-node:9090",
]
ports:
- "8080:8080" # main oracle port
- "8002:8002" # oracle metrics port
networks:
- neutron-testing

volumes:
data:
name: neutron-testing-data
Expand Down
3 changes: 1 addition & 2 deletions setup/dockerbuilds/Dockerfile.gaia
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# syntax=docker/dockerfile:1

FROM golang:1.20-alpine AS builder
RUN apk upgrade -U -a
FROM golang:1.21-alpine AS builder
WORKDIR /src/app/
COPY --from=app go.mod go.sum* ./
RUN go mod download
Expand Down
21 changes: 21 additions & 0 deletions setup/dockerbuilds/Dockerfile.slinky
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.22-bullseye AS builder

WORKDIR /src/slinky
COPY --from=app go.mod .

RUN go mod download

COPY --from=app . .

RUN make build

FROM ubuntu:rolling
EXPOSE 8080
EXPOSE 8002

COPY --from=builder /src/slinky/build/* /usr/local/bin/
RUN apt-get update && apt-get install ca-certificates -y

WORKDIR /usr/local/bin/

ENTRYPOINT ["slinky"]
73 changes: 41 additions & 32 deletions src/testcases/parallel/governance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('Neutron / Governance', () => {
});

describe('create several proposals', () => {
test('create proposal #1, will pass', async () => {
test('create proposal #1, will be rejected', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitParameterChangeProposal(
chainManagerAddress,
Expand Down Expand Up @@ -216,13 +216,12 @@ describe('Neutron / Governance', () => {

test('create proposal #6, will pass', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitClientUpdateProposal(
await daoMember1.submitRecoverIBCClient(
chainManagerAddress,
'Proposal #6',
'UpdateClient proposal. Will pass',
'07-tendermint-2',
'07-tendermint-1',
'1000',
);
});

Expand Down Expand Up @@ -368,7 +367,7 @@ describe('Neutron / Governance', () => {
);
});

test('create proposal #16, will pass', async () => {
test('create proposal #16, will be rejected', async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
await daoMember1.submitParameterChangeProposal(
chainManagerAddress,
Expand Down Expand Up @@ -480,32 +479,35 @@ describe('Neutron / Governance', () => {
});
});

describe('vote for proposal #1 (no, yes, yes)', () => {
describe('vote for proposal #1 (no, yes, no)', () => {
const proposalId = 1;
test('vote NO from wallet 1', async () => {
await daoMember1.voteNo(proposalId);
});
test('vote YES from wallet 2', async () => {
await daoMember2.voteYes(proposalId);
});
test('vote YES from wallet 3', async () => {
await daoMember3.voteYes(proposalId);
test('vote NO from wallet 3', async () => {
await daoMember3.voteNo(proposalId);
});
});

describe('execute proposal #1', () => {
const proposalId = 1;
test('check if proposal is passed', async () => {
await mainDao.checkPassedProposal(proposalId);
});
test('execute passed proposal', async () => {
const host = await neutronChain.queryHostEnabled();
expect(host).toEqual(true);
await daoMember1.executeProposalWithAttempts(proposalId);
});
test('check if host is not enabled after proposal execution', async () => {
const host = await neutronChain.queryHostEnabled();
expect(host).toEqual(false);
test('check if proposal is rejected', async () => {
const proposalId = 1;
let rawLog: any;
try {
rawLog = (await daoMember1.executeProposal(proposalId)).raw_log;
} catch (e) {
rawLog = e.message;
}
expect(rawLog.includes("proposal is not in 'passed' state"));
await getWithAttempts(
neutronChain.blockWaiter,
async () => await mainDao.queryProposal(proposalId),
async (response) => response.proposal.status === 'rejected',
20,
);
});
});

Expand Down Expand Up @@ -581,11 +583,15 @@ describe('Neutron / Governance', () => {
test('check if proposal is passed', async () => {
await mainDao.checkPassedMultiChoiceProposal(proposalId);
});
test('execute passed proposal', async () => {
await daoMember1.executeMultiChoiceProposalWithAttempts(proposalId);
});
test('check if proposal is executed', async () => {
await mainDao.checkExecutedMultiChoiceProposal(proposalId);
test('execute passed proposal, should fail on neutron side', async () => {
let rawLog: any;
try {
rawLog = (await daoMember1.executeMultiChoiceProposal(proposalId))
.raw_log;
} catch (e) {
rawLog = e.message;
}
expect(rawLog.includes('proposal content is not whitelisted'));
});
});

Expand Down Expand Up @@ -1027,12 +1033,15 @@ describe('Neutron / Governance', () => {
});

describe('try to execute proposal #16', () => {
const proposalId = 16;
test('check if proposal is passed', async () => {
await mainDao.checkPassedProposal(proposalId);
});
test('execute passed proposal', async () => {
await daoMember1.executeProposalWithAttempts(proposalId);
test('check if proposal is failed', async () => {
const proposalId = 1;
let rawLog: any;
try {
rawLog = (await daoMember1.executeProposal(proposalId)).raw_log;
} catch (e) {
rawLog = e.message;
}
expect(rawLog.includes('proposal content is not whitelisted'));
});
});

Expand Down Expand Up @@ -1147,11 +1156,11 @@ describe('Neutron / Governance', () => {
const res = await daoMember1.user.msgSendDirectProposal(
'icahost',
'HostEnabled',
'true',
'false',
);
expect(res.code).toEqual(1); // must be admin to submit proposals to admin-module
const afterProposalHostStatus = await neutronChain.queryHostEnabled();
expect(afterProposalHostStatus).toEqual(false);
expect(afterProposalHostStatus).toEqual(true);
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/testcases/parallel/simple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,10 @@ describe('Neutron / Simple', () => {
}),
);

/*
/*
What is going on here. To test SudoTimeout handler functionality
we have to make an IBC package delivery by hermes really slowly.
But, actually there is no any activity on the IBC channel at this stage, as a result
But, actually there is no any activity on the IBC channel at this stage, as a result
hermes does not send any UpdateClient messages from gaia to neuron.
Gaia keeps building blocks and hermes knows nothing about it.
We get the height =N of the gaia chain, wait 15 blocks.
Expand Down
3 changes: 2 additions & 1 deletion src/testcases/parallel/tokenfactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ describe('Neutron / Tokenfactory', () => {
},
}),
);
denom = res.logs[0].events
console.log(JSON.stringify(res.events));
denom = res.events
?.find((event) => event.type == 'create_denom')
?.attributes?.find(
(attribute) => attribute.key == 'new_token_denom',
Expand Down
39 changes: 0 additions & 39 deletions src/testcases/run_in_band/chain_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,43 +219,4 @@ describe('Neutron / Chain Manager', () => {
expect(cronParams.params.limit).toEqual('42');
});
});

describe('ALLOW_ONLY: change legacy (global fee) parameters', () => {
let proposalId: number;
beforeAll(async () => {
const chainManagerAddress = (await neutronChain.getChainAdmins())[0];
proposalId = await subdaoMember1.submitParameterChangeProposal(
chainManagerAddress,
'Proposal #2',
'Globalfee param update proposal. Will pass',
'globalfee',
'MaxTotalBypassMinFeeMsgGasUsage',
'"42000"',
'1000',
);

const timelockedProp = await subdaoMember1.supportAndExecuteProposal(
proposalId,
);

expect(timelockedProp.id).toEqual(proposalId);
expect(timelockedProp.status).toEqual('timelocked');
expect(timelockedProp.msgs).toHaveLength(1);
});

test('execute timelocked: success', async () => {
await waitSeconds(10);

await subdaoMember1.executeTimelockedProposal(proposalId);
const timelockedProp = await subDao.getTimelockedProposal(proposalId);
expect(timelockedProp.id).toEqual(proposalId);
expect(timelockedProp.status).toEqual('executed');
expect(timelockedProp.msgs).toHaveLength(1);

const globalFeeParams = await neutronChain.queryGlobalfeeParams();
expect(globalFeeParams.max_total_bypass_min_fee_msg_gas_usage).toEqual(
'42000',
);
});
});
});
Loading

0 comments on commit 089e42c

Please sign in to comment.