Skip to content

Commit

Permalink
refactor: testing around e2e websocket/jsonrpc, feature-flag mania
Browse files Browse the repository at this point in the history
  • Loading branch information
zeeshanlakhani committed Nov 2, 2023
1 parent adfabc7 commit 882342b
Show file tree
Hide file tree
Showing 31 changed files with 464 additions and 225 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions examples/websocket-relay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ if they've been previously run.
On macOS, for example, a simple homebrew install would install everything you
need: `brew install rust npm ipfs`

We have packaged homestar binaries via brew, so
We have packaged homestar binaries using brew, so
`brew install fission-codes/fission/homestar` will install everything you need,
including `ipfs`. You will still need npm to run this example. From this folder,
including `ipfs`. You will still need `npm` to run this example. From this folder,
you can then run the example like this:

```
Expand Down
Binary file modified examples/websocket-relay/example_test.wasm
Binary file not shown.
34 changes: 17 additions & 17 deletions examples/websocket-relay/relay-app/src/lib/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function run(workflowId: WorkflowId) {

// Record the first workflow that ran
if (!firstWorkflowToRun) {
firstWorkflowToRunStore.set(workflowId)
firstWorkflowToRunStore.set(workflowId);
}

// Set workflow status to working
Expand Down Expand Up @@ -164,11 +164,11 @@ export async function handleMessage(event: MessageEvent) {
const updatedTasks = store[activeWorkflow.id].map((t) =>
t.id === taskId
? {
...t,
status,
message: getTaskMessage(status),
receipt,
}
...t,
status,
message: getTaskMessage(status),
receipt,
}
: t
);

Expand Down Expand Up @@ -259,7 +259,7 @@ export const workflowOneJson = {
},
nnc: "",
op: "wasm/run",
rsc: "ipfs://bafybeiabbxwf2vn4j3zm7bbojr6rt6k7o6cg6xcbhqkllubmsnvocpv7y4",
rsc: "ipfs://bafybeichafzlolnoamugvfuyynjnj2gse7avstiqkeiuwuv2gyztap4qm4",
},
},
{
Expand All @@ -274,15 +274,15 @@ export const workflowOneJson = {
args: [
{
"await/ok": {
"/": "bafyrmibalyvlsj3zo2vdgjmvawdszh546jz53ejhud7u6lkmpg6mcvq5ja",
"/": "bafyrmigev36skyfjnslfswcez24rnrorzeaxkrpb3wci2arfkly5zcrepy",
},
},
],
func: "rotate90",
},
nnc: "",
op: "wasm/run",
rsc: "ipfs://bafybeiabbxwf2vn4j3zm7bbojr6rt6k7o6cg6xcbhqkllubmsnvocpv7y4",
rsc: "ipfs://bafybeichafzlolnoamugvfuyynjnj2gse7avstiqkeiuwuv2gyztap4qm4",
},
},
{
Expand All @@ -297,7 +297,7 @@ export const workflowOneJson = {
args: [
{
"await/ok": {
"/": "bafyrmiepk7vo7qcndopjhuywtv6bly7ojd6gzmwlqm4uzsingbyxluytny",
"/": "bafyrmiegkif6ofatmowjjmw7yttm7mi5pjjituoxtp5qqsmc3fw65ypbm4",
},
},
20.2,
Expand All @@ -306,7 +306,7 @@ export const workflowOneJson = {
},
nnc: "",
op: "wasm/run",
rsc: "ipfs://bafybeiabbxwf2vn4j3zm7bbojr6rt6k7o6cg6xcbhqkllubmsnvocpv7y4",
rsc: "ipfs://bafybeichafzlolnoamugvfuyynjnj2gse7avstiqkeiuwuv2gyztap4qm4",
},
},
],
Expand Down Expand Up @@ -336,7 +336,7 @@ export const workflowTwoJson = {
},
nnc: "",
op: "wasm/run",
rsc: "ipfs://bafybeiabbxwf2vn4j3zm7bbojr6rt6k7o6cg6xcbhqkllubmsnvocpv7y4",
rsc: "ipfs://bafybeichafzlolnoamugvfuyynjnj2gse7avstiqkeiuwuv2gyztap4qm4",
},
},
{
Expand All @@ -351,15 +351,15 @@ export const workflowTwoJson = {
args: [
{
"await/ok": {
"/": "bafyrmibalyvlsj3zo2vdgjmvawdszh546jz53ejhud7u6lkmpg6mcvq5ja",
"/": "bafyrmigev36skyfjnslfswcez24rnrorzeaxkrpb3wci2arfkly5zcrepy",
},
},
],
func: "rotate90",
},
nnc: "",
op: "wasm/run",
rsc: "ipfs://bafybeiabbxwf2vn4j3zm7bbojr6rt6k7o6cg6xcbhqkllubmsnvocpv7y4",
rsc: "ipfs://bafybeichafzlolnoamugvfuyynjnj2gse7avstiqkeiuwuv2gyztap4qm4",
},
},
{
Expand All @@ -374,15 +374,15 @@ export const workflowTwoJson = {
args: [
{
"await/ok": {
"/": "bafyrmiepk7vo7qcndopjhuywtv6bly7ojd6gzmwlqm4uzsingbyxluytny",
"/": "bafyrmiegkif6ofatmowjjmw7yttm7mi5pjjituoxtp5qqsmc3fw65ypbm4",
},
},
],
func: "grayscale",
},
nnc: "",
op: "wasm/run",
rsc: "ipfs://bafybeiabbxwf2vn4j3zm7bbojr6rt6k7o6cg6xcbhqkllubmsnvocpv7y4",
rsc: "ipfs://bafybeichafzlolnoamugvfuyynjnj2gse7avstiqkeiuwuv2gyztap4qm4",
},
},
],
Expand Down Expand Up @@ -432,7 +432,7 @@ function sampleReceipt(
workflowId: string,
op: TaskOperation
) {
const base64Cat = getStore(base64CatStore)
const base64Cat = getStore(base64CatStore);

return {
metadata: {
Expand Down
16 changes: 6 additions & 10 deletions homestar-core/src/test_utils/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use std::collections::BTreeMap;
use url::Url;

const RAW: u64 = 0x55;
const WASM_CID: &str = "bafkreib7os7i3f3x24r3simz2mqrgjmxags6xvjyoevbmtxwz7utgue4eu";

type NonceBytes = Vec<u8>;

/// Return a `mocked` `wasm/run` [Instruction].
pub fn wasm_instruction<'a, T>() -> Instruction<'a, T> {
let wasm = "bafybeihzvrlcfqf6ffbp2juhuakspxj2bdsc54cabxnuxfvuqy5lvfxapy".to_string();
let resource = Url::parse(format!("ipfs://{wasm}").as_str()).unwrap();
let resource = Url::parse(format!("ipfs://{WASM_CID}").as_str()).unwrap();

Instruction::new(
resource,
Expand All @@ -45,8 +45,7 @@ where
Ipld: From<T>,
T: Clone,
{
let wasm = "bafybeihzvrlcfqf6ffbp2juhuakspxj2bdsc54cabxnuxfvuqy5lvfxapy".to_string();
let resource = Url::parse(format!("ipfs://{wasm}").as_str()).unwrap();
let resource = Url::parse(format!("ipfs://{WASM_CID}").as_str()).unwrap();

let instr = Instruction::new(
resource.clone(),
Expand Down Expand Up @@ -100,8 +99,7 @@ where

/// Return a `mocked` `wasm/run` [Instruction], along with it's [Nonce] as bytes.
pub fn wasm_instruction_with_nonce<'a, T>() -> (Instruction<'a, T>, NonceBytes) {
let wasm = "bafybeihzvrlcfqf6ffbp2juhuakspxj2bdsc54cabxnuxfvuqy5lvfxapy".to_string();
let resource = Url::parse(format!("ipfs://{wasm}").as_str()).unwrap();
let resource = Url::parse(format!("ipfs://{WASM_CID}").as_str()).unwrap();
let nonce = Nonce::generate();

(
Expand All @@ -120,8 +118,7 @@ pub fn wasm_instruction_with_nonce<'a, T>() -> (Instruction<'a, T>, NonceBytes)

/// Return a `mocked` [Instruction].
pub fn instruction<'a, T>() -> Instruction<'a, T> {
let wasm = "bafybeihzvrlcfqf6ffbp2juhuakspxj2bdsc54cabxnuxfvuqy5lvfxapy".to_string();
let resource = Url::parse(format!("ipfs://{wasm}").as_str()).unwrap();
let resource = Url::parse(format!("ipfs://{WASM_CID}").as_str()).unwrap();

Instruction::new(
resource,
Expand All @@ -132,8 +129,7 @@ pub fn instruction<'a, T>() -> Instruction<'a, T> {

/// Return a `mocked` [Instruction], along with it's [Nonce] as bytes.
pub fn instruction_with_nonce<'a, T>() -> (Instruction<'a, T>, NonceBytes) {
let wasm = "bafybeihzvrlcfqf6ffbp2juhuakspxj2bdsc54cabxnuxfvuqy5lvfxapy".to_string();
let resource = Url::parse(format!("ipfs://{wasm}").as_str()).unwrap();
let resource = Url::parse(format!("ipfs://{WASM_CID}").as_str()).unwrap();
let nonce = Nonce::generate();

(
Expand Down
2 changes: 1 addition & 1 deletion homestar-core/src/workflow/input/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<T> From<Parsed<T>> for Args<T> {
/// use libipld::Ipld;
/// use url::Url;
///
/// let wasm = "bafybeihzvrlcfqf6ffbp2juhuakspxj2bdsc54cabxnuxfvuqy5lvfxapy".to_string();
/// let wasm = "bafkreib7os7i3f3x24r3simz2mqrgjmxags6xvjyoevbmtxwz7utgue4eu".to_string();
/// let resource = Url::parse(format!("ipfs://{wasm}").as_str()).unwrap();
///
/// let inst = Instruction::unique(
Expand Down
6 changes: 3 additions & 3 deletions homestar-core/src/workflow/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ where
/// use libipld::Ipld;
/// use url::Url;
///
/// let wasm = "bafybeihzvrlcfqf6ffbp2juhuakspxj2bdsc54cabxnuxfvuqy5lvfxapy".to_string();
/// let wasm = "bafkreib7os7i3f3x24r3simz2mqrgjmxags6xvjyoevbmtxwz7utgue4eu".to_string();
/// let resource = Url::parse(format!("ipfs://{wasm}").as_str()).unwrap();
///
/// let instr = Instruction::unique(
Expand All @@ -154,7 +154,7 @@ where
/// use libipld::{cid::{multihash::{Code, MultihashDigest}, Cid}, Ipld, Link};
/// use url::Url;
/// let wasm = "bafybeihzvrlcfqf6ffbp2juhuakspxj2bdsc54cabxnuxfvuqy5lvfxapy".to_string();
/// let wasm = "bafkreib7os7i3f3x24r3simz2mqrgjmxags6xvjyoevbmtxwz7utgue4eu".to_string();
/// let resource = Url::parse(format!("ipfs://{wasm}").as_str()).expect("IPFS URL");
/// let h = Code::Blake3_256.digest(b"beep boop");
/// let cid = Cid::new_v1(0x55, h);
Expand Down Expand Up @@ -330,7 +330,7 @@ mod test {
(
RESOURCE_KEY.into(),
Ipld::String(
"ipfs://bafybeihzvrlcfqf6ffbp2juhuakspxj2bdsc54cabxnuxfvuqy5lvfxapy".into()
"ipfs://bafkreib7os7i3f3x24r3simz2mqrgjmxags6xvjyoevbmtxwz7utgue4eu".into()
)
),
(OP_KEY.into(), Ipld::String("ipld/fun".to_string())),
Expand Down
2 changes: 1 addition & 1 deletion homestar-core/src/workflow/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ mod test {
(
"rsc".into(),
Ipld::String(
"ipfs://bafybeihzvrlcfqf6ffbp2juhuakspxj2bdsc54cabxnuxfvuqy5lvfxapy".into(),
"ipfs://bafkreib7os7i3f3x24r3simz2mqrgjmxags6xvjyoevbmtxwz7utgue4eu".into(),
),
),
("op".into(), Ipld::String("ipld/fun".to_string())),
Expand Down
2 changes: 1 addition & 1 deletion homestar-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cd test && cargo build --target wasm32-unknown-unknown --profile release-wasm-fn
cargo build -p homestar-functions-test --target wasm32-unknown-unknown --profile release-wasm-fn
```

Guest Wasm modules will be generated within the top-level `homestar` directory:
Guest Wasm modules will be generated in the top-level `homestar` directory:
`./target/wasm32-unknown-unknown/release-wasm-fn/homestar_functions_test.wasm`.

Sadly, this module is **not yet** an actual `component`. But, we can leverage
Expand Down
4 changes: 4 additions & 0 deletions homestar-functions/add/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ wit_bindgen::generate!({
pub struct Component;

impl Guest for Component {
fn add_one(input: i32) -> i32 {
input + 2
}

fn add_two(input: i32) -> i32 {
input + 2
}
Expand Down
1 change: 1 addition & 0 deletions homestar-functions/add/wit/host.wit
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package homestar-functions:add

world add {
export add-one: func(input: s32) -> s32
export add-two: func(input: s32) -> s32
}
1 change: 1 addition & 0 deletions homestar-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ serial_test = { version = "2.0", default-features = false, features = [
] }
strip-ansi-escapes = "0.2.0"
sysinfo = { version = "0.29", default-features = false }
tokio-test = "0.4"
tokio-tungstenite = { version = "0.20", default-features = false, features = [
"connect",
] }
Expand Down
3 changes: 1 addition & 2 deletions homestar-runtime/src/metrics/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ pub(crate) fn setup_metrics_recorder(
.build()
.expect("failed to install recorder/exporter");

let hdl = recorder.handle();
let rt_hdl = Handle::current();
rt_hdl.spawn(exporter);

let hdl = recorder.handle();

Stack::new(recorder)
.push(PrefixLayer::new("homestar"))
.install()?;
Expand Down
Loading

0 comments on commit 882342b

Please sign in to comment.