Skip to content

Commit

Permalink
chore: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zeeshanlakhani committed Mar 13, 2024
1 parent 8a219d2 commit e42a444
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 63 deletions.
17 changes: 4 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions homestar-invocation/src/task/instruction/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ impl TryFrom<Ipld> for Nonce {
*GenericArray::from_slice(&v),
IncomingTyp::Bytes,
)),
other_ipld => Err(Error::unexpected_ipld(other_ipld.to_owned().into())),
other_ipld => {
println!("other_ipld: {:?}", v.len());
Err(Error::unexpected_ipld(other_ipld.to_owned().into()))
}
},
_ => Ok(Nonce::Empty),
}
Expand Down Expand Up @@ -291,7 +294,7 @@ mod test {
});

let ipld: Ipld = DagJsonCodec.decode(json.to_string().as_bytes()).unwrap();
let Ipld::Map(map) = ipld.clone() else {
let Ipld::Map(map) = ipld else {
panic!("IPLD is not a map");
};
let nnc = map.get("nnc").unwrap();
Expand Down
5 changes: 3 additions & 2 deletions homestar-runtime/src/db/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Utility functions Database interaction.

use chrono::NaiveDateTime;
use chrono::{DateTime, NaiveDateTime};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand All @@ -14,7 +14,8 @@ impl Timestamp for i64 {
fn timestamp_from_nanos(&self) -> Option<NaiveDateTime> {
let nanos = self % 1_000_000_000;
let seconds = (self - nanos) / 1_000_000_000;
NaiveDateTime::from_timestamp_opt(seconds, nanos as u32)
let dt = DateTime::from_timestamp(seconds, nanos as u32);
dt.map(|dt| dt.naive_utc())
}
}

Expand Down
2 changes: 0 additions & 2 deletions homestar-runtime/src/network/webserver/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ impl<'a, 'de> Deserialize<'de> for CborRun<'a> {
where
D: Deserializer<'de>,
{
//let value: Ipld = Deserialize::deserialize(deserializer)?;
//let run = CborRun::try_from(value).map_err(de::Error::custom)?;
let value = Vec::<u8>::deserialize(deserializer)?;
let ipld: Ipld = serde_ipld_dagcbor::from_slice(&value).map_err(de::Error::custom)?;
let run = CborRun::try_from(ipld).map_err(de::Error::custom)?;
Expand Down
6 changes: 3 additions & 3 deletions homestar-runtime/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ fn test_workflow_run_integration_nonced() -> Result<()> {
let rpc_port = proc_info.rpc_port;
let metrics_port = proc_info.metrics_port;
let ws_port = proc_info.ws_port;
let workflow_cid = "bafyrmibpelk6e7cmfqfbjulatdyaiyoobb7mme26iskxsl6w4viyac37q4";
let workflow_cid = "bafyrmid4ev2l44lgbazmgg36rui3eirzp5tg5ebnaexyogdnzv4hmvvtay";
let toml = format!(
r#"
[node]
Expand Down Expand Up @@ -323,8 +323,8 @@ fn test_workflow_run_integration_nonced() -> Result<()> {
wait_for_asserts(500, || {
let (name, info) = Db::get_workflow_info(cid, &mut db.conn().unwrap()).unwrap();
name.unwrap().as_str() == workflow_cid
&& info.progress().len() == 2
&& info.progress_count() == 2
&& info.progress().len() == 3
&& info.progress_count() == 3
})
.unwrap();

Expand Down
108 changes: 67 additions & 41 deletions homestar-runtime/tests/fixtures/test-workflow-add-one-nonced.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,72 @@
{
"tasks": [
{
"cause": null,
"meta": {
"fuel": 18446744073709552000,
"memory": 4294967296,
"time": 100000
},
"prf": [],
"run": {
"input": {
"args": [1],
"func": "add_one"
"tasks": [
{
"cause": null,
"meta": {
"fuel": 18446744073709552000,
"memory": 4294967296,
"time": 100000
},
"prf": [],
"run": {
"input": {
"args": [1],
"func": "add_one"
},
"nnc": "1sod60ml6g26mfhsrsa0",
"op": "wasm/run",
"rsc": "ipfs://bafybeia32q3oy6u47x624rmsmgrrlpn7ulruissmz5z2ap6alv7goe7h3q"
}
},
"nnc": "1sod60ml6g26mfhsrsa0",
"op": "wasm/run",
"rsc": "ipfs://bafybeia32q3oy6u47x624rmsmgrrlpn7ulruissmz5z2ap6alv7goe7h3q"
}
},
{
"cause": null,
"meta": {
"fuel": 18446744073709552000,
"memory": 4294967296,
"time": 100000
},
"prf": [],
"run": {
"input": {
"args": [
{
"await/ok": {
"/": "bafyrmig5x46c6nzk74adlo6ffwo4bi7fr42jkv54zqa5kzazfirb47ninm"
}
{
"cause": null,
"meta": {
"fuel": 18446744073709552000,
"memory": 4294967296,
"time": 100000
},
"prf": [],
"run": {
"input": {
"args": [
{
"await/ok": {
"/": "bafyrmig5x46c6nzk74adlo6ffwo4bi7fr42jkv54zqa5kzazfirb47ninm"
}
}
],
"func": "add_one"
},
"nnc": {
"/": { "bytes": "oVI8XiFiec+c2XHS" }
},
"op": "wasm/run",
"rsc": "ipfs://bafybeia32q3oy6u47x624rmsmgrrlpn7ulruissmz5z2ap6alv7goe7h3q"
}
],
"func": "add_one"
},
"nnc": "4ja3jhlhs3b9rk3app40",
"op": "wasm/run",
"rsc": "ipfs://bafybeia32q3oy6u47x624rmsmgrrlpn7ulruissmz5z2ap6alv7goe7h3q"
}
}
]
{
"cause": null,
"meta": {
"fuel": 18446744073709552000,
"memory": 4294967296,
"time": 100000
},
"prf": [],
"run": {
"input": {
"args": [
{
"await/ok": {
"/": "bafyrmiaa2pbgwydezutitiqq6j6qd73o3gqpeycp4g6dxnx466xdxjfnvq"
}
}
],
"func": "add_one"
},
"nnc": "",
"op": "wasm/run",
"rsc": "ipfs://bafybeia32q3oy6u47x624rmsmgrrlpn7ulruissmz5z2ap6alv7goe7h3q"
}
}
]
}

0 comments on commit e42a444

Please sign in to comment.