Fix test compilation and allow the ci to run (#1456)

* Fix test compilation

* Don't fail if .wasm-pack dir does not exist
This commit is contained in:
Dennis Kobert 2023-11-14 23:01:40 +01:00 committed by GitHub
parent 81519601ae
commit 9784d31edb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 33 deletions

View file

@ -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>>,
@ -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(),
}
}
@ -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,
}
}
@ -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);
}
@ -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()
},
),
(
@ -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])),

View file

@ -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.
@ -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 => (),
@ -273,7 +287,7 @@ impl ProtoNode {
input: ProtoNodeInput::None,
document_node_path: path,
skip_deduplication: false,
hash: 0,
world_state_hash: 0,
}
}
@ -386,7 +400,7 @@ impl ProtoNetwork {
input,
document_node_path: path,
skip_deduplication: false,
hash: 0,
world_state_hash: 0,
},
));
@ -778,12 +792,12 @@ mod test {
assert_eq!(
ids,
vec![
2785293541695324513,
12994980551665119079,
17926586814106640907,
2523412932923113119,
12965978620570332342,
16191561097939296982
17957338642374791135,
1303972037140595827,
15485192931817078264,
9739645351331265115,
4165308598738454684,
5557529806312473178
]
);
}
@ -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()
},
),
(
@ -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()
},
),
(
@ -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()
},
),
(
@ -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()
},
),
(
@ -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()
},
),
]
@ -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()
},
),
(
@ -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()
},
),
]