Skip to content

Commit

Permalink
[pdsl_model] Add direct message calls.
Browse files Browse the repository at this point in the history
These are mainly useful for testing of contracts.
  • Loading branch information
Robbepop committed Feb 18, 2019
1 parent 284e546 commit f7be0c5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions model/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,5 +345,23 @@ where
.ok()
.expect("trapped during message dispatch");
}

/// Calls the given message with its expected input arguments.
///
/// # Note
///
/// Takes `&mut self` since it could potentially call a message
/// that mutates state. There currently is no separation between
/// messages that mutate state and those that don't.
///
/// # Panics
///
/// If the contract has no message handler setup for the given message.
pub fn call<Msg>(&mut self, input: <Msg as Message>::Input)
where
Msg: Message,
<Msg as Message>::Input: parity_codec::Encode,
{
self.call_with(CallData::from_msg::<Msg>(input))
}
}

0 comments on commit f7be0c5

Please sign in to comment.