Skip to content

Commit

Permalink
fix: save again
Browse files Browse the repository at this point in the history
  • Loading branch information
cgilbe27 committed Feb 3, 2024
1 parent d51c3a8 commit e1e09f1
Show file tree
Hide file tree
Showing 12 changed files with 416 additions and 109 deletions.
8 changes: 4 additions & 4 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const config: Config = {
coverageReporters: ["json-summary", "text", "html", "lcov"],
coverageThreshold: {
global: {
branches: 75,
functions: 75,
lines: 75,
statements: 75,
branches: 90,
functions: 90,
lines: 90,
statements: 90,
},
},
globals: {
Expand Down
132 changes: 94 additions & 38 deletions src/gql/heart-monitor/heart-monitor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ import {
GQLUnbonding,
GQLUser,
GQLValidator,
InflationFields,
QueryInflationArgs,
defaultInflationInfo,
defaultInflationDistribution,
GQLFeatureFlags,
defaultFeatureFlags,
} from ".."

const nibiruUrl = "devnet-2"
Expand Down Expand Up @@ -180,51 +186,22 @@ test("distributionCommissions", async () => {
await testDistributionCommissions({}, defaultDistributionCommission)
})

const testIbc = async (args: QueryIbcArgs, fields?: IbcFields) => {
const resp = await heartMonitor.ibc(args, fields)
expect(resp).toHaveProperty("ibc")
const testfeatureFlags = async (fields?: GQLFeatureFlags) => {
const resp = await heartMonitor.featureFlags(fields)
expect(resp).toHaveProperty("featureFlags")

if (resp.ibc) {
const { ibc } = resp
if (resp.featureFlags) {
const { featureFlags } = resp

checkFields(
[ibc],
[...(args.ibcChannels ? ["ibcChannels"] : []), "ibcTransfers"]
[featureFlags],
["gov", "oracle", "perp", "spot", "staking", "wasm"]
)
}
}

test("ibc", async () => {
await testIbc({
ibcTransfers: {
limit: 1,
},
})
await testIbc({
ibcChannels: undefined,
ibcTransfers: {
limit: 1,
},
})
await testIbc(
{
ibcChannels: undefined,
ibcTransfers: {
limit: 1,
},
},
{
ibcChannels: defaultIbcChannelsResponse,
ibcTransfers: defaultIbcTransfer,
}
)
await testIbc(
{},
{
ibcChannels: defaultIbcChannelsResponse,
ibcTransfers: defaultIbcTransfer,
}
)
test("featureFlags", async () => {
await testfeatureFlags(defaultFeatureFlags)
})

const testGovernance = async (
Expand Down Expand Up @@ -284,6 +261,85 @@ test("governance", async () => {
)
})

const testIbc = async (args: QueryIbcArgs, fields?: IbcFields) => {
const resp = await heartMonitor.ibc(args, fields)
expect(resp).toHaveProperty("ibc")

if (resp.ibc) {
const { ibc } = resp

checkFields(
[ibc],
[...(args.ibcChannels ? ["ibcChannels"] : []), "ibcTransfers"]
)
}
}

test("ibc", async () => {
await testIbc({
ibcTransfers: {
limit: 1,
},
})
await testIbc({
ibcChannels: undefined,
ibcTransfers: {
limit: 1,
},
})
await testIbc(
{
ibcChannels: undefined,
ibcTransfers: {
limit: 1,
},
},
{
ibcChannels: defaultIbcChannelsResponse,
ibcTransfers: defaultIbcTransfer,
}
)
await testIbc(
{},
{
ibcChannels: defaultIbcChannelsResponse,
ibcTransfers: defaultIbcTransfer,
}
)
})

const testInflation = async (
args: QueryInflationArgs,
fields?: InflationFields
) => {
const resp = await heartMonitor.inflation(args, fields)
expect(resp).toHaveProperty("inflation")

if (resp.inflation) {
const { inflation } = resp

checkFields([inflation], ["distributions", "inflations"])
}
}

test("inflation", async () => {
await testInflation({
inflations: {
limit: 1,
},
distributions: {
limit: 1,
},
})
await testInflation(
{},
{
inflations: defaultInflationInfo,
distributions: defaultInflationDistribution,
}
)
})

const testMarkPriceCandles = async (
args: GQLQueryGqlMarkPriceCandlesArgs,
fields?: GQLMarkPriceCandle
Expand Down
Loading

0 comments on commit e1e09f1

Please sign in to comment.