mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 06:48:03 +00:00
Merge branch 'main' into pvm-link-bug
This commit is contained in:
@@ -7,6 +7,10 @@ repository.workspace = true
|
||||
authors.workspace = true
|
||||
description = "Execute revive contracts in a simulated blockchain runtime"
|
||||
|
||||
[features]
|
||||
default = ["solidity"]
|
||||
solidity = ["revive-solidity", "revive-differential"]
|
||||
|
||||
[dependencies]
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
@@ -24,5 +28,5 @@ polkadot-sdk.features = [
|
||||
"pallet-timestamp"
|
||||
]
|
||||
|
||||
revive-solidity = { workspace = true }
|
||||
revive-differential = { workspace = true }
|
||||
revive-solidity = { workspace = true, optional = true }
|
||||
revive-differential = { workspace = true, optional = true }
|
||||
|
||||
@@ -44,6 +44,10 @@ pub use crate::specs::*;
|
||||
mod runtime;
|
||||
mod specs;
|
||||
|
||||
#[cfg(not(feature = "revive-solidity"))]
|
||||
pub(crate) const NO_SOLIDITY_FRONTEND: &str =
|
||||
"revive-runner was built without the solidity frontend; please enable the 'solidity' feature!";
|
||||
|
||||
/// The alice test account
|
||||
pub const ALICE: H160 = H160([1u8; 20]);
|
||||
/// The bob test account
|
||||
@@ -218,6 +222,7 @@ impl CallResult {
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum Code {
|
||||
#[cfg(feature = "revive-solidity")]
|
||||
/// Compile a single solidity source and use the blob of `contract`
|
||||
Solidity {
|
||||
path: Option<std::path::PathBuf>,
|
||||
@@ -242,6 +247,7 @@ impl Default for Code {
|
||||
impl From<Code> for pallet_revive::Code {
|
||||
fn from(val: Code) -> Self {
|
||||
match val {
|
||||
#[cfg(feature = "solidity")]
|
||||
Code::Solidity {
|
||||
path,
|
||||
contract,
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
use std::time::Instant;
|
||||
|
||||
use pallet_revive::AddressMapper;
|
||||
use revive_differential::{Evm, EvmLog};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::*;
|
||||
use alloy_primitives::Address;
|
||||
#[cfg(feature = "revive-solidity")]
|
||||
use revive_differential::{Evm, EvmLog};
|
||||
#[cfg(feature = "revive-solidity")]
|
||||
use revive_solidity::test_utils::*;
|
||||
|
||||
const SPEC_MARKER_BEGIN: &str = "/* runner.json";
|
||||
@@ -72,6 +74,7 @@ pub enum SpecsAction {
|
||||
},
|
||||
}
|
||||
|
||||
#[cfg(feature = "solidity")]
|
||||
impl SpecsAction {
|
||||
/// Derive verification actions from the EVM output log
|
||||
pub fn derive_verification(
|
||||
@@ -219,6 +222,7 @@ impl Specs {
|
||||
};
|
||||
|
||||
match code {
|
||||
#[cfg(feature = "revive-solidity")]
|
||||
Code::Bytes(bytes) if bytes.is_empty() => {
|
||||
let contract_source = match std::fs::read_to_string(contract_path) {
|
||||
Err(err) => panic!("unable to read {contract_path}: {err}"),
|
||||
@@ -226,6 +230,9 @@ impl Specs {
|
||||
};
|
||||
*bytes = compile_blob(contract_name, &contract_source)
|
||||
}
|
||||
#[cfg(not(feature = "revive-solidity"))]
|
||||
Code::Bytes(_) => panic!("{NO_SOLIDITY_FRONTEND}"),
|
||||
#[cfg(feature = "revive-solidity")]
|
||||
Code::Solidity { path, .. } if path.is_none() => *path = Some(contract_path.into()),
|
||||
_ => continue,
|
||||
}
|
||||
@@ -236,6 +243,9 @@ impl Specs {
|
||||
/// The test takes a [`Specs`] and executes the actions in order
|
||||
pub fn run(self) -> Vec<CallResult> {
|
||||
if self.differential {
|
||||
#[cfg(not(feature = "solidity"))]
|
||||
panic!("{NO_SOLIDITY_FRONTEND}");
|
||||
#[cfg(feature = "solidity")]
|
||||
self.run_on_evm()
|
||||
} else {
|
||||
self
|
||||
@@ -243,6 +253,7 @@ impl Specs {
|
||||
.run_on_pallet()
|
||||
}
|
||||
|
||||
#[cfg(feature = "solidity")]
|
||||
fn run_on_evm(self) -> Self {
|
||||
let mut derived_specs = Self {
|
||||
actions: vec![],
|
||||
|
||||
Reference in New Issue
Block a user