mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-11-10 12:47:10 +00:00
extend mock runtime to allow executing constructors and cross contract calls
Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
16 files changed
+544
-218
No files matched your search
@@ -1,6 +1,8 @@
|
||||
use alloy_primitives::{I256, U256};
|
||||
use alloy_sol_types::{sol, SolCall};
|
||||
|
||||
use crate::mock_runtime::{CallOutput, State};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Contract {
|
||||
pub name: &'static str,
|
||||
@@ -103,6 +105,24 @@ sol!(
|
||||
);
|
||||
|
||||
impl Contract {
|
||||
/// Execute the contract.
|
||||
///
|
||||
/// Useful helper if the contract state can be ignored,
|
||||
/// as it spares the deploy transaciton.
|
||||
///
|
||||
/// - Inserts an account with given `code` into a new state.
|
||||
/// - Callee and caller account will be `Transaction::default_address()`.
|
||||
/// - Sets the calldata.
|
||||
/// - Doesn't execute the constructor or deploy code.
|
||||
/// - Calls the "call" export on a default backend config.
|
||||
pub fn execute(&self) -> (State, CallOutput) {
|
||||
State::default()
|
||||
.transaction()
|
||||
.with_default_account(&self.pvm_runtime)
|
||||
.calldata(self.calldata.clone())
|
||||
.call()
|
||||
}
|
||||
|
||||
pub fn baseline() -> Self {
|
||||
let code = include_str!("../contracts/Baseline.sol");
|
||||
let name = "Baseline";
|
||||
|
||||
Reference in new issue
Block a user