Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
chore(tests): add sortKey checks in all evaluation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Nov 30, 2023
1 parent 754d20b commit c52bfbe
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 44 deletions.
67 changes: 36 additions & 31 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ openapi: 3.0.0
info:
title: ArNS Microservice
version: 0.1.0
description: A koa microservice that provides API interface for fetching and retrieving ArNS related Smartweave contracts.

description: A koa microservice that provides API interface for fetching and retrieving ArNS related Smartweave contracts.
servers:
- url: '/v1'

Expand Down Expand Up @@ -39,29 +38,21 @@ components:
properties:
sourceType:
type: string
enum: ['arweave', 'otherSource']
description: The source type of the evaluation.
enum: ['arweave', 'other']
internalWrites:
type: boolean
description: Flag to enable or disable internal writes.
useKVStorage:
type: boolean
description: Indicates if key-value storage is used.
remoteStateSyncEnabled:
type: boolean
description: Flag for enabling remote state synchronization.
waitForConfirmation:
type: boolean
description: Whether to wait for confirmation before proceeding.
updateCacheForEachInteraction:
type: boolean
description: Specifies if the cache should be updated for each interaction.
maxInteractionEvaluationTimeSeconds:
type: integer
description: The maximum time in seconds for interaction evaluation.
throwOnInternalWriteError:
type: boolean
description: Indicates if an error should be thrown on internal write failure.

ContractInteraction:
type: array
Expand Down Expand Up @@ -96,17 +87,15 @@ paths:
- in: query
name: blockHeight
required: false
description: Evaluate the contract up to a specific block height.
description: Evaluate the contract up to a specific block height. Only applicable if sortKey is not provided.
schema:
type: number
example: 1307087
- in: query
name: sortKey
required: false
description: Evaluate the contract at up to a specific sort key.
description: Evaluate the contract at up to a specific sort key. Only applicable if blockHeight is not provided.
schema:
type: string
example: 000001307087,0000000000000,0cbe0824cdf7ba421c49d08ebf6cd0957d0396da8ebe78107a37baa31ed5bbe4
responses:
'200':
description: OK
Expand Down Expand Up @@ -269,17 +258,15 @@ paths:
- in: query
name: blockHeight
required: false
description: Evaluate the contract up to a specific block height.
description: Evaluate the contract up to a specific block height. Only applicable if sortKey is not provided.
schema:
type: number
example: 1307087
- in: query
name: sortKey
required: false
description: Evaluate the contract at up to a specific sort key.
description: Evaluate the contract at up to a specific sort key. Only applicable if blockHeight is not provided.
schema:
type: string
example: 000001307087,0000000000000,0cbe0824cdf7ba421c49d08ebf6cd0957d0396da8ebe78107a37baa31ed5bbe4
responses:
'200':
description: OK
Expand Down Expand Up @@ -325,17 +312,15 @@ paths:
- in: query
name: blockHeight
required: false
description: Evaluate the contract up to a specific block height.
description: Evaluate the contract up to a specific block height. Only applicable if sortKey is not provided.
schema:
type: number
example: 1307087
- in: query
name: sortKey
required: false
description: Evaluate the contract at up to a specific sort key.
description: Evaluate the contract at up to a specific sort key. Only applicable if blockHeight is not provided.
schema:
type: string
example: 000001307087,0000000000000,0cbe0824cdf7ba421c49d08ebf6cd0957d0396da8ebe78107a37baa31ed5bbe4
responses:
'200':
description: OK
Expand Down Expand Up @@ -396,6 +381,18 @@ paths:
schema:
type: string
example: 'ario'
- in: query
name: blockHeight
required: false
description: Evaluate the contract up to a specific block height. Only applicable if sortKey is not provided.
schema:
type: number
- in: query
name: sortKey
required: false
description: Evaluate the contract at up to a specific sort key. Only applicable if blockHeight is not provided.
schema:
type: string
responses:
'200':
description: OK
Expand Down Expand Up @@ -462,17 +459,15 @@ paths:
- in: query
name: blockHeight
required: false
description: Evaluate the contract up to a specific block height.
description: Evaluate the contract up to a specific block height. Only applicable if sortKey is not provided.
schema:
type: number
example: 1307087
- in: query
name: sortKey
required: false
description: Evaluate the contract at up to a specific sort key.
description: Evaluate the contract at up to a specific sort key. Only applicable if blockHeight is not provided.
schema:
type: string
example: 000001307087,0000000000000,0cbe0824cdf7ba421c49d08ebf6cd0957d0396da8ebe78107a37baa31ed5bbe4
responses:
'200':
description: OK
Expand Down Expand Up @@ -515,17 +510,15 @@ paths:
- in: query
name: blockHeight
required: false
description: Evaluate the contract up to a specific block height.
description: Evaluate the contract up to a specific block height. Only applicable if sortKey is not provided.
schema:
type: number
example: 1307087
- in: query
name: sortKey
required: false
description: Evaluate the contract at up to a specific sort key.
description: Evaluate the contract at up to a specific sort key. Only applicable if blockHeight is not provided.
schema:
type: string
example: 000001307087,0000000000000,0cbe0824cdf7ba421c49d08ebf6cd0957d0396da8ebe78107a37baa31ed5bbe4
responses:
'200':
description: OK
Expand Down Expand Up @@ -569,6 +562,18 @@ paths:
schema:
type: string
example: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ'
- in: query
name: blockHeight
required: false
description: Evaluate the contract up to a specific block height. Only applicable if sortKey is not provided.
schema:
type: number
- in: query
name: sortKey
required: false
description: Evaluate the contract at up to a specific sort key. Only applicable if blockHeight is not provided.
schema:
type: string
responses:
'200':
description: OK
Expand Down
51 changes: 38 additions & 13 deletions tests/integration/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId, interactions } = data;
const { contractTxId, interactions, sortKey } = data;
expect(contractTxId).to.equal(id);
expect(sortKey).not.be.undefined;
expect(interactions).to.deep.equal(contractInteractions);
});

Expand All @@ -251,8 +252,9 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId, interactions } = data;
const { contractTxId, interactions, sortKey } = data;
expect(contractTxId).to.equal(id);
expect(sortKey).not.be.undefined;
expect(Object.keys(interactions)).not.to.contain(badInteractionTx.id);
});

Expand All @@ -265,8 +267,9 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId, interactions } = data;
const { contractTxId, interactions, sortKey } = data;
expect(contractTxId).to.equal(id);
expect(sortKey).not.be.undefined;
expect(interactions).to.deep.equal([]);
});

Expand All @@ -277,8 +280,9 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId, interactions } = data;
const { contractTxId, interactions, sortKey } = data;
expect(contractTxId).to.equal(id);
expect(sortKey).to.equal(knownSortKey);
expect(interactions).to.deep.equal([contractInteractions[0]]);
});
});
Expand All @@ -290,8 +294,9 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId, interactions } = data;
const { contractTxId, interactions, sortKey } = data;
expect(contractTxId).to.equal(id);
expect(sortKey).not.be.undefined;
// TODO: filter out interactions specific to the wallet address
expect(interactions).to.deep.equal(contractInteractions);
});
Expand All @@ -314,8 +319,9 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId } = data;
const { contractTxId, sortKey } = data;
expect(contractTxId).to.equal(id);
expect(sortKey).not.be.undefined;
expect(data[field]).to.not.be.undefined; // we haven't created any interactions
});
}
Expand All @@ -334,8 +340,9 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId } = data;
const { contractTxId, sortKey } = data;
expect(contractTxId).to.equal(id);
expect(sortKey).not.be.undefined;
expect(Object.keys(data['records'])).to.have.length(2);
});

Expand All @@ -345,8 +352,9 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId } = data;
const { contractTxId, sortKey } = data;
expect(contractTxId).to.equal(id);
expect(sortKey).not.be.undefined;
expect(Object.keys(data['records'])).to.have.length(1);
});

Expand All @@ -356,8 +364,9 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId } = data;
const { contractTxId, sortKey } = data;
expect(contractTxId).to.equal(id);
expect(sortKey).not.be.undefined;
expect(Object.keys(data['records'])).to.have.length(0);
});
});
Expand All @@ -369,11 +378,12 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId, owner, record } = data;
const { contractTxId, owner, record, sortKey } = data;
expect(contractTxId).to.equal(id);
expect(record).to.deep.equal({
contractTxId: process.env.DEPLOYED_ANT_CONTRACT_TX_ID,
});
expect(sortKey).not.be.undefined;
expect(owner).to.not.be.undefined;
expect(owner).to.equal(walletAddress);
});
Expand All @@ -384,9 +394,10 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId, owner, record } = data;
const { contractTxId, owner, record, sortKey } = data;
expect(contractTxId).to.equal(id);
expect(record).to.not.be.undefined;
expect(sortKey).not.be.undefined;
expect(owner).to.be.undefined;
});

Expand All @@ -405,10 +416,17 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId, reserved, details, evaluationOptions } = data;
const {
contractTxId,
reserved,
details,
sortKey,
evaluationOptions,
} = data;
expect(contractTxId).to.equal(id);
expect(reserved).to.be.true;
expect(details).to.not.be.undefined;
expect(sortKey).to.not.be.undefined;
expect(evaluationOptions).to.not.be.undefined;
});

Expand All @@ -418,10 +436,17 @@ describe('Integration tests', () => {
);
expect(status).to.equal(200);
expect(data).to.not.be.undefined;
const { contractTxId, reserved, details, evaluationOptions } = data;
const {
contractTxId,
reserved,
details,
sortKey,
evaluationOptions,
} = data;
expect(contractTxId).to.equal(id);
expect(reserved).to.be.false;
expect(details).to.be.undefined;
expect(sortKey).to.not.be.undefined;
expect(evaluationOptions).to.not.be.undefined;
});
});
Expand Down

0 comments on commit c52bfbe

Please sign in to comment.