@nomicfoundation/edr 0.12.0-next.9 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coverage.sol +38 -0
- package/dist/src/ts/coverage.d.ts +6 -0
- package/dist/src/ts/coverage.d.ts.map +1 -0
- package/dist/src/ts/coverage.js +51 -0
- package/dist/src/ts/coverage.js.map +1 -0
- package/index.d.ts +286 -27
- package/index.js +6 -2
- package/package.json +21 -19
- package/src/account.rs +0 -124
- package/src/block.rs +0 -28
- package/src/call_override.rs +0 -116
- package/src/cast.rs +0 -165
- package/src/chains/generic.rs +0 -58
- package/src/chains/l1.rs +0 -268
- package/src/chains/op.rs +0 -424
- package/src/chains.rs +0 -7
- package/src/config.rs +0 -700
- package/src/context.rs +0 -447
- package/src/contract_decoder.rs +0 -57
- package/src/debug_trace.rs +0 -40
- package/src/gas_report.rs +0 -92
- package/src/instrument.rs +0 -109
- package/src/lib.rs +0 -50
- package/src/log.rs +0 -28
- package/src/logger.rs +0 -120
- package/src/mock/time.rs +0 -134
- package/src/mock.rs +0 -71
- package/src/precompile.rs +0 -50
- package/src/provider/factory.rs +0 -22
- package/src/provider/response.rs +0 -73
- package/src/provider.rs +0 -162
- package/src/result.rs +0 -212
- package/src/scenarios.rs +0 -53
- package/src/serde.rs +0 -57
- package/src/solidity_tests/artifact.rs +0 -184
- package/src/solidity_tests/config.rs +0 -793
- package/src/solidity_tests/factory.rs +0 -22
- package/src/solidity_tests/l1.rs +0 -68
- package/src/solidity_tests/op.rs +0 -69
- package/src/solidity_tests/runner.rs +0 -51
- package/src/solidity_tests/test_results.rs +0 -736
- package/src/solidity_tests.rs +0 -56
- package/src/subscription.rs +0 -32
- package/src/trace/debug.rs +0 -61
- package/src/trace/exit.rs +0 -89
- package/src/trace/library_utils.rs +0 -11
- package/src/trace/model.rs +0 -59
- package/src/trace/return_data.rs +0 -96
- package/src/trace/solidity_stack_trace.rs +0 -869
- package/src/trace.rs +0 -199
- package/src/ts/solidity_tests.ts +0 -46
- package/src/withdrawal.rs +0 -49
package/coverage.sol
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity >=0.4.22 <0.9.0;
|
|
3
|
+
|
|
4
|
+
library __NomicFoundationCoverage {
|
|
5
|
+
address constant COVERAGE_ADDRESS =
|
|
6
|
+
0xc0bEc0BEc0BeC0bEC0beC0bEC0bEC0beC0beC0BE;
|
|
7
|
+
|
|
8
|
+
function _sendHitImplementation(uint256 coverageId) private view {
|
|
9
|
+
address coverageAddress = COVERAGE_ADDRESS;
|
|
10
|
+
/// @solidity memory-safe-assembly
|
|
11
|
+
assembly {
|
|
12
|
+
let ptr := mload(0x40) // Get free memory pointer
|
|
13
|
+
mstore(ptr, coverageId) // Store coverageId at free memory
|
|
14
|
+
pop(
|
|
15
|
+
staticcall(
|
|
16
|
+
gas(),
|
|
17
|
+
coverageAddress,
|
|
18
|
+
ptr,
|
|
19
|
+
32, // Size of uint256 is 32 bytes
|
|
20
|
+
0,
|
|
21
|
+
0
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function _castToPure(
|
|
28
|
+
function(uint256) internal view fnIn
|
|
29
|
+
) private pure returns (function(uint256) pure fnOut) {
|
|
30
|
+
assembly {
|
|
31
|
+
fnOut := fnIn
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function sendHit(uint256 coverageId) internal pure {
|
|
36
|
+
_castToPure(_sendHitImplementation)(coverageId);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../../src/ts/coverage.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,kBAAkB,IAAI,WAAW,CAYhD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getCoverageLibrary = getCoverageLibrary;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const edr_1 = require("@nomicfoundation/edr");
|
|
40
|
+
function getCoverageLibrary() {
|
|
41
|
+
const packageRoot = path.dirname(require.resolve("@nomicfoundation/edr"));
|
|
42
|
+
const sourcePath = path.join(packageRoot, "coverage.sol");
|
|
43
|
+
if (!fs.existsSync(sourcePath)) {
|
|
44
|
+
throw new Error(`Coverage library file not found at ${sourcePath}. It should be bundled with @nomicfoundation/edr.`);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
content: fs.readFileSync(sourcePath, "utf-8"),
|
|
48
|
+
filename: edr_1.COVERAGE_LIBRARY_FILE_NAME,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=coverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../../src/ts/coverage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,gDAYC;AAtBD,uCAAyB;AACzB,2CAA6B;AAE7B,8CAAkE;AAOlE,SAAgB,kBAAkB;IAChC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAC1E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAC1D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,sCAAsC,UAAU,mDAAmD,CACpG,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC;QAC7C,QAAQ,EAAE,gCAA0B;KACrC,CAAC;AACJ,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -91,7 +91,9 @@ export enum SpecId {
|
|
|
91
91
|
/** Cancun */
|
|
92
92
|
Cancun = 17,
|
|
93
93
|
/** Prague */
|
|
94
|
-
Prague = 18
|
|
94
|
+
Prague = 18,
|
|
95
|
+
/** Osaka */
|
|
96
|
+
Osaka = 19
|
|
95
97
|
}
|
|
96
98
|
/**
|
|
97
99
|
* Tries to parse the provided string to create a [`SpecId`] instance.
|
|
@@ -125,6 +127,7 @@ export const MERGE: string
|
|
|
125
127
|
export const SHANGHAI: string
|
|
126
128
|
export const CANCUN: string
|
|
127
129
|
export const PRAGUE: string
|
|
130
|
+
export const OSAKA: string
|
|
128
131
|
/** Enumeration of supported OP hardforks. */
|
|
129
132
|
export enum OpHardfork {
|
|
130
133
|
Bedrock = 100,
|
|
@@ -243,6 +246,16 @@ export interface HardforkActivationByTimestamp {
|
|
|
243
246
|
/** The timestamp at which the hardfork is activated */
|
|
244
247
|
timestamp: bigint
|
|
245
248
|
}
|
|
249
|
+
/** Controls the gas estimation strategy used by `eth_estimateGas`. */
|
|
250
|
+
export enum GasEstimationMode {
|
|
251
|
+
/** Estimates the minimum gas required for the top-level call to succeed. */
|
|
252
|
+
TopLevelSuccess = 0,
|
|
253
|
+
/**
|
|
254
|
+
* Estimates the minimum gas required for the top-level call to succeed
|
|
255
|
+
* without any internal sub-call running out of gas.
|
|
256
|
+
*/
|
|
257
|
+
NoInternalOutOfGas = 1
|
|
258
|
+
}
|
|
246
259
|
/**The type of ordering to use when selecting blocks to mine. */
|
|
247
260
|
export enum MineOrdering {
|
|
248
261
|
/**Insertion order */
|
|
@@ -261,15 +274,42 @@ export interface IntervalRange {
|
|
|
261
274
|
/** Configuration for the provider's miner. */
|
|
262
275
|
export interface MiningConfig {
|
|
263
276
|
autoMine: boolean
|
|
277
|
+
/**
|
|
278
|
+
* The block gas limit to use for mining a block.
|
|
279
|
+
*
|
|
280
|
+
* When not set, enforcement of the block gas limit is disabled in the mem
|
|
281
|
+
* pool, miner, and REVM.
|
|
282
|
+
*/
|
|
283
|
+
blockGasLimit?: bigint
|
|
264
284
|
interval?: bigint | IntervalRange
|
|
265
285
|
memPool: MemPoolConfig
|
|
266
286
|
}
|
|
287
|
+
/** Configuration for a locally mined blockchain. */
|
|
288
|
+
export interface LocalConfig {
|
|
289
|
+
/**
|
|
290
|
+
* The blob gas used for the genesis block, introduced in [EIP-4844].
|
|
291
|
+
*
|
|
292
|
+
* [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844
|
|
293
|
+
*/
|
|
294
|
+
genesisBlobGas?: BlobGas
|
|
295
|
+
/** The block gas limit of the genesis block. */
|
|
296
|
+
genesisBlockGasLimit: bigint
|
|
297
|
+
/** The date, in seconds since the Unix epoch, of the genesis block. */
|
|
298
|
+
genesisBlockTime?: bigint
|
|
299
|
+
}
|
|
267
300
|
/** Configuration for runtime observability. */
|
|
268
301
|
export interface ObservabilityConfig {
|
|
269
302
|
/** If present, configures runtime observability to collect code coverage. */
|
|
270
303
|
codeCoverage?: CodeCoverageConfig
|
|
271
304
|
/** If present, configures runtime observability to collect gas reports. */
|
|
272
305
|
gasReport?: GasReportConfig
|
|
306
|
+
/**
|
|
307
|
+
* Controls when to include call traces in the results of transaction
|
|
308
|
+
* execution.
|
|
309
|
+
*
|
|
310
|
+
* Defaults to `IncludeTraces.None`.
|
|
311
|
+
*/
|
|
312
|
+
includeCallTraces?: IncludeTraces
|
|
273
313
|
}
|
|
274
314
|
/** Configuration for a provider */
|
|
275
315
|
export interface ProviderConfig {
|
|
@@ -292,17 +332,20 @@ export interface ProviderConfig {
|
|
|
292
332
|
* will be used.
|
|
293
333
|
*/
|
|
294
334
|
baseFeeConfig?: Array<BaseFeeParamActivation>
|
|
295
|
-
/** The gas limit of each block */
|
|
296
|
-
blockGasLimit: bigint
|
|
297
335
|
/** The chain ID of the blockchain */
|
|
298
336
|
chainId: bigint
|
|
299
337
|
/** The address of the coinbase */
|
|
300
338
|
coinbase: Uint8Array
|
|
301
339
|
/**
|
|
302
|
-
* The
|
|
303
|
-
*
|
|
340
|
+
* The default transaction gas limit to use for RPC call and transaction
|
|
341
|
+
* requests that do not specify a `gas` value.
|
|
342
|
+
*/
|
|
343
|
+
defaultTransactionGasLimit: bigint
|
|
344
|
+
/**
|
|
345
|
+
* The gas estimation mode to use for `eth_estimateGas`. Defaults to
|
|
346
|
+
* `GasEstimationMode::TopLevelSuccess` if not set.
|
|
304
347
|
*/
|
|
305
|
-
|
|
348
|
+
gasEstimationMode?: GasEstimationMode
|
|
306
349
|
/** The genesis state of the blockchain */
|
|
307
350
|
genesisState: Array<AccountOverride>
|
|
308
351
|
/** The hardfork of the blockchain */
|
|
@@ -312,10 +355,6 @@ export interface ProviderConfig {
|
|
|
312
355
|
* transactions and later
|
|
313
356
|
*/
|
|
314
357
|
initialBaseFeePerGas?: bigint
|
|
315
|
-
/** The initial blob gas of the blockchain. Required for EIP-4844 */
|
|
316
|
-
initialBlobGas?: BlobGas
|
|
317
|
-
/** The initial date of the blockchain, in seconds since the Unix epoch */
|
|
318
|
-
initialDate?: bigint
|
|
319
358
|
/**
|
|
320
359
|
* The initial parent beacon block root of the blockchain. Required for
|
|
321
360
|
* EIP-4788
|
|
@@ -325,6 +364,8 @@ export interface ProviderConfig {
|
|
|
325
364
|
minGasPrice: bigint
|
|
326
365
|
/** The configuration for the miner */
|
|
327
366
|
mining: MiningConfig
|
|
367
|
+
/** The network configuration for the provider. */
|
|
368
|
+
network: ForkConfig | LocalConfig
|
|
328
369
|
/** The network ID of the blockchain */
|
|
329
370
|
networkId: bigint
|
|
330
371
|
/** The configuration for the provider's observability */
|
|
@@ -333,6 +374,20 @@ export interface ProviderConfig {
|
|
|
333
374
|
ownedAccounts: Array<string>
|
|
334
375
|
/** Overrides for precompiles */
|
|
335
376
|
precompileOverrides: Array<Precompile>
|
|
377
|
+
/**
|
|
378
|
+
* Transaction gas cap, introduced in [EIP-7825].
|
|
379
|
+
*
|
|
380
|
+
* Integer values should be larger than zero.
|
|
381
|
+
*
|
|
382
|
+
* When `false`, enforcement of the transaction gas cap is disabled and
|
|
383
|
+
* transactions with any `gas` value are accepted by the mempool and
|
|
384
|
+
* executed without REVM's transaction gas cap check.
|
|
385
|
+
*
|
|
386
|
+
* When not set, a hardfork-specific default value will be used.
|
|
387
|
+
*
|
|
388
|
+
* [EIP-7825]: https://eips.ethereum.org/EIPS/eip-7825
|
|
389
|
+
*/
|
|
390
|
+
transactionGasCap?: bigint | false
|
|
336
391
|
}
|
|
337
392
|
/** Tracing config for Solidity stack trace generation. */
|
|
338
393
|
export interface TracingConfigWithBuffers {
|
|
@@ -399,11 +454,19 @@ export enum GasReportExecutionStatus {
|
|
|
399
454
|
export interface DeploymentGasReport {
|
|
400
455
|
gas: bigint
|
|
401
456
|
size: bigint
|
|
457
|
+
runtimeSize: bigint
|
|
402
458
|
status: GasReportExecutionStatus
|
|
403
459
|
}
|
|
404
460
|
export interface FunctionGasReport {
|
|
405
461
|
gas: bigint
|
|
406
462
|
status: GasReportExecutionStatus
|
|
463
|
+
/**
|
|
464
|
+
* The proxy delegation chain for this call, if the called contract is a
|
|
465
|
+
* proxy. Contains contract identifiers from outermost proxy to final
|
|
466
|
+
* implementation, e.g. `["Proxy", "Implementation"]`.
|
|
467
|
+
* Empty if the call is not through a proxy.
|
|
468
|
+
*/
|
|
469
|
+
proxyChain: Array<string>
|
|
407
470
|
}
|
|
408
471
|
export interface InstrumentationResult {
|
|
409
472
|
/** The generated source code with coverage instrumentation. */
|
|
@@ -434,11 +497,15 @@ export interface InstrumentationMetadata {
|
|
|
434
497
|
*/
|
|
435
498
|
readonly endUtf16: number
|
|
436
499
|
}
|
|
500
|
+
/** The instrumentation coverage library file name. */
|
|
501
|
+
export const COVERAGE_LIBRARY_FILE_NAME: string
|
|
437
502
|
/**
|
|
438
503
|
* Adds per-statement coverage instrumentation to the given Solidity source
|
|
439
504
|
* code.
|
|
440
505
|
*/
|
|
441
|
-
export declare function addStatementCoverageInstrumentation(sourceCode: string, sourceId: string, solidityVersion: string
|
|
506
|
+
export declare function addStatementCoverageInstrumentation(sourceCode: string, sourceId: string, solidityVersion: string): InstrumentationResult
|
|
507
|
+
/** Retrieves the latest version of `Solidity` supported for instrumentation. */
|
|
508
|
+
export declare function latestSupportedSolidityVersion(): string
|
|
442
509
|
/** Ethereum execution log. */
|
|
443
510
|
export interface ExecutionLog {
|
|
444
511
|
address: Uint8Array
|
|
@@ -492,6 +559,8 @@ export interface SuccessResult {
|
|
|
492
559
|
export interface RevertResult {
|
|
493
560
|
/** The amount of gas used */
|
|
494
561
|
gasUsed: bigint
|
|
562
|
+
/** The logs */
|
|
563
|
+
logs: Array<ExecutionLog>
|
|
495
564
|
/** The transaction output */
|
|
496
565
|
output: Uint8Array
|
|
497
566
|
}
|
|
@@ -527,6 +596,8 @@ export interface HaltResult {
|
|
|
527
596
|
* gas limit
|
|
528
597
|
*/
|
|
529
598
|
gasUsed: bigint
|
|
599
|
+
/** The logs */
|
|
600
|
+
logs: Array<ExecutionLog>
|
|
530
601
|
}
|
|
531
602
|
/** The result of executing a transaction. */
|
|
532
603
|
export interface ExecutionResult {
|
|
@@ -574,6 +645,20 @@ export interface LinkReference {
|
|
|
574
645
|
start: number
|
|
575
646
|
length: number
|
|
576
647
|
}
|
|
648
|
+
/**Error codes that can be returned by cheatcodes in Solidity tests. */
|
|
649
|
+
export enum CheatcodeErrorCode {
|
|
650
|
+
/**The specified cheatcode is not supported. */
|
|
651
|
+
UnsupportedCheatcode = 'UnsupportedCheatcode',
|
|
652
|
+
/**The specified cheatcode is missing. */
|
|
653
|
+
MissingCheatcode = 'MissingCheatcode'
|
|
654
|
+
}
|
|
655
|
+
/**Error returned by a cheatcode in Solidity tests. */
|
|
656
|
+
export interface CheatcodeErrorDetails {
|
|
657
|
+
/**The error code representing the type of cheatcode error. */
|
|
658
|
+
code: CheatcodeErrorCode
|
|
659
|
+
/**The name of the cheatcode that caused the error. */
|
|
660
|
+
cheatcode: string
|
|
661
|
+
}
|
|
577
662
|
/**
|
|
578
663
|
* Solidity test runner configuration arguments exposed through the ffi.
|
|
579
664
|
* Docs based on <https://book.getfoundry.sh/reference/config/testing>.
|
|
@@ -586,8 +671,6 @@ export interface SolidityTestRunnerConfigArgs {
|
|
|
586
671
|
projectRoot: string
|
|
587
672
|
/** Configures the permissions of cheat codes that access the file system. */
|
|
588
673
|
fsPermissions?: Array<PathPermission>
|
|
589
|
-
/** Whether to support the `testFail` prefix. Defaults to false. */
|
|
590
|
-
testFail?: boolean
|
|
591
674
|
/** Address labels for traces. Defaults to none. */
|
|
592
675
|
labels?: Array<AddressLabel>
|
|
593
676
|
/**
|
|
@@ -635,6 +718,8 @@ export interface SolidityTestRunnerConfigArgs {
|
|
|
635
718
|
* Defaults to `31337`.
|
|
636
719
|
*/
|
|
637
720
|
chainId?: bigint
|
|
721
|
+
/** The hardfork to use for EVM execution. */
|
|
722
|
+
hardfork: string
|
|
638
723
|
/**
|
|
639
724
|
* The gas limit for each test case.
|
|
640
725
|
* Defaults to `9_223_372_036_854_775_807` (`i64::MAX`).
|
|
@@ -675,6 +760,21 @@ export interface SolidityTestRunnerConfigArgs {
|
|
|
675
760
|
* Defaults to false.
|
|
676
761
|
*/
|
|
677
762
|
disableBlockGasLimit?: boolean
|
|
763
|
+
/**
|
|
764
|
+
* Transaction gas cap, introduced in [EIP-7825].
|
|
765
|
+
*
|
|
766
|
+
* When not set, defaults to the value defined by the used hardfork.
|
|
767
|
+
*
|
|
768
|
+
* [EIP-7825]: https://eips.ethereum.org/EIPS/eip-7825
|
|
769
|
+
*/
|
|
770
|
+
transactionGasCap?: bigint
|
|
771
|
+
/**
|
|
772
|
+
* Whether to disable the [EIP-7825] transaction gas cap.
|
|
773
|
+
* Defaults to false.
|
|
774
|
+
*
|
|
775
|
+
* [EIP-7825]: https://eips.ethereum.org/EIPS/eip-7825
|
|
776
|
+
*/
|
|
777
|
+
disableTransactionGasCap?: boolean
|
|
678
778
|
/**
|
|
679
779
|
* The memory limit of the EVM in bytes.
|
|
680
780
|
* Defaults to `33_554_432` (2^25 = 32MiB).
|
|
@@ -743,6 +843,45 @@ export interface SolidityTestRunnerConfigArgs {
|
|
|
743
843
|
* Defaults to false.
|
|
744
844
|
*/
|
|
745
845
|
generateGasReport?: boolean
|
|
846
|
+
/**
|
|
847
|
+
* Test function level config overrides.
|
|
848
|
+
* Defaults to none.
|
|
849
|
+
*/
|
|
850
|
+
testFunctionOverrides?: Array<TestFunctionOverride>
|
|
851
|
+
/**
|
|
852
|
+
* A list of EIP-712 canonical type definitions that can be referenced by
|
|
853
|
+
* type name in the `eip712HashType` and `eip712HashStruct` cheatcodes.
|
|
854
|
+
*
|
|
855
|
+
* Each entry is an independent, self-contained type definition. A
|
|
856
|
+
* definition that references nested struct types must inline those
|
|
857
|
+
* struct definitions, per the EIP-712 `encodeType` spec.
|
|
858
|
+
*
|
|
859
|
+
* Only the primary (leftmost) type of each entry is registered by name.
|
|
860
|
+
* Nested struct types referenced inside an entry are *not* registered
|
|
861
|
+
* under their own names. To look up a nested struct by name from a
|
|
862
|
+
* cheatcode, add it as a separate top-level entry whose primary type
|
|
863
|
+
* is the nested struct.
|
|
864
|
+
*
|
|
865
|
+
* The type of a struct is encoded as:
|
|
866
|
+
*
|
|
867
|
+
* `name ‖ "(" ‖ member₁ ‖ "," ‖ member₂ ‖ "," ‖ … ‖ memberₙ ")"`
|
|
868
|
+
*
|
|
869
|
+
* where each member is written as `type ‖ " " ‖ name`.
|
|
870
|
+
*
|
|
871
|
+
* Entries that fail to parse cause a startup error listing every bad
|
|
872
|
+
* entry.
|
|
873
|
+
*
|
|
874
|
+
* Example — to make both `Mail` and `Person` reachable by name:
|
|
875
|
+
*
|
|
876
|
+
* ```text
|
|
877
|
+
* "Mail(Person from,Person to,string contents)Person(address wallet,string name)"
|
|
878
|
+
* "Person(address wallet,string name)"
|
|
879
|
+
* ```
|
|
880
|
+
*
|
|
881
|
+
* With *only* the first entry, `vm.eip712HashType("Mail")` works but
|
|
882
|
+
* `vm.eip712HashType("Person")` fails with an unknown-type error.
|
|
883
|
+
*/
|
|
884
|
+
eip712CanonicalTypes?: Array<string>
|
|
746
885
|
}
|
|
747
886
|
/** Fuzz testing configuration */
|
|
748
887
|
export interface FuzzConfigArgs {
|
|
@@ -788,6 +927,16 @@ export interface FuzzConfigArgs {
|
|
|
788
927
|
* Defaults to true.
|
|
789
928
|
*/
|
|
790
929
|
includePushBytes?: boolean
|
|
930
|
+
/**
|
|
931
|
+
* Show `console.log` in fuzz test.
|
|
932
|
+
* Defaults to false.
|
|
933
|
+
*/
|
|
934
|
+
showLogs?: boolean
|
|
935
|
+
/**
|
|
936
|
+
* Optional timeout (in seconds) for each property test.
|
|
937
|
+
* Defaults to none (no timeout).
|
|
938
|
+
*/
|
|
939
|
+
timeout?: number
|
|
791
940
|
}
|
|
792
941
|
/** Invariant testing configuration. */
|
|
793
942
|
export interface InvariantConfigArgs {
|
|
@@ -838,6 +987,17 @@ export interface InvariantConfigArgs {
|
|
|
838
987
|
* Defaults to 5000.
|
|
839
988
|
*/
|
|
840
989
|
shrinkRunLimit?: number
|
|
990
|
+
/**
|
|
991
|
+
* The maximum number of rejects via `vm.assume` which can be encountered
|
|
992
|
+
* during a single invariant run.
|
|
993
|
+
* Defaults to 65536.
|
|
994
|
+
*/
|
|
995
|
+
maxAssumeRejects?: number
|
|
996
|
+
/**
|
|
997
|
+
* Optional timeout (in seconds) for each invariant test.
|
|
998
|
+
* Defaults to none (no timeout).
|
|
999
|
+
*/
|
|
1000
|
+
timeout?: number
|
|
841
1001
|
}
|
|
842
1002
|
/** Settings to configure caching of remote RPC endpoints. */
|
|
843
1003
|
export interface StorageCachingConfig {
|
|
@@ -921,17 +1081,104 @@ export enum CollectStackTraces {
|
|
|
921
1081
|
OnFailure = 1
|
|
922
1082
|
}
|
|
923
1083
|
/**
|
|
924
|
-
* Configuration
|
|
925
|
-
*
|
|
1084
|
+
* Configuration that controls whether execution traces are decoded and
|
|
1085
|
+
* included in results.
|
|
1086
|
+
*
|
|
1087
|
+
* This can either be for Solidity test results or provider transaction
|
|
1088
|
+
* execution results.
|
|
926
1089
|
*/
|
|
927
1090
|
export enum IncludeTraces {
|
|
928
|
-
/** No traces will be included
|
|
1091
|
+
/** No traces will be included at all. */
|
|
929
1092
|
None = 0,
|
|
930
|
-
/**
|
|
1093
|
+
/**
|
|
1094
|
+
* Traces will be included only on the results of failed tests or
|
|
1095
|
+
* execution.
|
|
1096
|
+
*/
|
|
931
1097
|
Failing = 1,
|
|
932
|
-
/** Traces will be included
|
|
1098
|
+
/** Traces will be included for all test results or executed transactions. */
|
|
933
1099
|
All = 2
|
|
934
1100
|
}
|
|
1101
|
+
/** Test function level config override. */
|
|
1102
|
+
export interface TestFunctionConfigOverride {
|
|
1103
|
+
/**
|
|
1104
|
+
* Allow expecting reverts with `expectRevert` at the same callstack depth
|
|
1105
|
+
* as the test.
|
|
1106
|
+
*/
|
|
1107
|
+
allowInternalExpectRevert?: boolean
|
|
1108
|
+
/**
|
|
1109
|
+
* Whether to enable isolation of calls for the test. In isolation mode all
|
|
1110
|
+
* top-level calls are executed as a separate transaction in a separate
|
|
1111
|
+
* EVM context, enabling more precise gas accounting and transaction
|
|
1112
|
+
* state changes.
|
|
1113
|
+
* Ignored when gas reporting is enabled, as isolation is required for
|
|
1114
|
+
* accurate gas measurements.
|
|
1115
|
+
*/
|
|
1116
|
+
isolate?: boolean
|
|
1117
|
+
/**
|
|
1118
|
+
* The EVM version to use for this test, e.g. "Cancun". This will override
|
|
1119
|
+
* the global EVM version.
|
|
1120
|
+
*/
|
|
1121
|
+
evmVersion?: string
|
|
1122
|
+
/** Configuration override for fuzz testing. */
|
|
1123
|
+
fuzz?: FuzzConfigOverride
|
|
1124
|
+
/** Configuration override for invariant testing. */
|
|
1125
|
+
invariant?: InvariantConfigOverride
|
|
1126
|
+
}
|
|
1127
|
+
/** Test function override configuration. */
|
|
1128
|
+
export interface TestFunctionOverride {
|
|
1129
|
+
/** The test function identifier. */
|
|
1130
|
+
identifier: TestFunctionIdentifier
|
|
1131
|
+
/** The configuration override. */
|
|
1132
|
+
config: TestFunctionConfigOverride
|
|
1133
|
+
}
|
|
1134
|
+
/** Test function identifier. */
|
|
1135
|
+
export interface TestFunctionIdentifier {
|
|
1136
|
+
/** The contract artifact id. */
|
|
1137
|
+
contractArtifact: ArtifactId
|
|
1138
|
+
/** The function selector as hex string. */
|
|
1139
|
+
functionSelector: string
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Timeout configuration.
|
|
1143
|
+
* Note: This wrapper is needed to avoid ambiguity with NAPI conversion.
|
|
1144
|
+
*/
|
|
1145
|
+
export interface TimeoutConfig {
|
|
1146
|
+
/** Optional timeout (in seconds). */
|
|
1147
|
+
time?: number
|
|
1148
|
+
}
|
|
1149
|
+
/** Test function or test contract level fuzz config override. */
|
|
1150
|
+
export interface FuzzConfigOverride {
|
|
1151
|
+
/** The number of test cases that must execute for each property test. */
|
|
1152
|
+
runs?: number
|
|
1153
|
+
/**
|
|
1154
|
+
* The maximum number of test case rejections allowed by proptest, to be
|
|
1155
|
+
* encountered during usage of `vm.assume` cheatcode. This will be used
|
|
1156
|
+
* to set the `max_global_rejects` value in proptest test runner config.
|
|
1157
|
+
* `max_local_rejects` option isn't exposed here since we're not using
|
|
1158
|
+
* `prop_filter`.
|
|
1159
|
+
*/
|
|
1160
|
+
maxTestRejects?: number
|
|
1161
|
+
/** show `console.log` in fuzz test, defaults to `false`. */
|
|
1162
|
+
showLogs?: boolean
|
|
1163
|
+
/** Optional timeout (in seconds) for each property test. */
|
|
1164
|
+
timeout?: TimeoutConfig
|
|
1165
|
+
}
|
|
1166
|
+
/** Test function or test contract level invariant config override. */
|
|
1167
|
+
export interface InvariantConfigOverride {
|
|
1168
|
+
/** The number of runs that must execute for each invariant test group. */
|
|
1169
|
+
runs?: number
|
|
1170
|
+
/** The number of calls executed to attempt to break invariants in one run. */
|
|
1171
|
+
depth?: number
|
|
1172
|
+
/** Fails the invariant fuzzing if a revert occurs. */
|
|
1173
|
+
failOnRevert?: boolean
|
|
1174
|
+
/**
|
|
1175
|
+
* Allows overriding an unsafe external call when running invariant tests.
|
|
1176
|
+
* eg. reentrancy checks
|
|
1177
|
+
*/
|
|
1178
|
+
callOverride?: boolean
|
|
1179
|
+
/** Optional timeout (in seconds) for each invariant test. */
|
|
1180
|
+
timeout?: TimeoutConfig
|
|
1181
|
+
}
|
|
935
1182
|
export declare function l1SolidityTestRunnerFactory(): SolidityTestRunnerFactory
|
|
936
1183
|
export declare function opSolidityTestRunnerFactory(): SolidityTestRunnerFactory
|
|
937
1184
|
/** A grouping of value snapshot entries for a test. */
|
|
@@ -1003,7 +1250,7 @@ export enum TestStatus {
|
|
|
1003
1250
|
/**Test skipped */
|
|
1004
1251
|
Skipped = 'Skipped'
|
|
1005
1252
|
}
|
|
1006
|
-
/** See [`edr_solidity_tests::result::TestKind::
|
|
1253
|
+
/** See [`edr_solidity_tests::result::TestKind::Unit`] */
|
|
1007
1254
|
export interface StandardTestKind {
|
|
1008
1255
|
/** The gas consumed by the test. */
|
|
1009
1256
|
readonly consumedGas: bigint
|
|
@@ -1034,6 +1281,16 @@ export interface InvariantTestKind {
|
|
|
1034
1281
|
readonly calls: bigint
|
|
1035
1282
|
/** See [`edr_solidity_tests::result::TestKind::Invariant`] */
|
|
1036
1283
|
readonly reverts: bigint
|
|
1284
|
+
/** See [`edr_solidity_tests::result::TestKind::Invariant`] */
|
|
1285
|
+
readonly metrics: Record<string, InvariantMetrics>
|
|
1286
|
+
/** See [`edr_solidity_tests::result::TestKind::Invariant`] */
|
|
1287
|
+
readonly failedCorpusReplays: bigint
|
|
1288
|
+
}
|
|
1289
|
+
/** See [`edr_solidity_tests::result::InvariantMetrics`] */
|
|
1290
|
+
export interface InvariantMetrics {
|
|
1291
|
+
readonly calls: bigint
|
|
1292
|
+
readonly reverts: bigint
|
|
1293
|
+
readonly discards: bigint
|
|
1037
1294
|
}
|
|
1038
1295
|
/**
|
|
1039
1296
|
* Original sequence size and sequence of calls used as a counter example
|
|
@@ -1348,6 +1605,7 @@ export interface CheatcodeErrorStackTraceEntry {
|
|
|
1348
1605
|
type: StackTraceEntryType.CHEATCODE_ERROR
|
|
1349
1606
|
message: string
|
|
1350
1607
|
sourceReference: SourceReference
|
|
1608
|
+
details?: CheatcodeErrorDetails
|
|
1351
1609
|
}
|
|
1352
1610
|
export interface TracingMessage {
|
|
1353
1611
|
/** Sender address */
|
|
@@ -1392,11 +1650,6 @@ export interface TracingMessageResult {
|
|
|
1392
1650
|
/** Execution result */
|
|
1393
1651
|
readonly executionResult: ExecutionResult
|
|
1394
1652
|
}
|
|
1395
|
-
/**
|
|
1396
|
-
* Returns the latest version of solc that EDR officially
|
|
1397
|
-
* supports and is tested against.
|
|
1398
|
-
*/
|
|
1399
|
-
export declare function getLatestSupportedSolcVersion(): string
|
|
1400
1653
|
export interface Withdrawal {
|
|
1401
1654
|
/** The index of withdrawal */
|
|
1402
1655
|
index: bigint
|
|
@@ -1455,9 +1708,15 @@ export declare class Response {
|
|
|
1455
1708
|
/**Returns the response data as a JSON string or a JSON object. */
|
|
1456
1709
|
get data(): string | any
|
|
1457
1710
|
/**Compute the error stack trace. Return the stack trace if it can be decoded, otherwise returns none. Throws if there was an error computing the stack trace. */
|
|
1458
|
-
stackTrace():
|
|
1459
|
-
/**
|
|
1460
|
-
|
|
1711
|
+
stackTrace(): StackTrace | UnexpectedError | HeuristicFailed | null
|
|
1712
|
+
/**
|
|
1713
|
+
* Constructs the execution traces for the request. Returns an empty array
|
|
1714
|
+
* if traces are not enabled for this provider according to
|
|
1715
|
+
* [`crate::solidity_tests::config::SolidityTestRunnerConfigArgs::include_traces`]. Otherwise, returns
|
|
1716
|
+
* an array of the root calls of the trace, which always includes the
|
|
1717
|
+
* request's call itself.
|
|
1718
|
+
*/
|
|
1719
|
+
callTraces(): Array<CallTrace>
|
|
1461
1720
|
}
|
|
1462
1721
|
/** A JSON-RPC provider for Ethereum. */
|
|
1463
1722
|
export declare class Provider {
|
package/index.js
CHANGED
|
@@ -310,7 +310,7 @@ if (!nativeBinding) {
|
|
|
310
310
|
throw new Error(`Failed to load native binding`)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
const { GENERIC_CHAIN_TYPE, genericChainProviderFactory, L1_CHAIN_TYPE, l1GenesisState, l1ProviderFactory, SpecId, l1HardforkFromString, l1HardforkToString, l1HardforkLatest, FRONTIER, FRONTIER_THAWING, HOMESTEAD, DAO_FORK, TANGERINE, SPURIOUS_DRAGON, BYZANTIUM, CONSTANTINOPLE, PETERSBURG, ISTANBUL, MUIR_GLACIER, BERLIN, LONDON, ARROW_GLACIER, GRAY_GLACIER, MERGE, SHANGHAI, CANCUN, PRAGUE, OpHardfork, opHardforkFromString, opHardforkToString, opLatestHardfork, OP_CHAIN_TYPE, opGenesisState, opProviderFactory, BEDROCK, REGOLITH, CANYON, ECOTONE, FJORD, GRANITE, HOLOCENE, ISTHMUS, MineOrdering, EdrContext, ContractDecoder, GasReportExecutionStatus, addStatementCoverageInstrumentation, Precompile, precompileP256Verify, ProviderFactory, Response, Provider, SuccessReason, ExceptionalHalt, CachedChains, CachedEndpoints, FsAccessPermission, CollectStackTraces, IncludeTraces, SolidityTestRunnerFactory, l1SolidityTestRunnerFactory, opSolidityTestRunnerFactory, SuiteResult, TestResult, TestStatus, CallKind, LogKind, linkHexStringBytecode, printStackTrace, Exit, ExitCode, BytecodeWrapper, ContractFunctionType, ReturnData, StackTraceEntryType, stackTraceEntryTypeToString, FALLBACK_FUNCTION_NAME, RECEIVE_FUNCTION_NAME, CONSTRUCTOR_FUNCTION_NAME, UNRECOGNIZED_FUNCTION_NAME, UNKNOWN_FUNCTION_NAME, PRECOMPILE_FUNCTION_NAME, UNRECOGNIZED_CONTRACT_NAME, RawTrace
|
|
313
|
+
const { GENERIC_CHAIN_TYPE, genericChainProviderFactory, L1_CHAIN_TYPE, l1GenesisState, l1ProviderFactory, SpecId, l1HardforkFromString, l1HardforkToString, l1HardforkLatest, FRONTIER, FRONTIER_THAWING, HOMESTEAD, DAO_FORK, TANGERINE, SPURIOUS_DRAGON, BYZANTIUM, CONSTANTINOPLE, PETERSBURG, ISTANBUL, MUIR_GLACIER, BERLIN, LONDON, ARROW_GLACIER, GRAY_GLACIER, MERGE, SHANGHAI, CANCUN, PRAGUE, OSAKA, OpHardfork, opHardforkFromString, opHardforkToString, opLatestHardfork, OP_CHAIN_TYPE, opGenesisState, opProviderFactory, BEDROCK, REGOLITH, CANYON, ECOTONE, FJORD, GRANITE, HOLOCENE, ISTHMUS, GasEstimationMode, MineOrdering, EdrContext, ContractDecoder, GasReportExecutionStatus, COVERAGE_LIBRARY_FILE_NAME, addStatementCoverageInstrumentation, latestSupportedSolidityVersion, Precompile, precompileP256Verify, ProviderFactory, Response, Provider, SuccessReason, ExceptionalHalt, CheatcodeErrorCode, CachedChains, CachedEndpoints, FsAccessPermission, CollectStackTraces, IncludeTraces, SolidityTestRunnerFactory, l1SolidityTestRunnerFactory, opSolidityTestRunnerFactory, SuiteResult, TestResult, TestStatus, CallKind, LogKind, linkHexStringBytecode, printStackTrace, Exit, ExitCode, BytecodeWrapper, ContractFunctionType, ReturnData, StackTraceEntryType, stackTraceEntryTypeToString, FALLBACK_FUNCTION_NAME, RECEIVE_FUNCTION_NAME, CONSTRUCTOR_FUNCTION_NAME, UNRECOGNIZED_FUNCTION_NAME, UNKNOWN_FUNCTION_NAME, PRECOMPILE_FUNCTION_NAME, UNRECOGNIZED_CONTRACT_NAME, RawTrace } = nativeBinding
|
|
314
314
|
|
|
315
315
|
module.exports.GENERIC_CHAIN_TYPE = GENERIC_CHAIN_TYPE
|
|
316
316
|
module.exports.genericChainProviderFactory = genericChainProviderFactory
|
|
@@ -340,6 +340,7 @@ module.exports.MERGE = MERGE
|
|
|
340
340
|
module.exports.SHANGHAI = SHANGHAI
|
|
341
341
|
module.exports.CANCUN = CANCUN
|
|
342
342
|
module.exports.PRAGUE = PRAGUE
|
|
343
|
+
module.exports.OSAKA = OSAKA
|
|
343
344
|
module.exports.OpHardfork = OpHardfork
|
|
344
345
|
module.exports.opHardforkFromString = opHardforkFromString
|
|
345
346
|
module.exports.opHardforkToString = opHardforkToString
|
|
@@ -355,11 +356,14 @@ module.exports.FJORD = FJORD
|
|
|
355
356
|
module.exports.GRANITE = GRANITE
|
|
356
357
|
module.exports.HOLOCENE = HOLOCENE
|
|
357
358
|
module.exports.ISTHMUS = ISTHMUS
|
|
359
|
+
module.exports.GasEstimationMode = GasEstimationMode
|
|
358
360
|
module.exports.MineOrdering = MineOrdering
|
|
359
361
|
module.exports.EdrContext = EdrContext
|
|
360
362
|
module.exports.ContractDecoder = ContractDecoder
|
|
361
363
|
module.exports.GasReportExecutionStatus = GasReportExecutionStatus
|
|
364
|
+
module.exports.COVERAGE_LIBRARY_FILE_NAME = COVERAGE_LIBRARY_FILE_NAME
|
|
362
365
|
module.exports.addStatementCoverageInstrumentation = addStatementCoverageInstrumentation
|
|
366
|
+
module.exports.latestSupportedSolidityVersion = latestSupportedSolidityVersion
|
|
363
367
|
module.exports.Precompile = Precompile
|
|
364
368
|
module.exports.precompileP256Verify = precompileP256Verify
|
|
365
369
|
module.exports.ProviderFactory = ProviderFactory
|
|
@@ -367,6 +371,7 @@ module.exports.Response = Response
|
|
|
367
371
|
module.exports.Provider = Provider
|
|
368
372
|
module.exports.SuccessReason = SuccessReason
|
|
369
373
|
module.exports.ExceptionalHalt = ExceptionalHalt
|
|
374
|
+
module.exports.CheatcodeErrorCode = CheatcodeErrorCode
|
|
370
375
|
module.exports.CachedChains = CachedChains
|
|
371
376
|
module.exports.CachedEndpoints = CachedEndpoints
|
|
372
377
|
module.exports.FsAccessPermission = FsAccessPermission
|
|
@@ -397,4 +402,3 @@ module.exports.UNKNOWN_FUNCTION_NAME = UNKNOWN_FUNCTION_NAME
|
|
|
397
402
|
module.exports.PRECOMPILE_FUNCTION_NAME = PRECOMPILE_FUNCTION_NAME
|
|
398
403
|
module.exports.UNRECOGNIZED_CONTRACT_NAME = UNRECOGNIZED_CONTRACT_NAME
|
|
399
404
|
module.exports.RawTrace = RawTrace
|
|
400
|
-
module.exports.getLatestSupportedSolcVersion = getLatestSupportedSolcVersion
|