1
1
// SPDX-License-Identifier: Apache-2.0
2
- // import {
3
- // JSONSchemaObject,
4
- // MethodObject,
5
- // MethodOrReference,
6
- // OpenrpcDocument,
7
- // } from '@open-rpc/meta-schema';
8
- // import { parseOpenRPCDocument } from '@open-rpc/schema-utils-js';
9
- // import { expect } from 'chai';
2
+ import { JSONSchemaObject , MethodObject , MethodOrReference , OpenrpcDocument } from '@open-rpc/meta-schema' ;
3
+ import { parseOpenRPCDocument } from '@open-rpc/schema-utils-js' ;
4
+ import { expect } from 'chai' ;
10
5
import fs from 'fs' ;
11
6
import path from 'path' ;
12
7
13
8
// import WebSocket from 'ws';
14
9
import openRpcData from '../../../../docs/openrpc.json' ;
15
- // import CallerContract from '../contracts/Caller.json';
16
- // import LogsContract from '../contracts/Logs.json';
10
+ import CallerContract from '../contracts/Caller.json' ;
11
+ import LogsContract from '../contracts/Logs.json' ;
17
12
import {
18
13
chainId ,
19
14
gasLimit ,
@@ -26,9 +21,8 @@ import {
26
21
setTransaction1559_2930AndBlockHash ,
27
22
setTransaction1559AndBlockHash ,
28
23
setTransaction2930AndBlockHash ,
29
- // WS_RELAY_URL,
30
24
} from './data/conformity/utils/constants' ;
31
- // import { TestCases, UpdateParamFunction } from './data/conformity/utils/interfaces';
25
+ import { TestCases , UpdateParamFunction } from './data/conformity/utils/interfaces' ;
32
26
import { processFileContent , splitReqAndRes } from './data/conformity/utils/processors' ;
33
27
import {
34
28
createContractLegacyTransaction ,
@@ -37,53 +31,45 @@ import {
37
31
transaction1559_2930 ,
38
32
transaction2930 ,
39
33
} from './data/conformity/utils/transactions' ;
40
- import {
41
- getLatestBlockHash ,
42
- // sendRequestToRelay,
43
- signAndSendRawTransaction ,
44
- } from './data/conformity/utils/utils' ;
45
- // import { hasResponseFormatIssues, isResponseValid } from './data/conformity/utils/validations';
34
+ import { getLatestBlockHash , sendRequestToRelay , signAndSendRawTransaction } from './data/conformity/utils/utils' ;
35
+ import { isResponseValid } from './data/conformity/utils/validations' ;
46
36
47
37
const directoryPath = path . resolve ( __dirname , '../../../../node_modules/execution-apis/tests' ) ;
48
38
const overwritesDirectoryPath = path . resolve ( __dirname , 'data/conformity/overwrites' ) ;
49
39
50
- // let relayOpenRpcData: OpenrpcDocument;
51
- // (async () => {
52
- // relayOpenRpcData = await parseOpenRPCDocument(JSON.stringify(openRpcData));
53
- // })().catch((error) => console.error('Error parsing OpenRPC document:', error));
54
-
55
- // const synthesizeTestCases = function (testCases: TestCases, updateParamIfNeeded: UpdateParamFunction) {
56
- // for (const testName in testCases) {
57
- // it(`${testName}`, async function () {
58
- // const isErrorStatusExpected: boolean =
59
- // (testCases[testName]?.status && testCases[testName].status != 200) ||
60
- // !!JSON.parse(testCases[testName].response).error;
61
- // const method = relayOpenRpcData.methods.find(
62
- // (m: MethodOrReference): m is MethodObject => 'name' in m && m.name === testName.split(' ')[0],
63
- // );
64
- // const schema: JSONSchemaObject | undefined =
65
- // method?.result && 'schema' in method.result && typeof method.result.schema === 'object'
66
- // ? method.result.schema
67
- // : undefined;
68
- // try {
69
- // const req = updateParamIfNeeded(testName, JSON.parse(testCases[testName].request));
70
- // const res = await sendRequestToRelay(RELAY_URL, req, false);
71
- // const isResFormatInvalid: boolean = hasResponseFormatIssues(res, JSON.parse(testCases[testName].response));
72
- //
73
- // if (schema && schema.pattern) {
74
- // const check = isResponseValid(schema, res);
75
- // expect(check).to.be.true;
76
- // }
77
- //
78
- // expect(isResFormatInvalid).to.be.false;
79
- // expect(isErrorStatusExpected).to.be.false;
80
- // } catch (e: any) {
81
- // expect(isErrorStatusExpected).to.be.true;
82
- // expect(e?.response?.status).to.equal(testCases[testName].status);
83
- // }
84
- // });
85
- // }
86
- // };
40
+ let relayOpenRpcData : OpenrpcDocument ;
41
+ ( async ( ) => {
42
+ relayOpenRpcData = await parseOpenRPCDocument ( JSON . stringify ( openRpcData ) ) ;
43
+ } ) ( ) . catch ( ( error ) => console . error ( 'Error parsing OpenRPC document:' , error ) ) ;
44
+
45
+ const synthesizeTestCases = function ( testCases : TestCases , updateParamIfNeeded : UpdateParamFunction ) {
46
+ for ( const testName in testCases ) {
47
+ it ( `${ testName } ` , async function ( ) {
48
+ const isErrorStatusExpected : boolean =
49
+ ( testCases [ testName ] ?. status && testCases [ testName ] . status != 200 ) ||
50
+ ! ! JSON . parse ( testCases [ testName ] . response ) . error ;
51
+ const method = relayOpenRpcData . methods . find (
52
+ ( m : MethodOrReference ) : m is MethodObject => 'name' in m && m . name === testName . split ( ' ' ) [ 0 ] ,
53
+ ) ;
54
+ const schema : JSONSchemaObject | undefined =
55
+ method ?. result && 'schema' in method . result && typeof method . result . schema === 'object'
56
+ ? method . result . schema
57
+ : undefined ;
58
+ try {
59
+ const req = updateParamIfNeeded ( testName , JSON . parse ( testCases [ testName ] . request ) ) ;
60
+ const res = await sendRequestToRelay ( RELAY_URL , req , false ) ;
61
+ if ( schema && schema . pattern ) {
62
+ const check = isResponseValid ( schema , res ) ;
63
+ expect ( check ) . to . be . true ;
64
+ }
65
+ expect ( isErrorStatusExpected ) . to . be . false ;
66
+ } catch ( e : any ) {
67
+ expect ( isErrorStatusExpected ) . to . be . true ;
68
+ expect ( e ?. response ?. status ) . to . equal ( testCases [ testName ] . status ) ;
69
+ }
70
+ } ) ;
71
+ }
72
+ } ;
87
73
88
74
/**
89
75
* To run the Ethereum Execution API tests as defined in the repository ethereum/execution-apis, it’s necessary
@@ -152,7 +138,7 @@ describe('@api-conformity', async function () {
152
138
//
153
139
// These test suites must be un-skipped. The code requires refactoring to resolve the
154
140
// static analysis issues before they can be re-enabled.
155
- /* describe.skip ('@conformity-batch-2 Ethereum execution apis tests', async function () {
141
+ describe ( '@conformity-batch-2 Ethereum execution apis tests' , async function ( ) {
156
142
this . timeout ( 240 * 1000 ) ;
157
143
158
144
let existingBlockFilter : string ;
@@ -222,7 +208,7 @@ describe('@api-conformity', async function () {
222
208
synthesizeTestCases ( TEST_CASES_BATCH_2 , updateParamIfNeeded ) ;
223
209
} ) ;
224
210
225
- describe.skip ('@conformity-batch-3 Ethereum execution apis tests', async function () {
211
+ describe ( '@conformity-batch-3 Ethereum execution apis tests' , async function ( ) {
226
212
this . timeout ( 240 * 1000 ) ;
227
213
228
214
let txHash : any ;
@@ -254,7 +240,7 @@ describe('@api-conformity', async function () {
254
240
255
241
synthesizeTestCases ( TEST_CASES_BATCH_3 [ 'server' ] , updateParamIfNeeded ) ;
256
242
257
- describe('ws related rpc methods', async function () {
243
+ /* describe('ws related rpc methods', async function () {
258
244
let webSocket: WebSocket;
259
245
let contractAddress: string | null;
260
246
let existingFilter: string;
@@ -340,10 +326,10 @@ describe('@api-conformity', async function () {
340
326
};
341
327
342
328
synthesizeWsTestCases(TEST_CASES_BATCH_3['ws-server'], updateParamIfNeeded);
343
- });
329
+ });*/
344
330
} ) ;
345
331
346
- describe.skip ('@conformity-batch-4 Ethereum execution apis tests', async function () {
332
+ describe ( '@conformity-batch-4 Ethereum execution apis tests' , async function ( ) {
347
333
this . timeout ( 240 * 1000 ) ;
348
334
349
335
let existingCallerContractAddress : string | null ;
@@ -543,12 +529,12 @@ describe('@api-conformity', async function () {
543
529
synthesizeTestCases ( TEST_CASES_BATCH_4 , updateParamIfNeeded ) ;
544
530
} ) ;
545
531
546
- describe.skip ('@conformity-batch-5 Ethereum execution apis tests', async function () {
532
+ describe ( '@conformity-batch-5 Ethereum execution apis tests' , async function ( ) {
547
533
this . timeout ( 240 * 1000 ) ;
548
534
// eslint-disable-next-line @typescript-eslint/no-var-requires
549
535
const TEST_CASES_BATCH_5 = require ( './data/conformity-tests-batch-5.json' ) ;
550
536
551
537
const updateParamIfNeeded = ( _testName : any , request : any ) => request ;
552
538
synthesizeTestCases ( TEST_CASES_BATCH_5 , updateParamIfNeeded ) ;
553
- });*/
539
+ } ) ;
554
540
} ) ;
0 commit comments