Skip to content

Fix test compilation and allow the ci to run #1456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/checkout@v3

- name: 🗑 Clear wasm-bindgen cache
run: rm -r ~/.cache/.wasm-pack
run: rm -r ~/.cache/.wasm-pack || true

- name: 🟢 Set up Node
uses: actions/setup-node@v3
Expand Down
1 change: 1 addition & 0 deletions editor/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ mod test {
use crate::messages::prelude::*;
use crate::test_utils::EditorTestUtils;

use document_legacy::document_metadata::LayerNodeIdentifier;
use document_legacy::LayerId;
use document_legacy::Operation;
use graphene_core::raster::color::Color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2519,7 +2519,7 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork, hash: u64) -> NodeNetwork
.to_document_node(vec![input_type.unwrap()], DocumentNodeMetadata::default());
if let DocumentNodeImplementation::Network(g) = &mut begin_scope.implementation {
if let Some(node) = g.nodes.get_mut(&0) {
node.hash = hash;
node.world_state_hash = hash;
}
}

Expand Down
13 changes: 6 additions & 7 deletions node-graph/graph-craft/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub struct DocumentNode {
pub skip_deduplication: bool,
/// Used as a hash of the graph input where applicable. This ensures that protonodes that depend on the graph's input are always regenerated.
#[serde(default)]
pub hash: u64,
pub world_state_hash: u64,
/// The path to this node as of when [`NodeNetwork::generate_node_paths`] was called.
/// For example if this node was ID 6 inside a node with ID 4 and with a [`DocumentNodeImplementation::Network`], the path would be [4, 6].
pub path: Option<Vec<NodeId>>,
Expand All @@ -164,7 +164,7 @@ impl Default for DocumentNode {
implementation: Default::default(),
metadata: Default::default(),
skip_deduplication: Default::default(),
hash: Default::default(),
world_state_hash: Default::default(),
path: Default::default(),
}
}
Expand Down Expand Up @@ -230,7 +230,7 @@ impl DocumentNode {
construction_args: args,
document_node_path: self.path.unwrap_or_default(),
skip_deduplication: self.skip_deduplication,
hash: self.hash,
world_state_hash: self.world_state_hash,
}
}

Expand Down Expand Up @@ -1248,8 +1248,7 @@ mod test {
identifier: "graphene_core::structural::ConsNode".into(),
input: ProtoNodeInput::ManualComposition(concrete!(u32)),
construction_args: ConstructionArgs::Nodes(vec![(0, false)]),
document_node_path: vec![],
skip_deduplication: false,
..Default::default()
};
assert_eq!(proto_node, reference);
}
Expand All @@ -1267,7 +1266,7 @@ mod test {
input: ProtoNodeInput::ManualComposition(concrete!(u32)),
construction_args: ConstructionArgs::Nodes(vec![(14, false)]),
document_node_path: vec![1, 0],
skip_deduplication: false,
..Default::default()
},
),
(
Expand All @@ -1277,7 +1276,7 @@ mod test {
input: ProtoNodeInput::Node(10, false),
construction_args: ConstructionArgs::Nodes(vec![]),
document_node_path: vec![1, 1],
skip_deduplication: false,
..Default::default()
},
),
(14, ProtoNode::value(ConstructionArgs::Value(TaggedValue::U32(2)), vec![1, 4])),
Expand Down
55 changes: 31 additions & 24 deletions node-graph/graph-craft/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,21 @@ pub struct ProtoNode {
pub identifier: NodeIdentifier,
pub document_node_path: Vec<NodeId>,
pub skip_deduplication: bool,
pub hash: u64,
/// Represents a global state on which the node depends. This is a hack, TODO: figure out a proper solution
pub world_state_hash: u64,
}

impl Default for ProtoNode {
fn default() -> Self {
Self {
identifier: NodeIdentifier::new("graphene_core::ops::IdNode"),
construction_args: ConstructionArgs::Value(value::TaggedValue::U32(0)),
input: ProtoNodeInput::None,
document_node_path: vec![],
skip_deduplication: false,
world_state_hash: 0,
}
}
}

/// A ProtoNodeInput represents the primary input of a node in a ProtoNetwork.
Expand Down Expand Up @@ -253,7 +267,7 @@ impl ProtoNode {
if self.skip_deduplication {
self.document_node_path.hash(&mut hasher);
}
self.hash.hash(&mut hasher);
self.world_state_hash.hash(&mut hasher);
std::mem::discriminant(&self.input).hash(&mut hasher);
match self.input {
ProtoNodeInput::None => (),
Expand All @@ -273,7 +287,7 @@ impl ProtoNode {
input: ProtoNodeInput::None,
document_node_path: path,
skip_deduplication: false,
hash: 0,
world_state_hash: 0,
}
}

Expand Down Expand Up @@ -386,7 +400,7 @@ impl ProtoNetwork {
input,
document_node_path: path,
skip_deduplication: false,
hash: 0,
world_state_hash: 0,
},
));

Expand Down Expand Up @@ -778,12 +792,12 @@ mod test {
assert_eq!(
ids,
vec![
2785293541695324513,
12994980551665119079,
17926586814106640907,
2523412932923113119,
12965978620570332342,
16191561097939296982
17957338642374791135,
1303972037140595827,
15485192931817078264,
9739645351331265115,
4165308598738454684,
5557529806312473178
]
);
}
Expand All @@ -799,8 +813,7 @@ mod test {
identifier: "id".into(),
input: ProtoNodeInput::Node(11, false),
construction_args: ConstructionArgs::Nodes(vec![]),
document_node_path: vec![],
skip_deduplication: false,
..Default::default()
},
),
(
Expand All @@ -809,8 +822,7 @@ mod test {
identifier: "id".into(),
input: ProtoNodeInput::Node(11, false),
construction_args: ConstructionArgs::Nodes(vec![]),
document_node_path: vec![],
skip_deduplication: false,
..Default::default()
},
),
(
Expand All @@ -819,8 +831,7 @@ mod test {
identifier: "cons".into(),
input: ProtoNodeInput::ManualComposition(concrete!(u32)),
construction_args: ConstructionArgs::Nodes(vec![(14, false)]),
document_node_path: vec![],
skip_deduplication: false,
..Default::default()
},
),
(
Expand All @@ -829,8 +840,7 @@ mod test {
identifier: "add".into(),
input: ProtoNodeInput::Node(10, false),
construction_args: ConstructionArgs::Nodes(vec![]),
document_node_path: vec![],
skip_deduplication: false,
..Default::default()
},
),
(
Expand All @@ -839,8 +849,7 @@ mod test {
identifier: "value".into(),
input: ProtoNodeInput::None,
construction_args: ConstructionArgs::Value(value::TaggedValue::U32(2)),
document_node_path: vec![],
skip_deduplication: false,
..Default::default()
},
),
]
Expand All @@ -860,8 +869,7 @@ mod test {
identifier: "id".into(),
input: ProtoNodeInput::Node(2, false),
construction_args: ConstructionArgs::Nodes(vec![]),
document_node_path: vec![],
skip_deduplication: false,
..Default::default()
},
),
(
Expand All @@ -870,8 +878,7 @@ mod test {
identifier: "id".into(),
input: ProtoNodeInput::Node(1, false),
construction_args: ConstructionArgs::Nodes(vec![]),
document_node_path: vec![],
skip_deduplication: false,
..Default::default()
},
),
]
Expand Down