feat(testing-framework): Testing framework major refactoring (#372)

1. Network can be shared between several execution, being used by an Rc-handle.
2. The neighborhood is just network's all peers with removed/inserted hosts delta with respect to network.
3. An AIR script is transformed into a separate value of type `TransformedAirScript`.  It allows running several
particles on the same parsed AIR script, sharing state.
4. `TestExecutor` was renamed to `AirScriptExecutor`.  It also has a constructor that accepts a `TransformedAirScript`.
This commit is contained in:
Ivan Boldyrev
2022-11-24 19:33:55 +03:00
committed by GitHub
parent 7ac0ab109c
commit 4e86da7eda
17 changed files with 857 additions and 505 deletions

View File

@ -66,20 +66,20 @@ pub fn parse_kw(inp: &str) -> IResult<&str, ServiceDefinition, ParseError> {
let value = value.trim();
match ServiceTagName::from_str(tag) {
Ok(ServiceTagName::Ok) => {
serde_json::from_str::<JValue>(value).map(ServiceDefinition::Ok)
serde_json::from_str::<JValue>(value).map(ServiceDefinition::ok)
}
Ok(ServiceTagName::Error) => {
serde_json::from_str::<CallServiceResult>(value).map(ServiceDefinition::Error)
serde_json::from_str::<CallServiceResult>(value).map(ServiceDefinition::error)
}
Ok(ServiceTagName::SeqOk) => {
serde_json::from_str(value).map(ServiceDefinition::SeqOk)
serde_json::from_str(value).map(ServiceDefinition::seq_ok)
}
Ok(ServiceTagName::SeqError) => {
serde_json::from_str::<HashMap<String, CallServiceResult>>(value)
.map(ServiceDefinition::SeqError)
.map(ServiceDefinition::seq_error)
}
Ok(ServiceTagName::Behaviour) => Ok(ServiceDefinition::Behaviour(value.to_owned())),
Ok(ServiceTagName::Map) => serde_json::from_str(value).map(ServiceDefinition::Map),
Ok(ServiceTagName::Behaviour) => Ok(ServiceDefinition::behaviour(value)),
Ok(ServiceTagName::Map) => serde_json::from_str(value).map(ServiceDefinition::map),
Err(_) => unreachable!("unknown tag {:?}", tag),
}
},
@ -153,7 +153,7 @@ mod tests {
let res = ServiceDefinition::from_str(r#"seq_ok={"default": 42, "1": true, "3": []}"#);
assert_eq!(
res,
Ok(ServiceDefinition::SeqOk(maplit::hashmap! {
Ok(ServiceDefinition::seq_ok(maplit::hashmap! {
"default".to_owned() => json!(42),
"1".to_owned() => json!(true),
"3".to_owned() => json!([]),
@ -183,7 +183,7 @@ mod tests {
);
assert_eq!(
res,
Ok(ServiceDefinition::SeqError(maplit::hashmap! {
Ok(ServiceDefinition::seq_error(maplit::hashmap! {
"default".to_owned() => CallServiceResult::ok(json!(42)),
"1".to_owned() => CallServiceResult::ok(json!(true)),
"3".to_owned() => CallServiceResult::err(1, json!("error")),