1
1
import { describe , before , it } from 'mocha' ;
2
2
import { expect } from 'chai' ;
3
3
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' ;
5
8
import { assertNotNull } from '../utils' ;
6
9
import { pause } from '../../src/utils/other' ;
7
10
import { Activity } from '../../src/apis/middleware' ;
@@ -91,6 +94,7 @@ describe('Middleware API', () => {
91
94
const microBlockHash = ( await middleware . getKeyBlocks ( ) ) . data . reverse ( )
92
95
. find ( ( { prevHash } ) => prevHash . startsWith ( 'mh_' ) ) ?. prevHash ;
93
96
assertNotNull ( microBlockHash ) ;
97
+ if ( ! isAddressValid ( microBlockHash , Encoding . MicroBlockHash ) ) throw new UnexpectedTsError ( ) ;
94
98
const res = await middleware . getMicroBlock ( microBlockHash ) ;
95
99
const expectedRes : typeof res = {
96
100
hash : 'mh_uMZS2rqBQ1ZD9GNTS2n54bRbATbupC2JV32wpj4gs4EGnfnKd' ,
@@ -829,7 +833,7 @@ describe('Middleware API', () => {
829
833
} ) ;
830
834
831
835
it ( 'gets blocks' , async ( ) => {
832
- const res = await middleware . getBlocksStatistics ( ) ;
836
+ const res = await middleware . getBlocksStats ( ) ;
833
837
const expectedRes : typeof res = new MiddlewarePage ( {
834
838
data : [ { count : 24 , endDate, startDate } ] ,
835
839
next : null ,
@@ -839,7 +843,7 @@ describe('Middleware API', () => {
839
843
} ) ;
840
844
841
845
it ( 'gets transactions' , async ( ) => {
842
- const res = await middleware . getTransactionsStatistics ( ) ;
846
+ const res = await middleware . getTransactionsStats ( ) ;
843
847
const expectedRes : typeof res = new MiddlewarePage ( {
844
848
data : [ { count : 11 , endDate, startDate } ] ,
845
849
next : null ,
@@ -849,7 +853,7 @@ describe('Middleware API', () => {
849
853
} ) ;
850
854
851
855
it ( 'gets names' , async ( ) => {
852
- const res = await middleware . getNamesStatistics ( ) ;
856
+ const res = await middleware . getNamesStats ( ) ;
853
857
const expectedRes : typeof res = new MiddlewarePage ( {
854
858
data : [ { count : 0 , endDate, startDate } ] ,
855
859
next : null ,
0 commit comments