Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramation committed Apr 13, 2024
1 parent a5d32f0 commit 7585a92
Show file tree
Hide file tree
Showing 9 changed files with 1,600 additions and 756 deletions.
460 changes: 460 additions & 0 deletions __fixtures__/schemas/assetlist.json

Large diffs are not rendered by default.

714 changes: 714 additions & 0 deletions __fixtures__/schemas/chain.json

Large diffs are not rendered by default.

183 changes: 183 additions & 0 deletions __fixtures__/schemas/ibc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"required": [
"chain_1",
"chain_2",
"channels"
],
"properties": {
"$schema": {
"type": "string",
"pattern": "^(\\.\\./)+ibc_data\\.schema\\.json$"
},
"chain_1": {
"type": "object",
"$ref": "#/$defs/chain_info"
},
"chain_2": {
"type": "object",
"$ref": "#/$defs/chain_info"
},
"channels": {
"type": "array",
"items": {
"type": "object",
"required": [
"chain_1",
"chain_2",
"ordering",
"version"
],
"properties": {
"chain_1": {
"type": "object",
"$ref": "#/$defs/channel_info"
},
"chain_2": {
"type": "object",
"$ref": "#/$defs/channel_info"
},
"ordering": {
"enum": [
"ordered",
"unordered"
],
"description": "Determines if packets from a sending module must be 'ordered' or 'unordered'."
},
"version": {
"type": "string",
"description": "IBC Version"
},
"fee_version": {
"type": "string",
"description": "Fee Version"
},
"description": {
"type": "string",
"description": "Human readable description of the channel."
},
"tags": {
"type": "object",
"description": "Human readable key:value pairs that help describe and distinguish channels.",
"properties": {
"status": {
"enum": [
"live",
"upcoming",
"killed"
]
},
"preferred": {
"type": "boolean"
},
"dex": {
"type": "string"
},
"properties": {
"type": "string",
"description": "String that helps describe non-dex use cases ex: interchain accounts(ICA)."
}
},
"additionalProperties": true
}
},
"additionalProperties": false
}
},
"operators": {
"type": "array",
"description": "ibc connection operator information.",
"items": {
"type": "object",
"required": [
"chain_1",
"chain_2",
"memo",
"name"
],
"properties": {
"chain_1": {
"type": "object",
"$ref": "#/$defs/chain_operator_info"
},
"chain_2": {
"type": "object",
"$ref": "#/$defs/chain_operator_info"
},
"memo": {
"type": "string"
},
"name": {
"type": "string",
"description": "Operator display name"
},
"discord_handle": {
"type": "string"
}
}
}
}
},
"additionalProperties": false,
"$defs": {
"chain_operator_info": {
"type": "object",
"description": "Operator information on a specific chain.",
"properties": {
"address": {
"type": "string"
}
}
},
"chain_info": {
"type": "object",
"description": "Top level IBC data pertaining to the chain. `chain_1` and `chain_2` should be in alphabetical order.",
"required": [
"chain_name",
"client_id",
"connection_id"
],
"properties": {
"chain_name": {
"type": "string"
},
"client_id": {
"type": "string",
"description": "The client ID on the corresponding chain representing the other chain's light client."
},
"connection_id": {
"type": "string",
"description": "The connection ID on the corresponding chain representing a connection to the other chain."
}
},
"additionalProperties": false
},
"channel_info": {
"type": "object",
"required": [
"channel_id",
"port_id"
],
"properties": {
"channel_id": {
"type": "string",
"description": "The channel ID on the corresponding chain's connection representing a channel on the other chain."
},
"port_id": {
"type": "string",
"description": "The IBC port ID which a relevant module binds to on the corresponding chain."
},
"client_id": {
"type": "string",
"description": "Optional. The client ID on the corresponding chain representing the other chain's light client."
},
"connection_id": {
"type": "string",
"description": "Optional. The connection ID on the corresponding chain representing a connection to the other chain."
}
},
"additionalProperties": false
}
}
}
42 changes: 42 additions & 0 deletions __fixtures__/schemas/memo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"required": [
"memo_keys"
],
"properties": {
"$schema": {
"type": "string",
"pattern": "^(\\.\\./)+memo_keys\\.schema\\.json$"
},
"memo_keys": {
"type": "array",
"items": {
"type": "object",
"required": [
"key",
"description",
"git_repo",
"memo"
],
"properties": {
"key": {
"type": "string"
},
"description": {
"type": "string"
},
"git_repo": {
"type": "string",
"format": "uri"
},
"memo": {
"type": "object"
}
},
"additionalProperties": true
}
}
},
"additionalProperties": false
}
94 changes: 94 additions & 0 deletions __tests__/__snapshots__/assetlist.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`assetlist 1`] = `
"interface Asset {
deprecated?: boolean;
description?: string;
extended_description?: string;
denom_units: Denomunit[];
type_asset?: string;
address?: string;
base: string;
name: string;
display: string;
symbol: string;
traces?: any[];
ibc?: {
source_channel: string;
dst_channel: string;
source_denom: string;
};
logo_URIs?: {
png?: string;
svg?: string;
};
images?: {
image_sync?: Pointer;
png?: string;
svg?: string;
theme?: {
primary_color_hex?: string;
circle?: boolean;
dark_mode?: boolean;
};
}[];
coingecko_id?: string;
keywords?: string[];
socials?: {
website?: string;
twitter?: string;
};
}
interface Denomunit {
denom: string;
exponent: number;
aliases?: string[];
}
interface Pointer {
chain_name: string;
base_denom?: string;
}
interface Ibctransition {
type: string;
counterparty: {
chain_name: string;
base_denom: string;
channel_id: string;
};
chain: {
channel_id: string;
path: string;
};
}
interface Ibccw20transition {
type: string;
counterparty: {
chain_name: string;
base_denom: string;
port: string;
channel_id: string;
};
chain: {
port: string;
channel_id: string;
path: string;
};
}
interface Nonibctransition {
type: string;
counterparty: {
chain_name: string;
base_denom: string;
contract?: string;
};
chain?: {
contract: string;
};
provider: string;
}
interface Asset Lists {
$schema?: string;
chain_name: string;
assets: Asset[];
}"
`;
30 changes: 15 additions & 15 deletions __tests__/__snapshots__/chain.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`works 1`] = `
exports[`chain 1`] = `
"interface Peer {
id: string;
address: string;
Expand Down Expand Up @@ -75,12 +75,12 @@ interface Cosmos Chain {
go_version?: string;
compatible_versions?: string[];
binaries?: {
"\\"linux/amd64\\""?: string;
"\\"linux/arm64\\""?: string;
"\\"darwin/amd64\\""?: string;
"\\"darwin/arm64\\""?: string;
"\\"windows/amd64\\""?: string;
"\\"windows/arm64\\""?: string;
"'linux/amd64'"?: string;
"'linux/arm64'"?: string;
"'darwin/amd64'"?: string;
"'darwin/arm64'"?: string;
"'windows/amd64'"?: string;
"'windows/arm64'"?: string;
};
cosmos_sdk_version?: string;
consensus?: {
Expand Down Expand Up @@ -118,12 +118,12 @@ interface Cosmos Chain {
ibc_go_version?: string;
ics_enabled?: string[];
binaries?: {
"\\"linux/amd64\\""?: string;
"\\"linux/arm64\\""?: string;
"\\"darwin/amd64\\""?: string;
"\\"darwin/arm64\\""?: string;
"\\"windows/amd64\\""?: string;
"\\"windows/arm64\\""?: string;
"'linux/amd64'"?: string;
"'linux/arm64'"?: string;
"'darwin/amd64'"?: string;
"'darwin/arm64'"?: string;
"'windows/amd64'"?: string;
"'windows/arm64'"?: string;
};
}[];
};
Expand Down Expand Up @@ -153,8 +153,8 @@ interface Cosmos Chain {
rest?: Endpoint[];
grpc?: Endpoint[];
wss?: Endpoint[];
"\\"grpc-web\\""?: Endpoint[];
"\\"evm-http-jsonrpc\\""?: Endpoint[];
"'grpc-web'"?: Endpoint[];
"'evm-http-jsonrpc'"?: Endpoint[];
};
explorers?: Explorer[];
keywords?: string[];
Expand Down
5 changes: 5 additions & 0 deletions __tests__/assetlist.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import assetlist from '../__fixtures__/schemas/assetlist.json';
import { generateTypeScript } from '../src';
it('assetlist', () => {
expect(generateTypeScript(assetlist as any)).toMatchSnapshot();
});
Loading

0 comments on commit 7585a92

Please sign in to comment.