Skip to content

Commit

Permalink
Merge pull request #737 from osmosis-labs/jonator/testnet
Browse files Browse the repository at this point in the history
Add testnet
  • Loading branch information
jonator authored Aug 17, 2022
2 parents 2e76d47 + a792f73 commit fc757c5
Show file tree
Hide file tree
Showing 34 changed files with 2,435 additions and 28 deletions.
3 changes: 2 additions & 1 deletion packages/math/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/src/**/?(*.)+(spec|test).[jt]s?(x)"],
roots: ["<rootDir>/src/"],
testMatch: ["**/__tests__/?(*.)+(spec|test).[jt]s?(x)"],
};
1 change: 1 addition & 0 deletions packages/math/types/__tests__/weighted.spec.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
1 change: 1 addition & 0 deletions packages/pools/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
roots: ["<rootDir>/src/"],
testMatch: ["**/src/**/?(*.)+(spec|test).[jt]s?(x)"],
};
1 change: 1 addition & 0 deletions packages/stores/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ build/*
types/*

**/generated/**
localnet
README.md
1 change: 1 addition & 0 deletions packages/stores/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ types/*

.prettierignore
.eslintignore
localnet
8 changes: 8 additions & 0 deletions packages/stores/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
roots: ["<rootDir>/src/"],
testMatch: ["**/__tests__/?(*.)+(spec|test).[jt]s?(x)"],
globalSetup: "./src/__tests__/global-setup.ts",
globalTeardown: "./src/__tests__/global-teardown.ts",
};
19 changes: 19 additions & 0 deletions packages/stores/localnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM ubuntu as config

RUN apt-get update && apt-get install -y git
RUN git clone https://github.com/osmosis-labs/LocalOsmosis.git
RUN mkdir -p /osmosis/.osmosisd/config && \
mv ./LocalOsmosis/config /osmosis/.osmosisd/ && \
mkdir -p /osmosis/.osmosisd/data && \
mv ./LocalOsmosis/data /osmosis/.osmosisd/ && \
mv ./LocalOsmosis/priv_validator_state.json /osmosis/.osmosisd/data

#enable swagger
RUN sed -i 's/swagger = false/swagger = true/g' /osmosis/.osmosisd/config/app.toml

# use debug version for utils, like sh
#FROM osmolabs/osmosis-dev:v9.0.0-debug
FROM osmolabs/osmosis:9.0.0

COPY --from=config /osmosis/.osmosisd/config /osmosis/.osmosisd/config
COPY --from=config /osmosis/.osmosisd/data /osmosis/.osmosisd/data
8 changes: 7 additions & 1 deletion packages/stores/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"build": "tsc && yarn build:proto",
"build:proto": "mkdir -p build/account/msg/proto/generated && cp ./src/account/msg/proto/generated/* ./build/account/msg/proto/generated",
"dev": "tsc -w",
"test": "jest --passWithNoTests",
"test:regression": "jest --passWithNoTests --runInBand",
"lint": "eslint \"src/**/*\" && prettier --check \"src/**/*\"",
"lint:fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\"",
"prepare": "yarn build",
Expand All @@ -39,6 +39,12 @@
"prettier --check"
]
},
"devDependencies": {
"@keplr-wallet/provider-mock": "^0.10.4",
"@types/ws": "^7.4.1",
"eventemitter3": "^4.0.7",
"ws": "^7.4.5"
},
"dependencies": {
"@cosmjs/launchpad": "^0.24.1",
"@keplr-wallet/common": "^0.10.4",
Expand Down
5 changes: 5 additions & 0 deletions packages/stores/src/__tests__/global-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { initLocalnet } from "./test-env";

module.exports = async () => {
await initLocalnet();
};
5 changes: 5 additions & 0 deletions packages/stores/src/__tests__/global-teardown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { removeLocalnet } from "./test-env";

module.exports = async () => {
await removeLocalnet();
};
253 changes: 253 additions & 0 deletions packages/stores/src/__tests__/test-env.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
import { deepContained } from "./test-env";

describe("Test test env", () => {
test("Test deep contain function", () => {
const obj1 = {
a: 2,
};

expect(() => {
deepContained(obj1, {
a: 2,
});
}).not.toThrow();

expect(() => {
deepContained(obj1, {
a: 3,
});
}).toThrow();

expect(() => {
deepContained(obj1, {
b: 2,
});
}).toThrow();
});

test("Test deep contain function nested", () => {
const obj2 = {
a: 1,
b: {
c: 2,
d: {
e: 3,
f: 4,
},
},
};

expect(() => {
deepContained(
{
a: 1,
},
obj2
);
}).not.toThrow();

expect(() => {
deepContained(
{
b: {
c: 2,
d: {
e: 3,
},
},
},
obj2
);
}).not.toThrow();

expect(() => {
deepContained(
{
b: {
c: 2,
d: {
e: 4,
},
},
},
obj2
);
}).toThrow();

expect(() => {
deepContained(
{
b: {
c: 2,
d: {
e: {
f: 4,
},
},
},
},
obj2
);
}).toThrow();
});

test("Test deep contain function with array", () => {
const obj2 = {
a: 1,
b: [2, 3, 4, 5],
};

expect(() => {
deepContained(
{
a: 1,
b: [2],
},
obj2
);
}).not.toThrow();

expect(() => {
deepContained(
{
b: [2, 3],
},
obj2
);
}).not.toThrow();

expect(() => {
deepContained(
{
b: [2, 3, 6],
},
obj2
);
}).toThrow();

expect(() => {
deepContained(
{
a: 1,
b: [6],
},
obj2
);
}).toThrow();

expect(() => {
deepContained(
{
a: 6,
b: [2, 3],
},
obj2
);
}).toThrow();
});

test("Test deep contain function with array (2)", () => {
const obj2 = {
a: 1,
b: [
{
c: {
d: 2,
},
},
{
c: {
e: 3,
},
},
{
f: {
g: 4,
},
},
],
};

expect(() => {
deepContained(
{
a: 1,
},
obj2
);
}).not.toThrow();

expect(() => {
deepContained(
{
b: [
{
c: {
d: 2,
},
},
],
},
obj2
);
}).not.toThrow();

expect(() => {
deepContained(
{
b: [
{
c: {
d: 2,
},
},
{
f: {
g: 4,
},
},
],
},
obj2
);
}).not.toThrow();

expect(() => {
deepContained(
{
b: [
{
c: {
d: 2,
},
},
{
f: {
g: 5,
},
},
],
},
obj2
);
}).toThrow();

expect(() => {
deepContained(
{
b: [
{
c: {
d: 2,
},
},
{
a: 1,
},
],
},
obj2
);
}).toThrow();
});
});
Loading

2 comments on commit fc757c5

@vercel
Copy link

@vercel vercel bot commented on fc757c5 Aug 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on fc757c5 Aug 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.