Skip to content

Commit c8fbffe

Browse files
authored
Merge pull request #2011 from aeternity/autorest-prefixed-types
feat(middleware): prefixed types provided by OpenApi instead of strings
2 parents 530b3b0 + 0b16a32 commit c8fbffe

File tree

4 files changed

+856
-575
lines changed

4 files changed

+856
-575
lines changed

test/integration/Middleware.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { describe, before, it } from 'mocha';
22
import { expect } from 'chai';
33
import resetMiddleware, { presetAccount1Address, presetAccount2Address } from './reset-middleware';
4-
import { IllegalArgumentError, Middleware, MiddlewarePageMissed } from '../../src';
4+
import {
5+
Encoding, IllegalArgumentError, isAddressValid, Middleware, MiddlewarePageMissed,
6+
UnexpectedTsError,
7+
} from '../../src';
58
import { assertNotNull } from '../utils';
69
import { pause } from '../../src/utils/other';
710
import { Activity } from '../../src/apis/middleware';
@@ -91,6 +94,7 @@ describe('Middleware API', () => {
9194
const microBlockHash = (await middleware.getKeyBlocks()).data.reverse()
9295
.find(({ prevHash }) => prevHash.startsWith('mh_'))?.prevHash;
9396
assertNotNull(microBlockHash);
97+
if (!isAddressValid(microBlockHash, Encoding.MicroBlockHash)) throw new UnexpectedTsError();
9498
const res = await middleware.getMicroBlock(microBlockHash);
9599
const expectedRes: typeof res = {
96100
hash: 'mh_uMZS2rqBQ1ZD9GNTS2n54bRbATbupC2JV32wpj4gs4EGnfnKd',
@@ -829,7 +833,7 @@ describe('Middleware API', () => {
829833
});
830834

831835
it('gets blocks', async () => {
832-
const res = await middleware.getBlocksStatistics();
836+
const res = await middleware.getBlocksStats();
833837
const expectedRes: typeof res = new MiddlewarePage({
834838
data: [{ count: 24, endDate, startDate }],
835839
next: null,
@@ -839,7 +843,7 @@ describe('Middleware API', () => {
839843
});
840844

841845
it('gets transactions', async () => {
842-
const res = await middleware.getTransactionsStatistics();
846+
const res = await middleware.getTransactionsStats();
843847
const expectedRes: typeof res = new MiddlewarePage({
844848
data: [{ count: 11, endDate, startDate }],
845849
next: null,
@@ -849,7 +853,7 @@ describe('Middleware API', () => {
849853
});
850854

851855
it('gets names', async () => {
852-
const res = await middleware.getNamesStatistics();
856+
const res = await middleware.getNamesStats();
853857
const expectedRes: typeof res = new MiddlewarePage({
854858
data: [{ count: 0, endDate, startDate }],
855859
next: null,

0 commit comments

Comments
 (0)