feat: finalise XEX runner and testing

This commit is contained in:
0xalivecow 2024-10-28 18:41:15 +01:00
parent c34557ea29
commit 31050ea696
No known key found for this signature in database
6 changed files with 146 additions and 49 deletions

View file

@ -3,7 +3,13 @@ use base64::prelude::*;
use std::collections::HashMap;
use crate::utils::parse::{Responses, Testcase, Testcases};
use tasks01::{block2poly::block2poly, gfmul::gfmul, poly2block::poly2block, sea128::sea128};
use tasks01::{
block2poly::block2poly,
gfmul::gfmul,
poly2block::poly2block,
sea128::sea128,
xex::{self, fde_xex},
};
use anyhow::{anyhow, Result};
use serde_json::{json, Value};
@ -47,6 +53,12 @@ pub fn task_deploy(testcase: &Testcase) -> Result<Value> {
let json = json!({"product" : result});
Ok(json)
}
"xex" => {
let result = BASE64_STANDARD.encode(fde_xex(args)?);
let json = json!({"output" : result});
Ok(json)
}
_ => Err(anyhow!(
"Fatal. No compatible action found. Json data was {:?}. Arguments were; {:?}",
testcase,
@ -142,4 +154,22 @@ mod tests {
Ok(())
}
#[test]
fn test_task_xex_full() -> Result<()> {
let json = fs::read_to_string("test_json/xex_tests.json").unwrap();
let parsed = parse_json(json).unwrap();
let expected = json!({ "responses": {
"0192d428-3913-762b-a702-d14828eae1f8": {"output": "mHAVhRCKPAPx0BcufG5BZ4+/CbneMV/gRvqK5rtLe0OJgpDU5iT7z2P0R7gEeRDO"},
"0192d428-3913-7168-a3bb-69c258c74dc1": {"output": "SGV5IHdpZSBrcmFzcyBkYXMgZnVua3Rpb25pZXJ0IGphIG9mZmVuYmFyIGVjaHQu"}
}});
assert_eq!(
serde_json::to_value(task_distrubute(&parsed)?).unwrap(),
serde_json::to_value(expected).unwrap()
);
Ok(())
}
}