mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-13 17:41:05 +00:00
@@ -129,6 +129,12 @@ sol!(
|
||||
}
|
||||
);
|
||||
|
||||
sol!(
|
||||
contract MCopy {
|
||||
function memcpy(bytes memory payload) public pure returns (bytes memory);
|
||||
}
|
||||
);
|
||||
|
||||
impl Contract {
|
||||
/// Execute the contract.
|
||||
///
|
||||
@@ -423,6 +429,18 @@ impl Contract {
|
||||
calldata: ExtCode::ExtCodeSizeCall::new((address,)).abi_encode(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn memcpy(payload: Vec<u8>) -> Self {
|
||||
let code = include_str!("../contracts/MCopy.sol");
|
||||
let name = "MCopy";
|
||||
|
||||
Self {
|
||||
name,
|
||||
evm_runtime: crate::compile_evm_bin_runtime(name, code),
|
||||
pvm_runtime: crate::compile_blob(name, code),
|
||||
calldata: MCopy::memcpyCall::new((payload,)).abi_encode(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use alloy_primitives::{keccak256, Address, FixedBytes, B256, I256, U256};
|
||||
use alloy_sol_types::{sol, SolCall};
|
||||
use alloy_sol_types::{sol, SolCall, SolValue};
|
||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||
use sha1::Digest;
|
||||
|
||||
@@ -522,3 +522,15 @@ fn ext_code_size() {
|
||||
let expected = U256::ZERO;
|
||||
assert_eq!(received, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mcopy() {
|
||||
let expected = vec![1, 2, 3];
|
||||
|
||||
let (_, output) = assert_success(&Contract::memcpy(expected.clone()), false);
|
||||
|
||||
let received = alloy_primitives::Bytes::abi_decode(&output.data, true)
|
||||
.unwrap()
|
||||
.to_vec();
|
||||
assert_eq!(expected, received);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user