Skip to content

Commit

Permalink
Merge pull request #57 from weaveVM/fix-graphql-tests
Browse files Browse the repository at this point in the history
Fix graphql tests
  • Loading branch information
andreespirela authored Sep 11, 2024
2 parents 5905093 + c2fbe5f commit dbd439c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
16 changes: 8 additions & 8 deletions wvm-apps/wvm-exexed/crates/precompiles/src/inner/graphql_util.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
use eyre::Error;
use eyre::{Error};
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct Response {
pub data: Data,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct Data {
pub transactions: Transactions,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct Transactions {
pub edges: Vec<Edge>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Edge {
pub node: Node,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Tag {
pub name: String,
pub value: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Node {
pub id: String,
pub data: Option<NodeData>,
pub tags: Option<Vec<Tag>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct NodeData {
pub size: String,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ fn wevm_read_block_pc(input: &Bytes, gas_limit: u64) -> PrecompileResult {
None,
Some(&[("Block-Number".to_string(), vec![block_id.to_string()])]),
Some(&WVM_DATA_PUBLISHERS.map(|i| i.to_string())),
None,
true,
Some("DESC".to_string()),
false,
);

query
Expand All @@ -87,7 +87,10 @@ fn wevm_read_block_pc(input: &Bytes, gas_limit: u64) -> PrecompileResult {
None
}
}
Err(_) => None,
Err(e) => {
println!("{}", e);
None
},
};

if let Some(edge) = edge {
Expand Down Expand Up @@ -220,12 +223,12 @@ mod arweave_read_pc_tests {

#[test]
pub fn test_read_wvm_block() {
let input = Bytes::from("141550;hash".as_bytes());
let input = Bytes::from("https://arweave.mainnet.irys.xyz;1127975;hash".as_bytes());
let PrecompileOutput { gas_used, bytes } = wevm_read_block_pc(&input, 100_000).unwrap();
assert_eq!(bytes.len(), 66);
assert_eq!(
bytes.to_vec(),
"0xaf1c63505340e7c923a7cbc70b8353dfceab667100174943293896a9b75ea091"
"0xe0201f1e284fbe6fa0c90e811194a11a694a08d240f4691996b9182f2e767fee"
.as_bytes()
.to_vec()
);
Expand Down

0 comments on commit dbd439c

Please sign in to comment.