Skip to content

Commit

Permalink
indexer-common: Fix cost model syntax in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannis committed Jan 15, 2021
1 parent 6cb8731 commit 4dcb26e
Showing 1 changed file with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('Cost models', () => {
test('Set and get cost model (model and variables)', async () => {
const input = {
deployment: '0x0000000000000000000000000000000000000000000000000000000000000000',
model: '{ votes } => 10 * $n',
model: 'query { votes } => 10 * $n;',
variables: JSON.stringify({ n: 100 }),
}

Expand All @@ -116,7 +116,7 @@ describe('Cost models', () => {
test('Set and get cost model (model only)', async () => {
const input = {
deployment: '0x0000000000000000000000000000000000000000000000000000000000000000',
model: '{ votes } => 10 * $n',
model: 'query { votes } => 10 * $n;',
}

const expected = {
Expand Down Expand Up @@ -180,22 +180,22 @@ describe('Cost models', () => {
{
input: {
deployment,
model: '{ votes} => 10 * $n',
model: 'query { votes} => 10 * $n;',
},
expected: {
deployment,
model: '{ votes} => 10 * $n',
model: 'query { votes} => 10 * $n;',
variables: null,
},
},
{
input: {
deployment,
model: '{ votes} => 20 * $n',
model: 'query { votes} => 20 * $n;',
},
expected: {
deployment,
model: '{ votes} => 20 * $n',
model: 'query { votes} => 20 * $n;',
variables: null,
},
},
Expand All @@ -206,7 +206,7 @@ describe('Cost models', () => {
},
expected: {
deployment,
model: '{ votes} => 20 * $n',
model: 'query { votes} => 20 * $n;',
variables: JSON.stringify({ n: 1 }),
},
},
Expand All @@ -217,7 +217,7 @@ describe('Cost models', () => {
},
expected: {
deployment,
model: '{ votes} => 20 * $n',
model: 'query { votes} => 20 * $n;',
variables: JSON.stringify({ n: 2 }),
},
},
Expand Down Expand Up @@ -266,12 +266,12 @@ describe('Cost models', () => {
const inputs = [
{
deployment: '0x0000000000000000000000000000000000000000000000000000000000000000',
model: '{ votes } => 10 * $n',
model: 'query { votes } => 10 * $n;',
variables: JSON.stringify({ n: 100 }),
},
{
deployment: '0x1111111111111111111111111111111111111111111111111111111111111111',
model: '{ proposals } => 30 * $n',
model: 'query { proposals } => 30 * $n;',
variables: JSON.stringify({ n: 10 }),
},
]
Expand All @@ -296,16 +296,16 @@ describe('Cost models', () => {
}
})

test('Get all cost model', async () => {
test('Get all cost models', async () => {
const inputs = [
{
deployment: '0x0000000000000000000000000000000000000000000000000000000000000000',
model: '{ votes } => 10 * $n',
model: 'query { votes } => 10 * $n;',
variables: JSON.stringify({ n: 100 }),
},
{
deployment: '0x1111111111111111111111111111111111111111111111111111111111111111',
model: '{ proposals } => 30 * $n',
model: 'query { proposals } => 30 * $n;',
variables: JSON.stringify({ n: 10 }),
},
]
Expand All @@ -332,7 +332,7 @@ describe('Cost models', () => {
test('Clear model by passing in an empty model', async () => {
let input = {
deployment: '0x0000000000000000000000000000000000000000000000000000000000000000',
model: '{ votes } => 10 * $n',
model: 'query { votes } => 10 * $n',
variables: JSON.stringify({ n: 100 }),
}

Expand Down Expand Up @@ -377,7 +377,7 @@ describe('Feature: Inject $DAI variable', () => {

const initial = {
deployment: '0x0000000000000000000000000000000000000000000000000000000000000000',
model: '{ votes } => 10 * $n',
model: 'query { votes } => 10 * $n;',
variables: JSON.stringify({ DAI: '10.0' }),
}
await client.mutation(SET_COST_MODEL_MUTATION, { costModel: initial }).toPromise()
Expand All @@ -397,7 +397,7 @@ describe('Feature: Inject $DAI variable', () => {
test('$DAI variable can be overwritten', async () => {
const initial = {
deployment: '0x0000000000000000000000000000000000000000000000000000000000000000',
model: '{ votes } => 10 * $n',
model: 'query { votes } => 10 * $n;',
variables: JSON.stringify({ DAI: '10.0' }),
}
const client = await createIndexerManagementClient({
Expand All @@ -424,12 +424,12 @@ describe('Feature: Inject $DAI variable', () => {
const inputs = [
{
deployment: '0x0000000000000000000000000000000000000000000000000000000000000000',
model: '{ votes } => 10 * $n',
model: 'query { votes } => 10 * $n;',
variables: JSON.stringify({ n: 100, DAI: '10.0' }),
},
{
deployment: '0x1111111111111111111111111111111111111111111111111111111111111111',
model: '{ proposals } => 30 * $n',
model: 'query { proposals } => 30 * $n;',
variables: JSON.stringify({ n: 10 }),
},
]
Expand Down Expand Up @@ -472,12 +472,12 @@ describe('Feature: Inject $DAI variable', () => {
const inputs = [
{
deployment: '0x0000000000000000000000000000000000000000000000000000000000000000',
model: '{ votes } => 10 * $n',
model: 'query { votes } => 10 * $n;',
variables: JSON.stringify({ n: 100, DAI: '10.0' }),
},
{
deployment: '0x1111111111111111111111111111111111111111111111111111111111111111',
model: '{ proposals } => 30 * $n',
model: 'query { proposals } => 30 * $n;',
variables: JSON.stringify({ n: 10 }),
},
]
Expand Down Expand Up @@ -521,7 +521,7 @@ describe('Feature: Inject $DAI variable', () => {
test('$DAI is preserved when cost model is updated', async () => {
const initial = {
deployment: '0x0000000000000000000000000000000000000000000000000000000000000000',
model: '{ votes } => 10 * $n',
model: 'query { votes } => 10 * $n;',
variables: JSON.stringify({ n: 5, DAI: '10.0' }),
}
const client = await createIndexerManagementClient({
Expand Down Expand Up @@ -555,7 +555,7 @@ describe('Feature: Inject $DAI variable', () => {
test('If feature is disabled, $DAI variable is not preserved', async () => {
const initial = {
deployment: '0x0000000000000000000000000000000000000000000000000000000000000000',
model: '{ votes } => 10 * $n',
model: 'query { votes } => 10 * $n;',
variables: JSON.stringify({ DAI: '10.0' }),
}
const client = await createIndexerManagementClient({
Expand Down

0 comments on commit 4dcb26e

Please sign in to comment.