UNPKG

@cosmology/ast

Version:
201 lines (198 loc) 12 kB
"use strict"; var _object = require("./object"); var _protoParser = require("@cosmology/proto-parser"); var _utils = require("@cosmology/utils"); var _context = require("./context"); var _proto = require("./proto"); var _testUtils = require("../../test-utils"); var store = (0, _testUtils.getTestProtoStore)(); describe('osmosis/gamm/v1beta1/tx', function () { var ref = store.findProto('osmosis/gamm/v1beta1/tx.proto'); var res = (0, _protoParser.traverse)(store, ref); it('MsgJoinPool', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'MsgJoinPool', (0, _utils.getNestedProto)(res).MsgJoinPool)); }); it('MsgSwapExactAmountOut', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'MsgSwapExactAmountOut', (0, _utils.getNestedProto)(res).MsgSwapExactAmountOut)); }); it('MsgSwapExactAmountIn', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'MsgSwapExactAmountIn', (0, _utils.getNestedProto)(res).MsgSwapExactAmountIn)); }); }); describe('google/api/expr/conformance/v1alpha1/conformance_service', function () { var ref = store.findProto('google/api/expr/conformance/v1alpha1/conformance_service.proto'); var res = (0, _protoParser.traverse)(store, ref); it('ParseRequest', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'ParseRequest', (0, _utils.getNestedProto)(res).ParseRequest)); }); }); describe('google/api/servicecontrol/v1/log_entry', function () { var ref = store.findProto('google/api/servicecontrol/v1/log_entry.proto'); var res = (0, _protoParser.traverse)(store, ref); it('LogEntry', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'LogEntry', (0, _utils.getNestedProto)(res).LogEntry)); }); }); describe('google/api/expr/v1alpha1/syntax', function () { var ref = store.findProto('google/api/expr/v1alpha1/syntax.proto'); var res = (0, _protoParser.traverse)(store, ref); it('Constant', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'Constant', (0, _utils.getNestedProto)(res).Constant)); }); }); describe('google/api/expr/v1alpha1/value', function () { var ref = store.findProto('google/api/expr/v1alpha1/value.proto'); var res = (0, _protoParser.traverse)(store, ref); it('MapValue', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'MapValue', (0, _utils.getNestedProto)(res).MapValue)); expect(context.imports).toMatchSnapshot(); }); it('Entry', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'Entry', (0, _utils.getNestedProto)(res).MapValue.nested.Entry)); expect(context.imports).toMatchSnapshot(); }); }); describe('cosmos/tx/signing/v1beta1/signing', function () { var ref = store.findProto('cosmos/tx/signing/v1beta1/signing.proto'); var res = (0, _protoParser.traverse)(store, ref); it('SignatureDescriptors', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'SignatureDescriptors', (0, _utils.getNestedProto)(res).SignatureDescriptors)); }); it('SignatureDescriptor', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'SignatureDescriptor', (0, _utils.getNestedProto)(res).SignatureDescriptor)); }); }); describe('cosmos/tx/v1beta1/tx', function () { var ref = store.findProto('cosmos/tx/v1beta1/tx.proto'); var res = (0, _protoParser.traverse)(store, ref); it('AuxSignerData', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'AuxSignerData', (0, _utils.getNestedProto)(res).AuxSignerData)); }); it('ModeInfo_Multi', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'ModeInfo_Multi', (0, _utils.getNestedProto)(res).ModeInfo)); }); }); describe('cosmos/staking/v1beta1', function () { var ref = store.findProto('cosmos/staking/v1beta1/staking.proto'); var res = (0, _protoParser.traverse)(store, ref); it('Delegation', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); context.options.prototypes.typingsFormat.customTypes.useCosmosSDKDec = true; (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'Delegation', (0, _utils.getNestedProto)(res).Delegation)); }); }); describe('google/api/expr/v1alpha1/checked', function () { var ref = store.findProto('google/api/expr/v1alpha1/checked.proto'); var res = (0, _protoParser.traverse)(store, ref); it('Type', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'Type', (0, _utils.getNestedProto)(res).Type)); }); describe('nested', function () { it('MapType', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'Type_MapType', (0, _utils.getNestedProto)(res).Type.nested.MapType)); }); }); describe('Decl_FunctionDecl_Overload', function () { it('MapType', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'Decl_FunctionDecl_Overload', (0, _utils.getNestedProto)(res).Decl.nested.FunctionDecl.nested.Overload)); }); }); describe('typeHash (Long)', function () { it('CheckedExpr', function () { var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'CheckedExpr', (0, _utils.getNestedProto)(res).CheckedExpr)); }); }); }); it('google/api/expr/v1beta1/source', function () { var ref = store.findProto('google/api/expr/v1beta1/source.proto'); var res = (0, _protoParser.traverse)(store, ref); var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'SourceInfo', (0, _utils.getNestedProto)(res).SourceInfo)); }); it('cosmwasm/wasm/v1/proposal', function () { var ref = store.findProto('cosmwasm/wasm/v1/proposal.proto'); var res = (0, _protoParser.traverse)(store, ref); var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'PinCodesProposal', (0, _utils.getNestedProto)(res).PinCodesProposal)); }); it('cosmwasm/wasm/v1/proposal', function () { var ref = store.findProto('cosmwasm/wasm/v1/proposal.proto'); var res = (0, _protoParser.traverse)(store, ref); var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'UnpinCodesProposal', (0, _utils.getNestedProto)(res).UnpinCodesProposal)); }); it('cosmwasm/wasm/v1/query', function () { var ref = store.findProto('cosmwasm/wasm/v1/query.proto'); var res = (0, _protoParser.traverse)(store, ref); var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'QueryRawContractStateRequest', (0, _utils.getNestedProto)(res).QueryRawContractStateRequest)); }); it('ibc/core/port/v1/query', function () { var ref = store.findProto('ibc/core/port/v1/query.proto'); var res = (0, _protoParser.traverse)(store, ref); var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'QueryAppVersionRequest', (0, _utils.getNestedProto)(res).QueryAppVersionRequest)); expect(context.imports).toMatchSnapshot(); // console.log(context.imports); }); describe('google/api/quota', function () { it('keyType', function () { var ref = store.findProto('google/api/quota.proto'); var res = (0, _protoParser.traverse)(store, ref); var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'MetricRule', (0, _utils.getNestedProto)(res).MetricRule)); expect(context.imports).toMatchSnapshot(); // console.log(context.imports); }); }); describe('ibc/core/types/v1/genesis', function () { it('name collisions', function () { store.traverseAll(); var ref = store.findProto('ibc/core/types/v1/genesis.proto'); var res = (0, _protoParser.traverse)(store, ref); var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); var ast = (0, _proto.createProtoType)(context, 'GenesisState', (0, _utils.getNestedProto)(res).GenesisState); (0, _testUtils.expectCode)(ast); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'GenesisState', (0, _utils.getNestedProto)(res).GenesisState)); expect(context.imports).toMatchSnapshot(); }); }); describe('google/rpc/error_details', function () { it('name collisions', function () { store.traverseAll(); var ref = store.findProto('google/rpc/error_details.proto'); var res = (0, _protoParser.traverse)(store, ref); var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); var ast = (0, _proto.createProtoType)(context, 'PreconditionFailure', (0, _utils.getNestedProto)(res).PreconditionFailure); (0, _testUtils.expectCode)(ast); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'PreconditionFailure', (0, _utils.getNestedProto)(res).PreconditionFailure)); }); }); it('evmos/fees/v1/tx', function () { var ref = store.findProto('evmos/fees/v1/tx.proto'); var res = (0, _protoParser.traverse)(store, ref); var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'MsgRegisterDevFeeInfo', (0, _utils.getNestedProto)(res).MsgRegisterDevFeeInfo)); }); it('osmosis/gamm/v1beta1/query', function () { var ref = store.findProto('osmosis/gamm/v1beta1/query.proto'); var res = (0, _protoParser.traverse)(store, ref); var context = new _context.ProtoParseContext(ref, store, _testUtils.defaultTelescopeOptions); (0, _testUtils.expectCode)((0, _object.createObjectWithMethods)(context, 'QueryPoolsResponse', (0, _utils.getNestedProto)(res).QueryPoolsResponse)); });