@nomicfoundation/edr 0.12.0-next.14 → 0.12.0-next.15
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/index.d.ts +21 -4
- package/index.js +2 -1
- package/package.json +8 -8
- package/src/account.rs +1 -1
- package/src/chains/l1.rs +7 -1
- package/src/context.rs +2 -2
- package/src/precompile.rs +5 -5
- package/src/result.rs +4 -2
- package/src/solidity_tests/config.rs +13 -7
- package/src/solidity_tests/test_results.rs +60 -6
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,
|
|
@@ -586,8 +589,6 @@ export interface SolidityTestRunnerConfigArgs {
|
|
|
586
589
|
projectRoot: string
|
|
587
590
|
/** Configures the permissions of cheat codes that access the file system. */
|
|
588
591
|
fsPermissions?: Array<PathPermission>
|
|
589
|
-
/** Whether to support the `testFail` prefix. Defaults to false. */
|
|
590
|
-
testFail?: boolean
|
|
591
592
|
/** Address labels for traces. Defaults to none. */
|
|
592
593
|
labels?: Array<AddressLabel>
|
|
593
594
|
/**
|
|
@@ -838,6 +839,12 @@ export interface InvariantConfigArgs {
|
|
|
838
839
|
* Defaults to 5000.
|
|
839
840
|
*/
|
|
840
841
|
shrinkRunLimit?: number
|
|
842
|
+
/**
|
|
843
|
+
* The maximum number of rejects via `vm.assume` which can be encountered
|
|
844
|
+
* during a single invariant run.
|
|
845
|
+
* Defaults to 65536.
|
|
846
|
+
*/
|
|
847
|
+
maxAssumeRejects?: number
|
|
841
848
|
}
|
|
842
849
|
/** Settings to configure caching of remote RPC endpoints. */
|
|
843
850
|
export interface StorageCachingConfig {
|
|
@@ -1003,7 +1010,7 @@ export enum TestStatus {
|
|
|
1003
1010
|
/**Test skipped */
|
|
1004
1011
|
Skipped = 'Skipped'
|
|
1005
1012
|
}
|
|
1006
|
-
/** See [`edr_solidity_tests::result::TestKind::
|
|
1013
|
+
/** See [`edr_solidity_tests::result::TestKind::Unit`] */
|
|
1007
1014
|
export interface StandardTestKind {
|
|
1008
1015
|
/** The gas consumed by the test. */
|
|
1009
1016
|
readonly consumedGas: bigint
|
|
@@ -1034,6 +1041,16 @@ export interface InvariantTestKind {
|
|
|
1034
1041
|
readonly calls: bigint
|
|
1035
1042
|
/** See [`edr_solidity_tests::result::TestKind::Invariant`] */
|
|
1036
1043
|
readonly reverts: bigint
|
|
1044
|
+
/** See [`edr_solidity_tests::result::TestKind::Invariant`] */
|
|
1045
|
+
readonly metrics: Record<string, InvariantMetrics>
|
|
1046
|
+
/** See [`edr_solidity_tests::result::TestKind::Invariant`] */
|
|
1047
|
+
readonly failedCorpusReplays: bigint
|
|
1048
|
+
}
|
|
1049
|
+
/** See [`edr_solidity_tests::result::InvariantMetrics`] */
|
|
1050
|
+
export interface InvariantMetrics {
|
|
1051
|
+
readonly calls: bigint
|
|
1052
|
+
readonly reverts: bigint
|
|
1053
|
+
readonly discards: bigint
|
|
1037
1054
|
}
|
|
1038
1055
|
/**
|
|
1039
1056
|
* Original sequence size and sequence of calls used as a counter example
|
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, getLatestSupportedSolcVersion } = nativeBinding
|
|
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, 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, getLatestSupportedSolcVersion } = 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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomicfoundation/edr",
|
|
3
|
-
"version": "0.12.0-next.
|
|
3
|
+
"version": "0.12.0-next.15",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@napi-rs/cli": "^2.18.4",
|
|
6
6
|
"@nomicfoundation/ethereumjs-util": "^9.0.4",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"repository": "NomicFoundation/edr.git",
|
|
59
59
|
"types": "index.d.ts",
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@nomicfoundation/edr-darwin-arm64": "0.12.0-next.
|
|
62
|
-
"@nomicfoundation/edr-darwin-x64": "0.12.0-next.
|
|
63
|
-
"@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.
|
|
64
|
-
"@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.
|
|
65
|
-
"@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.
|
|
66
|
-
"@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.
|
|
67
|
-
"@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.
|
|
61
|
+
"@nomicfoundation/edr-darwin-arm64": "0.12.0-next.15",
|
|
62
|
+
"@nomicfoundation/edr-darwin-x64": "0.12.0-next.15",
|
|
63
|
+
"@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.15",
|
|
64
|
+
"@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.15",
|
|
65
|
+
"@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.15",
|
|
66
|
+
"@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.15",
|
|
67
|
+
"@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.15"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"artifacts": "napi artifacts",
|
package/src/account.rs
CHANGED
|
@@ -82,7 +82,7 @@ impl TryFrom<AccountOverride> for Predeploy {
|
|
|
82
82
|
fn try_from(value: AccountOverride) -> Result<Self, Self::Error> {
|
|
83
83
|
let (address, account_override) = value.try_into()?;
|
|
84
84
|
|
|
85
|
-
let storage = account_override.storage.unwrap_or_else(HashMap::
|
|
85
|
+
let storage = account_override.storage.unwrap_or_else(HashMap::default);
|
|
86
86
|
let balance = account_override.balance.unwrap_or(U256::ZERO);
|
|
87
87
|
let nonce = account_override.nonce.unwrap_or(0);
|
|
88
88
|
let code = account_override.code.ok_or_else(|| {
|
package/src/chains/l1.rs
CHANGED
|
@@ -135,6 +135,8 @@ pub enum SpecId {
|
|
|
135
135
|
Cancun = 17,
|
|
136
136
|
/// Prague
|
|
137
137
|
Prague = 18,
|
|
138
|
+
/// Osaka
|
|
139
|
+
Osaka = 19,
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
impl FromStr for SpecId {
|
|
@@ -161,6 +163,7 @@ impl FromStr for SpecId {
|
|
|
161
163
|
edr_chain_l1::chains::name::SHANGHAI => Ok(SpecId::Shanghai),
|
|
162
164
|
edr_chain_l1::chains::name::CANCUN => Ok(SpecId::Cancun),
|
|
163
165
|
edr_chain_l1::chains::name::PRAGUE => Ok(SpecId::Prague),
|
|
166
|
+
edr_chain_l1::chains::name::OSAKA => Ok(SpecId::Osaka),
|
|
164
167
|
_ => Err(napi::Error::new(
|
|
165
168
|
napi::Status::InvalidArg,
|
|
166
169
|
format!("The provided hardfork `{s}` is not supported."),
|
|
@@ -191,6 +194,7 @@ impl From<SpecId> for edr_chain_l1::Hardfork {
|
|
|
191
194
|
SpecId::Shanghai => edr_chain_l1::Hardfork::SHANGHAI,
|
|
192
195
|
SpecId::Cancun => edr_chain_l1::Hardfork::CANCUN,
|
|
193
196
|
SpecId::Prague => edr_chain_l1::Hardfork::PRAGUE,
|
|
197
|
+
SpecId::Osaka => edr_chain_l1::Hardfork::OSAKA,
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
200
|
}
|
|
@@ -225,6 +229,7 @@ pub fn l1_hardfork_to_string(harfork: SpecId) -> &'static str {
|
|
|
225
229
|
SpecId::Shanghai => edr_chain_l1::chains::name::SHANGHAI,
|
|
226
230
|
SpecId::Cancun => edr_chain_l1::chains::name::CANCUN,
|
|
227
231
|
SpecId::Prague => edr_chain_l1::chains::name::PRAGUE,
|
|
232
|
+
SpecId::Osaka => edr_chain_l1::chains::name::OSAKA,
|
|
228
233
|
}
|
|
229
234
|
}
|
|
230
235
|
|
|
@@ -264,5 +269,6 @@ export_spec_id!(
|
|
|
264
269
|
MERGE,
|
|
265
270
|
SHANGHAI,
|
|
266
271
|
CANCUN,
|
|
267
|
-
PRAGUE
|
|
272
|
+
PRAGUE,
|
|
273
|
+
OSAKA
|
|
268
274
|
);
|
package/src/context.rs
CHANGED
|
@@ -390,8 +390,8 @@ impl Context {
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
Ok(Self {
|
|
393
|
-
provider_factories: HashMap::
|
|
394
|
-
solidity_test_runner_factories: HashMap::
|
|
393
|
+
provider_factories: HashMap::default(),
|
|
394
|
+
solidity_test_runner_factories: HashMap::default(),
|
|
395
395
|
#[cfg(feature = "tracing")]
|
|
396
396
|
_tracing_write_guard: guard,
|
|
397
397
|
})
|
package/src/precompile.rs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
use edr_precompile::
|
|
1
|
+
use edr_precompile::PrecompileFn;
|
|
2
2
|
use edr_primitives::Address;
|
|
3
3
|
use napi::bindgen_prelude::Uint8Array;
|
|
4
4
|
use napi_derive::napi;
|
|
@@ -24,11 +24,11 @@ impl Precompile {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
impl From<
|
|
28
|
-
fn from(value:
|
|
27
|
+
impl From<edr_precompile::Precompile> for Precompile {
|
|
28
|
+
fn from(value: edr_precompile::Precompile) -> Self {
|
|
29
29
|
Self {
|
|
30
|
-
address: value.
|
|
31
|
-
precompile_fn: value.
|
|
30
|
+
address: *value.address(),
|
|
31
|
+
precompile_fn: value.into_precompile(),
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/result.rs
CHANGED
|
@@ -112,7 +112,9 @@ impl From<EvmHaltReason> for ExceptionalHalt {
|
|
|
112
112
|
EvmHaltReason::StackOverflow => ExceptionalHalt::StackOverflow,
|
|
113
113
|
EvmHaltReason::OutOfOffset => ExceptionalHalt::OutOfOffset,
|
|
114
114
|
EvmHaltReason::CreateCollision => ExceptionalHalt::CreateCollision,
|
|
115
|
-
EvmHaltReason::PrecompileError =>
|
|
115
|
+
EvmHaltReason::PrecompileError | EvmHaltReason::PrecompileErrorWithContext(_) => {
|
|
116
|
+
ExceptionalHalt::PrecompileError
|
|
117
|
+
}
|
|
116
118
|
EvmHaltReason::NonceOverflow => ExceptionalHalt::NonceOverflow,
|
|
117
119
|
EvmHaltReason::CreateContractSizeLimit => ExceptionalHalt::CreateContractSizeLimit,
|
|
118
120
|
EvmHaltReason::CreateContractStartingWithEF => {
|
|
@@ -198,7 +200,7 @@ impl From<&AfterMessage<EvmHaltReason>> for ExecutionResult {
|
|
|
198
200
|
}
|
|
199
201
|
edr_evm_spec::result::ExecutionResult::Halt { reason, gas_used } => {
|
|
200
202
|
Either3::C(HaltResult {
|
|
201
|
-
reason: ExceptionalHalt::from(
|
|
203
|
+
reason: ExceptionalHalt::from(reason.clone()),
|
|
202
204
|
gas_used: BigInt::from(*gas_used),
|
|
203
205
|
})
|
|
204
206
|
}
|
|
@@ -8,7 +8,7 @@ use edr_solidity_tests::{
|
|
|
8
8
|
inspectors::cheatcodes::{CheatsConfigOptions, ExecutionContextConfig},
|
|
9
9
|
TestFilterConfig,
|
|
10
10
|
};
|
|
11
|
-
use foundry_cheatcodes::{FsPermissions,
|
|
11
|
+
use foundry_cheatcodes::{FsPermissions, RpcEndpointUrl, RpcEndpoints};
|
|
12
12
|
use napi::{
|
|
13
13
|
bindgen_prelude::{BigInt, Uint8Array},
|
|
14
14
|
tokio::runtime,
|
|
@@ -36,8 +36,6 @@ pub struct SolidityTestRunnerConfigArgs {
|
|
|
36
36
|
pub project_root: String,
|
|
37
37
|
/// Configures the permissions of cheat codes that access the file system.
|
|
38
38
|
pub fs_permissions: Option<Vec<PathPermission>>,
|
|
39
|
-
/// Whether to support the `testFail` prefix. Defaults to false.
|
|
40
|
-
pub test_fail: Option<bool>,
|
|
41
39
|
/// Address labels for traces. Defaults to none.
|
|
42
40
|
pub labels: Option<Vec<AddressLabel>>,
|
|
43
41
|
/// Whether to enable isolation of calls. In isolation mode all top-level
|
|
@@ -173,7 +171,6 @@ impl SolidityTestRunnerConfigArgs {
|
|
|
173
171
|
let SolidityTestRunnerConfigArgs {
|
|
174
172
|
project_root,
|
|
175
173
|
fs_permissions,
|
|
176
|
-
test_fail,
|
|
177
174
|
labels,
|
|
178
175
|
isolate,
|
|
179
176
|
ffi,
|
|
@@ -246,7 +243,7 @@ impl SolidityTestRunnerConfigArgs {
|
|
|
246
243
|
RpcEndpoints::new(
|
|
247
244
|
endpoints
|
|
248
245
|
.into_iter()
|
|
249
|
-
.map(|(chain, url)| (chain,
|
|
246
|
+
.map(|(chain, url)| (chain, RpcEndpointUrl::new(url))),
|
|
250
247
|
)
|
|
251
248
|
})
|
|
252
249
|
.unwrap_or_default(),
|
|
@@ -267,6 +264,7 @@ impl SolidityTestRunnerConfigArgs {
|
|
|
267
264
|
.into_iter()
|
|
268
265
|
.map(|AddressLabel { address, label }| Ok((address.try_cast()?, label)))
|
|
269
266
|
.collect::<Result<_, napi::Error>>()?,
|
|
267
|
+
seed: fuzz.seed,
|
|
270
268
|
allow_internal_expect_revert: allow_internal_expect_revert.unwrap_or(false),
|
|
271
269
|
};
|
|
272
270
|
|
|
@@ -282,7 +280,6 @@ impl SolidityTestRunnerConfigArgs {
|
|
|
282
280
|
let config = edr_napi_core::solidity::config::TestRunnerConfig {
|
|
283
281
|
project_root: project_root.into(),
|
|
284
282
|
include_traces: include_traces.unwrap_or_default().into(),
|
|
285
|
-
test_fail: test_fail.unwrap_or_default(),
|
|
286
283
|
isolate,
|
|
287
284
|
ffi,
|
|
288
285
|
sender: sender.map(TryCast::try_cast).transpose()?,
|
|
@@ -370,7 +367,7 @@ impl TryFrom<FuzzConfigArgs> for FuzzConfig {
|
|
|
370
367
|
} = value;
|
|
371
368
|
|
|
372
369
|
let failure_persist_dir = failure_persist_dir.map(PathBuf::from);
|
|
373
|
-
let failure_persist_file = failure_persist_file.
|
|
370
|
+
let failure_persist_file = failure_persist_file.unwrap_or_else(|| "failures".to_string());
|
|
374
371
|
let seed = seed
|
|
375
372
|
.map(|s| {
|
|
376
373
|
s.parse().map_err(|_err| {
|
|
@@ -461,6 +458,10 @@ pub struct InvariantConfigArgs {
|
|
|
461
458
|
/// process is disabled if set to 0.
|
|
462
459
|
/// Defaults to 5000.
|
|
463
460
|
pub shrink_run_limit: Option<u32>,
|
|
461
|
+
/// The maximum number of rejects via `vm.assume` which can be encountered
|
|
462
|
+
/// during a single invariant run.
|
|
463
|
+
/// Defaults to 65536.
|
|
464
|
+
pub max_assume_rejects: Option<u32>,
|
|
464
465
|
}
|
|
465
466
|
|
|
466
467
|
impl InvariantConfigArgs {
|
|
@@ -514,6 +515,7 @@ impl From<InvariantConfigArgs> for InvariantConfig {
|
|
|
514
515
|
include_storage,
|
|
515
516
|
include_push_bytes,
|
|
516
517
|
shrink_run_limit,
|
|
518
|
+
max_assume_rejects,
|
|
517
519
|
} = value;
|
|
518
520
|
|
|
519
521
|
let failure_persist_dir = failure_persist_dir.map(PathBuf::from);
|
|
@@ -557,6 +559,10 @@ impl From<InvariantConfigArgs> for InvariantConfig {
|
|
|
557
559
|
invariant.shrink_run_limit = shrink_run_limit;
|
|
558
560
|
}
|
|
559
561
|
|
|
562
|
+
if let Some(max_assume_rejects) = max_assume_rejects {
|
|
563
|
+
invariant.max_assume_rejects = max_assume_rejects;
|
|
564
|
+
}
|
|
565
|
+
|
|
560
566
|
invariant
|
|
561
567
|
}
|
|
562
568
|
}
|
|
@@ -264,7 +264,7 @@ impl TestResult {
|
|
|
264
264
|
}),
|
|
265
265
|
decoded_logs: test_result.decoded_logs,
|
|
266
266
|
kind: match test_result.kind {
|
|
267
|
-
edr_solidity_tests::result::TestKind::
|
|
267
|
+
edr_solidity_tests::result::TestKind::Unit { gas: gas_consumed } => {
|
|
268
268
|
Either3::A(StandardTestKind {
|
|
269
269
|
consumed_gas: BigInt::from(gas_consumed),
|
|
270
270
|
})
|
|
@@ -283,11 +283,27 @@ impl TestResult {
|
|
|
283
283
|
runs,
|
|
284
284
|
calls,
|
|
285
285
|
reverts,
|
|
286
|
+
metrics,
|
|
287
|
+
failed_corpus_replays,
|
|
286
288
|
} => Either3::C(InvariantTestKind {
|
|
287
289
|
// usize as u64 is always safe
|
|
288
290
|
runs: BigInt::from(runs as u64),
|
|
289
291
|
calls: BigInt::from(calls as u64),
|
|
290
292
|
reverts: BigInt::from(reverts as u64),
|
|
293
|
+
metrics: metrics
|
|
294
|
+
.into_iter()
|
|
295
|
+
.map(|(name, metric)| {
|
|
296
|
+
(
|
|
297
|
+
name,
|
|
298
|
+
InvariantMetrics {
|
|
299
|
+
calls: BigInt::from(metric.calls as u64),
|
|
300
|
+
reverts: BigInt::from(metric.reverts as u64),
|
|
301
|
+
discards: BigInt::from(metric.discards as u64),
|
|
302
|
+
},
|
|
303
|
+
)
|
|
304
|
+
})
|
|
305
|
+
.collect(),
|
|
306
|
+
failed_corpus_replays: BigInt::from(failed_corpus_replays as u64),
|
|
291
307
|
}),
|
|
292
308
|
},
|
|
293
309
|
duration_ns: BigInt::from(test_result.duration.as_nanos()),
|
|
@@ -336,7 +352,7 @@ impl From<edr_solidity_tests::result::TestStatus> for TestStatus {
|
|
|
336
352
|
}
|
|
337
353
|
}
|
|
338
354
|
|
|
339
|
-
/// See [`edr_solidity_tests::result::TestKind::
|
|
355
|
+
/// See [`edr_solidity_tests::result::TestKind::Unit`]
|
|
340
356
|
#[napi(object)]
|
|
341
357
|
#[derive(Debug, Clone)]
|
|
342
358
|
pub struct StandardTestKind {
|
|
@@ -397,6 +413,27 @@ pub struct InvariantTestKind {
|
|
|
397
413
|
/// See [`edr_solidity_tests::result::TestKind::Invariant`]
|
|
398
414
|
#[napi(readonly)]
|
|
399
415
|
pub reverts: BigInt,
|
|
416
|
+
/// See [`edr_solidity_tests::result::TestKind::Invariant`]
|
|
417
|
+
#[napi(readonly)]
|
|
418
|
+
pub metrics: std::collections::HashMap<String, InvariantMetrics>,
|
|
419
|
+
/// See [`edr_solidity_tests::result::TestKind::Invariant`]
|
|
420
|
+
#[napi(readonly)]
|
|
421
|
+
pub failed_corpus_replays: BigInt,
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/// See [`edr_solidity_tests::result::InvariantMetrics`]
|
|
425
|
+
#[napi(object)]
|
|
426
|
+
#[derive(Debug, Clone)]
|
|
427
|
+
pub struct InvariantMetrics {
|
|
428
|
+
// Count of fuzzed selector calls.
|
|
429
|
+
#[napi(readonly)]
|
|
430
|
+
pub calls: BigInt,
|
|
431
|
+
// Count of fuzzed selector reverts.
|
|
432
|
+
#[napi(readonly)]
|
|
433
|
+
pub reverts: BigInt,
|
|
434
|
+
// Count of fuzzed selector discards (through assume cheatcodes).
|
|
435
|
+
#[napi(readonly)]
|
|
436
|
+
pub discards: BigInt,
|
|
400
437
|
}
|
|
401
438
|
|
|
402
439
|
/// Original sequence size and sequence of calls used as a counter example
|
|
@@ -543,10 +580,19 @@ impl CallTrace {
|
|
|
543
580
|
/// Instantiates a `CallTrace` with the details from a node and the supplied
|
|
544
581
|
/// children.
|
|
545
582
|
fn new(node: &traces::CallTraceNode, children: Vec<Either<CallTrace, LogTrace>>) -> Self {
|
|
546
|
-
let contract = node
|
|
583
|
+
let contract = node
|
|
584
|
+
.trace
|
|
585
|
+
.decoded
|
|
586
|
+
.as_ref()
|
|
587
|
+
.and_then(|decoded| decoded.label.clone());
|
|
547
588
|
let address = node.trace.address.to_checksum(None);
|
|
548
589
|
|
|
549
|
-
let inputs = match &node
|
|
590
|
+
let inputs = match &node
|
|
591
|
+
.trace
|
|
592
|
+
.decoded
|
|
593
|
+
.as_ref()
|
|
594
|
+
.and_then(|decoded| decoded.call_data.as_ref())
|
|
595
|
+
{
|
|
550
596
|
Some(traces::DecodedCallData { signature, args }) => {
|
|
551
597
|
let name = signature
|
|
552
598
|
.split('(')
|
|
@@ -559,7 +605,12 @@ impl CallTrace {
|
|
|
559
605
|
None => Either::B(node.trace.data.as_ref().into()),
|
|
560
606
|
};
|
|
561
607
|
|
|
562
|
-
let outputs = match
|
|
608
|
+
let outputs = match node
|
|
609
|
+
.trace
|
|
610
|
+
.decoded
|
|
611
|
+
.as_ref()
|
|
612
|
+
.and_then(|decoded| decoded.return_data.as_ref())
|
|
613
|
+
{
|
|
563
614
|
Some(outputs) => Either::A(outputs.clone()),
|
|
564
615
|
None => {
|
|
565
616
|
if node.kind().is_any_create() && node.trace.success {
|
|
@@ -676,7 +727,10 @@ impl CallTrace {
|
|
|
676
727
|
|
|
677
728
|
impl From<&traces::CallLog> for LogTrace {
|
|
678
729
|
fn from(log: &traces::CallLog) -> Self {
|
|
679
|
-
let decoded_log = log
|
|
730
|
+
let decoded_log = log
|
|
731
|
+
.decoded
|
|
732
|
+
.as_ref()
|
|
733
|
+
.and_then(|decoded| decoded.name.clone().zip(decoded.params.as_ref()));
|
|
680
734
|
|
|
681
735
|
let parameters = decoded_log.map_or_else(
|
|
682
736
|
|| {
|