From d18aae3e06a482f6e3ed3deda43a2878b9669986 Mon Sep 17 00:00:00 2001 From: gianalarcon Date: Fri, 24 Nov 2023 13:21:33 -0500 Subject: [PATCH] fmt --- crates/torii/graphql/src/tests/mod.rs | 6 +- .../graphql/src/tests/subscription_test.rs | 73 ++++++++++++++++--- 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/crates/torii/graphql/src/tests/mod.rs b/crates/torii/graphql/src/tests/mod.rs index 67c73dc632..ca8ec1da54 100644 --- a/crates/torii/graphql/src/tests/mod.rs +++ b/crates/torii/graphql/src/tests/mod.rs @@ -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; diff --git a/crates/torii/graphql/src/tests/subscription_test.rs b/crates/torii/graphql/src/tests/subscription_test.rs index 0f438a41bd..f3b373f68c 100644 --- a/crates/torii/graphql/src/tests/subscription_test.rs +++ b/crates/torii/graphql/src/tests/subscription_test.rs @@ -41,7 +41,6 @@ mod tests { "type_bool": true, "type_felt": format!("{:#x}", FieldElement::from(1u128)), "type_contract_address": format!("{:#x}", FieldElement::ONE) - }] } }); @@ -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) }] } }); @@ -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(), @@ -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(); }); @@ -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 } } }