Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
gianalarcon committed Nov 24, 2023
1 parent 86a1e96 commit d18aae3
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 14 deletions.
6 changes: 3 additions & 3 deletions crates/torii/graphql/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ use torii_core::processors::register_model::RegisterModelProcessor;
use torii_core::processors::store_set_record::StoreSetRecordProcessor;
use torii_core::sql::Sql;

// mod entities_test;
// mod metadata_test;
// mod models_test;
mod entities_test;
mod metadata_test;
mod models_test;
mod subscription_test;

use crate::schema::build_schema;
Expand Down
73 changes: 62 additions & 11 deletions crates/torii/graphql/src/tests/subscription_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ mod tests {
"type_bool": true,
"type_felt": format!("{:#x}", FieldElement::from(1u128)),
"type_contract_address": format!("{:#x}", FieldElement::ONE)

}]
}
});
Expand Down Expand Up @@ -168,9 +167,16 @@ mod tests {
"keys":vec![keys_str],
"model_names": "Record",
"models" : [{
"type_contract_address": format!("{:#x}", FieldElement::ONE),
"record_id": 0,
"type_u8": 1
"__typename": "Record",
"depth": "Zero",
"record_id": 0,
"type_u8": 1,
"type_u16": 1,
"type_u32": 1,
"type_u64": 1,
"type_bool": true,
"type_felt": format!("{:#x}", FieldElement::from(1u128)),
"type_contract_address": format!("{:#x}", FieldElement::ONE)
}]
}
});
Expand All @@ -180,15 +186,24 @@ mod tests {
// 1. Open process and sleep.Go to execute subscription
tokio::time::sleep(Duration::from_secs(1)).await;

// Set entity with one moves model
// Set entity with one Record model
db.set_entity(
Ty::Struct(Struct {
name: "Record".to_string(),
children: vec![
Member {
name: "type_contract_address".to_string(),
key: true,
ty: Ty::Primitive(Primitive::ContractAddress(Some(FieldElement::ONE))),
name: "depth".to_string(),
key: false,
ty: Ty::Enum(Enum {
name: "Depth".to_string(),
option: Some(0),
options: vec![
EnumOption { name: "Zero".to_string(), ty: Ty::Tuple(vec![]) },
EnumOption { name: "One".to_string(), ty: Ty::Tuple(vec![]) },
EnumOption { name: "Two".to_string(), ty: Ty::Tuple(vec![]) },
EnumOption { name: "Three".to_string(), ty: Ty::Tuple(vec![]) },
],
}),
},
Member {
name: "record_id".to_string(),
Expand All @@ -200,13 +215,42 @@ mod tests {
key: false,
ty: Ty::Primitive(Primitive::U8(Some(1))),
},
Member {
name: "type_u16".to_string(),
key: false,
ty: Ty::Primitive(Primitive::U16(Some(1))),
},
Member {
name: "type_u32".to_string(),
key: false,
ty: Ty::Primitive(Primitive::U32(Some(1))),
},
Member {
name: "type_u64".to_string(),
key: false,
ty: Ty::Primitive(Primitive::U64(Some(1))),
},
Member {
name: "type_bool".to_string(),
key: false,
ty: Ty::Primitive(Primitive::Bool(Some(true))),
},
Member {
name: "type_felt".to_string(),
key: false,
ty: Ty::Primitive(Primitive::Felt252(Some(FieldElement::from(1u128)))),
},
Member {
name: "type_contract_address".to_string(),
key: true,
ty: Ty::Primitive(Primitive::ContractAddress(Some(FieldElement::ONE))),
},
],
}),
&format!("0x{:064x}:0x{:04x}:0x{:04x}", 0, 0, 0),
)
.await
.unwrap();
// 3. fn publish() is called from state.set_entity()

tx.send(()).await.unwrap();
});
Expand All @@ -216,14 +260,21 @@ mod tests {
&pool,
r#"subscription {
entityUpdated(id: "0x579e8877c7755365d5ec1ec7d3a94a457eff5d1f40482bbe9729c064cdead2") {
id
id
keys
model_names
models {
__typename
... on Record {
type_contract_address
depth
record_id
type_u8
type_u16
type_u32
type_u64
type_bool
type_felt
type_contract_address
}
}
}
Expand Down

0 comments on commit d18aae3

Please sign in to comment.