From 3159aee360130ef64f27be30558d58b8b41777bd Mon Sep 17 00:00:00 2001 From: Trantorian Date: Fri, 12 Jan 2024 08:43:38 +0000 Subject: [PATCH] test(spec_version): :white_check_mark: tested starknet_specversion Current test is against version 0.5.1 --- unit_tests/Cargo.toml | 6 +++--- unit_tests/src/constants.rs | 2 ++ unit_tests/src/fixtures.rs | 2 +- unit_tests/tests/test_specversion.rs | 21 +++++++++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 unit_tests/tests/test_specversion.rs diff --git a/unit_tests/Cargo.toml b/unit_tests/Cargo.toml index f98c7c9..41fb12f 100644 --- a/unit_tests/Cargo.toml +++ b/unit_tests/Cargo.toml @@ -12,9 +12,9 @@ serde = "1.0.194" serde_json = "1.0.110" tokio = { version = "1", features = ["full"] } url = "2.5.0" -starknet = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "a35ce22", default-features = false } -starknet-core = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "a35ce22", default-features = false } -starknet-providers = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "a35ce22", default-features = false } +starknet = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "64ebc36", default-features = false } +starknet-core = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "64ebc36", default-features = false } +starknet-providers = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "64ebc36", default-features = false } env_logger = "0.10.1" [dev-dependencies] diff --git a/unit_tests/src/constants.rs b/unit_tests/src/constants.rs index e8efaec..c4a9e5c 100644 --- a/unit_tests/src/constants.rs +++ b/unit_tests/src/constants.rs @@ -144,3 +144,5 @@ pub const SELECTOR_NAME: &str = ""; pub const ERR_DEOXYS: &str = "Error waiting for response from Deoxys client"; pub const ERR_PATHFINDER: &str = "Error waiting for response from Pathfinder client"; + +pub const RPC_SPEC: &str = "0.5.1"; diff --git a/unit_tests/src/fixtures.rs b/unit_tests/src/fixtures.rs index 7afd6b6..a29718a 100644 --- a/unit_tests/src/fixtures.rs +++ b/unit_tests/src/fixtures.rs @@ -10,7 +10,7 @@ use crate::TestConfig; #[fixture] pub fn config() -> TestConfig { - TestConfig::new("./secret.json").expect("'./secret.json' must contain correct node urls") + TestConfig::new("../secret.json").expect("'../secret.json' must contain correct node urls") } #[fixture] diff --git a/unit_tests/tests/test_specversion.rs b/unit_tests/tests/test_specversion.rs new file mode 100644 index 0000000..daedcee --- /dev/null +++ b/unit_tests/tests/test_specversion.rs @@ -0,0 +1,21 @@ +#![feature(assert_matches)] + +mod common; +use common::*; +use starknet_providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; + +/// +/// Unit test for `starknet_specversion` +/// +/// purpose: retrieve the Deoxys node spec version +/// success case: spec version should be 0.5.1 +/// +#[rstest] +#[tokio::test] +#[logging] +async fn test_specversion(deoxys: JsonRpcClient) { + let response_deoxys = deoxys.spec_version().await.expect(ERR_DEOXYS); + + log::info!("Deoxys RPC spec: {}", response_deoxys); + assert_eq!(response_deoxys, RPC_SPEC); +}