diff --git a/subgraph/tests/entities.rs b/subgraph/tests/entities.rs index e452baa5c..555c8e753 100644 --- a/subgraph/tests/entities.rs +++ b/subgraph/tests/entities.rs @@ -10,7 +10,7 @@ use ethers::{ }; use generated::{EvaluableConfigV2, Io, OrderConfigV2}; use hex::FromHex; -use subgraph::{wait, Query}; +use subgraph::{query::get_order, wait, Query}; use utils::{ cbor::{decode_rain_meta, encode_rain_docs, RainMapDoc}, deploy::{deploy_erc20_mock, get_orderbook, read_orderbook_meta, touch_deployer}, @@ -269,8 +269,12 @@ async fn order_entity_test() -> Result<()> { // Wait for Subgraph sync wait().await.expect("cannot get SG sync status"); + let id = Bytes::from(add_order_data.order_hash); + // let id = response; + let _ = get_order(id).await; + // let response = Query::content_meta_v1(content.hash().as_fixed_bytes().into()) // .await // .expect("cannot get the query response"); diff --git a/subgraph/tests/subgraph/query/mod.rs b/subgraph/tests/subgraph/query/mod.rs index d70fa461e..60bb58e78 100644 --- a/subgraph/tests/subgraph/query/mod.rs +++ b/subgraph/tests/subgraph/query/mod.rs @@ -1,7 +1,7 @@ pub(crate) mod content_meta_v1; +pub(crate) mod order; pub(crate) mod orderbook; pub(crate) mod rain_meta_v1; -pub(crate) mod order; use anyhow::Result; use ethers::types::{Address, Bytes}; @@ -12,6 +12,8 @@ use content_meta_v1::{get_content_meta_v1, ContentMetaV1Response}; use orderbook::{get_orderbook_query, OrderBookResponse}; use rain_meta_v1::{get_rain_meta_v1, RainMetaV1Response}; +pub use order::get_order; + pub static SG_URL: Lazy = Lazy::new(|| Url::parse("http://localhost:8000/subgraphs/name/test/test").unwrap()); diff --git a/subgraph/tests/subgraph/query/order/mod.rs b/subgraph/tests/subgraph/query/order/mod.rs index c4dd1a346..76396e8bf 100644 --- a/subgraph/tests/subgraph/query/order/mod.rs +++ b/subgraph/tests/subgraph/query/order/mod.rs @@ -45,12 +45,14 @@ pub struct OrderResponse { impl OrderResponse { // pub fn from(response: ResponseData) -> OrderResponse { pub fn from(response: ResponseData) -> () { + println!("OrderResponse.from()"); let data = response.order.unwrap(); // Check here. let owner: Bytes = data.owner.id; println!("owner: {}", owner); let emitter = data.emitter.id; + println!("emitter: {}", emitter); let meta = data.meta.unwrap().id; @@ -72,8 +74,9 @@ impl OrderResponse { } // pub async fn get_content_meta_v1(id: Bytes) -> Result { -pub async fn get_content_meta_v1(id: Bytes) -> Result<()> { +pub async fn get_order(id: Bytes) -> Result<()> { wait().await?; + println!("get_order_0"); let variables = order::Variables { id: id.to_string().into(), @@ -87,12 +90,14 @@ pub async fn get_content_meta_v1(id: Bytes) -> Result<()> { .send() .await?; + println!("get_order_1"); + let response_body: Response = res.json().await?; + println!("get_order_2.is_some: {}", response_body.data.is_some()); match response_body.data { Some(data) => { - let response = (); - // let response: OrderResponse = OrderResponse::from(data); + let response = OrderResponse::from(data); Ok(response) } None => Err(anyhow!("Failed to get query")), diff --git a/subgraph/tests/subgraph/query/order/order.graphql b/subgraph/tests/subgraph/query/order/order.graphql index d5dc28176..16e8ea7d8 100644 --- a/subgraph/tests/subgraph/query/order/order.graphql +++ b/subgraph/tests/subgraph/query/order/order.graphql @@ -2,9 +2,6 @@ query Order($id: String) { order(id: $id) { id orderHash - owner { - id - } interpreter interpreterStore expressionDeployer @@ -25,6 +22,9 @@ query Order($id: String) { transaction { id } + owner { + id + } emitter { id }