Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat / local decimal supporting bigint and options to use agoric-sdk or cosmjs #653

Merged
merged 11 commits into from
Sep 14, 2024
138 changes: 70 additions & 68 deletions packages/telescope/__tests__/misc.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { TelescopeBuilder } from "../src/builder";
import { TelescopeOptions } from "@cosmology/types";
import { TelescopeInput } from "../src";
import deepmerge from "deepmerge";
import { TelescopeBuilder } from '../src/builder';
import { TelescopeOptions } from '@cosmology/types';
import { TelescopeInput } from '../src';
import deepmerge from 'deepmerge';

const outPath = __dirname + "/../../../__fixtures__/misc/output";
const outPath = __dirname + '/../../../__fixtures__/misc/output';

const options: TelescopeOptions = {
env: "v-next",
env: 'v-next',
removeUnusedImports: false,
classesUseArrowFunctions: false,

Expand All @@ -20,7 +20,7 @@ const options: TelescopeOptions = {

excluded: {
// hard exclude faulty proto files
hardProtos: ["google/api/expr/v1alpha1/eval1.proto"],
hardProtos: ['google/api/expr/v1alpha1/eval1.proto'],
},

parser: {
Expand Down Expand Up @@ -48,12 +48,14 @@ const options: TelescopeOptions = {
typingsFormat: {
customTypes: {
useCosmosSDKDec: true,
// default uses cosmjs/math Decimals, undefined uses agoric-sdk
useAgoricDecimal: 'default',
},
j-yw marked this conversation as resolved.
Show resolved Hide resolved
num64: "bigint",
num64: 'bigint',
useDeepPartial: true,
useExact: false,
timestamp: "date",
duration: "duration",
timestamp: 'date',
duration: 'duration',
},
},

Expand All @@ -76,11 +78,11 @@ const options: TelescopeOptions = {
camelCase: true,
scopedIsExclusive: false,
enabledServices: [
"Msg",
"Query",
"Service",
"ReflectionService",
"ABCIApplication",
'Msg',
'Query',
'Service',
'ReflectionService',
'ABCIApplication',
],
},

Expand All @@ -105,23 +107,23 @@ const options: TelescopeOptions = {

const input: TelescopeInput = {
outPath,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options,
};

describe("misc", () => {
it("generates", async () => {
describe('misc', () => {
it('generates', async () => {
const telescope = new TelescopeBuilder(input);

await telescope.build();
});

it("generates without amino", async () => {
const testFolder = "/output-proto-amino/no-amino";
it('generates without amino', async () => {
const testFolder = '/output-proto-amino/no-amino';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
prototypes: {
methods: {
Expand All @@ -141,12 +143,12 @@ describe("misc", () => {
await telescope.build();
});

it("generates without amino, no proto", async () => {
const testFolder = "/output-proto-amino/no-amino-no-proto";
it('generates without amino, no proto', async () => {
const testFolder = '/output-proto-amino/no-amino-no-proto';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
prototypes: {
methods: {
Expand All @@ -166,12 +168,12 @@ describe("misc", () => {
await telescope.build();
});

it("generates amino legacy", async () => {
const testFolder = "/output-proto-amino/amino-legacy";
it('generates amino legacy', async () => {
const testFolder = '/output-proto-amino/amino-legacy';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
prototypes: {
methods: {
Expand All @@ -194,12 +196,12 @@ describe("misc", () => {
await telescope.build();
});

it("generates without amino but legacy", async () => {
const testFolder = "/output-proto-amino/no-amino-legacy";
it('generates without amino but legacy', async () => {
const testFolder = '/output-proto-amino/no-amino-legacy';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
prototypes: {
methods: {
Expand All @@ -219,12 +221,12 @@ describe("misc", () => {
await telescope.build();
});

it("generates without amino but legacy, no proto", async () => {
const testFolder = "/output-proto-amino/no-amino-legacy-no-proto";
it('generates without amino but legacy, no proto', async () => {
const testFolder = '/output-proto-amino/no-amino-legacy-no-proto';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
prototypes: {
methods: {
Expand All @@ -244,12 +246,12 @@ describe("misc", () => {
await telescope.build();
});

it("generates, proto only", async () => {
const testFolder = "/output-proto-amino/proto-only";
it('generates, proto only', async () => {
const testFolder = '/output-proto-amino/proto-only';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
prototypes: {
methods: {
Expand All @@ -269,12 +271,12 @@ describe("misc", () => {
await telescope.build();
});

it("generates, proto only, legacy", async () => {
const testFolder = "/output-proto-amino/proto-only-legacy";
it('generates, proto only, legacy', async () => {
const testFolder = '/output-proto-amino/proto-only-legacy';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
prototypes: {
methods: {
Expand All @@ -294,12 +296,12 @@ describe("misc", () => {
await telescope.build();
});

it("generates amino, useMsgTypes, with amino func", async () => {
const testFolder = "/output-proto-amino/amino-msg-with-func";
it('generates amino, useMsgTypes, with amino func', async () => {
const testFolder = '/output-proto-amino/amino-msg-with-func';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
prototypes: {
methods: {
Expand All @@ -309,8 +311,8 @@ describe("misc", () => {
fromProto: true,
},
typingsFormat: {
autoFixUndefinedEnumDefault: true
}
autoFixUndefinedEnumDefault: true,
},
},
aminoEncoding: {
enabled: true,
Expand All @@ -322,12 +324,12 @@ describe("misc", () => {
await telescope.build();
});

it("generates amino, useMsgTypes, no amino func", async () => {
const testFolder = "/output-proto-amino/amino-msg-no-func";
it('generates amino, useMsgTypes, no amino func', async () => {
const testFolder = '/output-proto-amino/amino-msg-no-func';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
prototypes: {
methods: {
Expand All @@ -347,12 +349,12 @@ describe("misc", () => {
await telescope.build();
});

it("generates amino, no useMsgTypes, with amino func", async () => {
const testFolder = "/output-proto-amino/amino-no-msg-with-func";
it('generates amino, no useMsgTypes, with amino func', async () => {
const testFolder = '/output-proto-amino/amino-no-msg-with-func';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
prototypes: {
methods: {
Expand All @@ -373,12 +375,12 @@ describe("misc", () => {
await telescope.build();
});

it("generates with amino interface", async () => {
const testFolder = "/output-proto-amino/amino-interface";
it('generates with amino interface', async () => {
const testFolder = '/output-proto-amino/amino-interface';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
interfaces: {
enabled: true,
Expand All @@ -403,12 +405,12 @@ describe("misc", () => {
await telescope.build();
});

it("generates with amino interface and proto optionality", async () => {
const testFolder = "/output-proto-amino/amino-interface-proto-optionality";
it('generates with amino interface and proto optionality', async () => {
const testFolder = '/output-proto-amino/amino-interface-proto-optionality';

const telescope = new TelescopeBuilder({
outPath: __dirname + "/../../../__fixtures__/misc" + testFolder,
protoDirs: [__dirname + "/../../../__fixtures__/misc/proto"],
outPath: __dirname + '/../../../__fixtures__/misc' + testFolder,
protoDirs: [__dirname + '/../../../__fixtures__/misc/proto'],
options: deepmerge(options, {
interfaces: {
enabled: true,
Expand Down
Loading
Loading