Skip to content

Commit 7794fb0

Browse files
committed
moves debug api enabled test in debug.spec to also fix them
Signed-off-by: Konstantina Blazhukova <[email protected]>
1 parent f723d52 commit 7794fb0

File tree

1 file changed

+51
-40
lines changed

1 file changed

+51
-40
lines changed

packages/server/tests/acceptance/debug.spec.ts

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
// External resources
44
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
5-
import { ConfigServiceTestHelper } from '@hashgraph/json-rpc-config-service/tests/configServiceTestHelper';
65
import { predefined } from '@hashgraph/json-rpc-relay';
76
import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types';
87
import { numberTo0x } from '@hashgraph/json-rpc-relay/src/formatters';
@@ -11,6 +10,7 @@ import chai, { expect } from 'chai';
1110
import chaiExclude from 'chai-exclude';
1211
import { ethers } from 'ethers';
1312

13+
import { ConfigServiceTestHelper } from '../../../config-service/tests/configServiceTestHelper';
1414
import RelayCall from '../../tests/helpers/constants';
1515
import MirrorClient from '../clients/mirrorClient';
1616
import RelayClient from '../clients/relayClient';
@@ -367,27 +367,6 @@ describe('@debug API Acceptance Tests', function () {
367367
}
368368
});
369369

370-
it('should fail with UNSUPPORTED_METHOD error when DEBUG_API_ENABLED is false', async function () {
371-
// Store original value
372-
const originalDebugApiEnabled = ConfigService.get('DEBUG_API_ENABLED');
373-
374-
// Set DEBUG_API_ENABLED to false
375-
ConfigServiceTestHelper.dynamicOverride('DEBUG_API_ENABLED', false);
376-
377-
try {
378-
// Should return UNSUPPORTED_METHOD error
379-
await relay.callFailing(
380-
DEBUG_TRACE_BLOCK_BY_NUMBER,
381-
[numberTo0x(deploymentBlockNumber), TRACER_CONFIGS.CALL_TRACER_TOP_ONLY_FALSE],
382-
predefined.UNSUPPORTED_METHOD,
383-
requestId,
384-
);
385-
} finally {
386-
// Restore original value
387-
ConfigServiceTestHelper.dynamicOverride('DEBUG_API_ENABLED', originalDebugApiEnabled);
388-
}
389-
});
390-
391370
it('should fail with INVALID_PARAMETER when given an invalid block number', async function () {
392371
// Invalid block number format
393372
await relay.callFailing(
@@ -683,28 +662,60 @@ describe('@debug API Acceptance Tests', function () {
683662
requestId,
684663
);
685664
});
665+
});
686666

687-
it('should fail with UNSUPPORTED_METHOD error when DEBUG_API_ENABLED is false', async function () {
688-
// Store original value
689-
const originalDebugApiEnabled = ConfigService.get('DEBUG_API_ENABLED');
667+
describe('when DEBUG_API_ENABLED is false', () => {
668+
let originalDebugApiEnabled: boolean;
669+
let transactionHash: string;
670+
let deploymentBlockNumber: string;
671+
672+
before(async () => {
673+
const transaction = {
674+
to: basicContractAddress,
675+
from: accounts[0].address,
676+
gasLimit: numberTo0x(3_000_000),
677+
chainId: Number(CHAIN_ID),
678+
type: 2,
679+
maxFeePerGas: await relay.gasPrice(requestId),
680+
maxPriorityFeePerGas: await relay.gasPrice(requestId),
681+
data: BASIC_CONTRACT_PING_CALL_DATA,
682+
nonce: await relay.getAccountNonce(accounts[0].address, requestId),
683+
};
684+
685+
const signedTx = await accounts[0].wallet.signTransaction(transaction);
686+
transactionHash = await relay.sendRawTransaction(signedTx, requestId);
690687

691-
// Set DEBUG_API_ENABLED to false
688+
// Wait for transaction to be processed
689+
const receipt = await relay.pollForValidTransactionReceipt(transactionHash);
690+
deploymentBlockNumber = receipt.blockNumber;
691+
console.log('receipt', receipt);
692+
console.log('deploymentBlockNumber', deploymentBlockNumber);
693+
originalDebugApiEnabled = ConfigService.get('DEBUG_API_ENABLED');
692694
ConfigServiceTestHelper.dynamicOverride('DEBUG_API_ENABLED', false);
695+
});
693696

694-
try {
695-
const tracerConfig = { tracer: TracerType.CallTracer, tracerConfig: { onlyTopCall: false } };
696-
697-
// Should return UNSUPPORTED_METHOD error
698-
await relay.callFailing(
699-
DEBUG_TRACE_TRANSACTION,
700-
[createChildTx.hash, tracerConfig],
701-
predefined.UNSUPPORTED_METHOD,
702-
requestId,
703-
);
704-
} finally {
705-
// Restore original value
706-
ConfigServiceTestHelper.dynamicOverride('DEBUG_API_ENABLED', originalDebugApiEnabled);
707-
}
697+
after(() => {
698+
ConfigServiceTestHelper.dynamicOverride('DEBUG_API_ENABLED', originalDebugApiEnabled);
699+
});
700+
701+
it('should fail debug_traceBlockByNumber with UNSUPPORTED_METHOD', async function () {
702+
await relay.callFailing(
703+
DEBUG_TRACE_BLOCK_BY_NUMBER,
704+
[deploymentBlockNumber, TRACER_CONFIGS.CALL_TRACER_TOP_ONLY_FALSE],
705+
predefined.UNSUPPORTED_METHOD,
706+
requestId,
707+
);
708+
});
709+
710+
it('should fail debug_traceTransaction with UNSUPPORTED_METHOD', async function () {
711+
const tracerConfig = { tracer: TracerType.CallTracer, tracerConfig: { onlyTopCall: false } };
712+
713+
await relay.callFailing(
714+
DEBUG_TRACE_TRANSACTION,
715+
[transactionHash, tracerConfig],
716+
predefined.UNSUPPORTED_METHOD,
717+
requestId,
718+
);
708719
});
709720
});
710721
});

0 commit comments

Comments
 (0)