Skip to content

Commit

Permalink
chore: release 0.1.0-pre.0 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
itegulov authored Aug 25, 2022
1 parent 983346e commit fa1b42d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "near-abi"
version = "0.1.0"
version = "0.1.0-pre.0"
edition = "2021"
rust-version = "1.56.0"
license = "MIT OR Apache-2.0"
Expand Down
57 changes: 57 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,4 +710,61 @@ mod tests {
serde_json::from_str::<AbiParameter>(json)
.expect_err("Expected deserialization to fail due to unknown field");
}

#[test]
fn test_correct_version() {
let json = format!(
r#"
{{
"schema_version": "{}",
"metadata": {{}},
"body": {{
"functions": [],
"root_schema": {{}}
}}
}}
"#,
SCHEMA_VERSION
);
let abi_root = serde_json::from_str::<AbiRoot>(&json).unwrap();
assert_eq!(abi_root.schema_version, SCHEMA_VERSION);
}

#[test]
fn test_older_version() {
let json = r#"
{
"schema_version": "0.0.1",
"metadata": {},
"body": {
"functions": [],
"root_schema": {}
}
}
"#;
let err = serde_json::from_str::<AbiRoot>(json)
.expect_err("Expected deserialization to fail due to schema version mismatch");
assert!(err.to_string().contains(
"got 0.0.1: consider re-generating your ABI file with a newer version of SDK and cargo-near"
));
}

#[test]
fn test_newer_version() {
let json = r#"
{
"schema_version": "99.99.99",
"metadata": {},
"body": {
"functions": [],
"root_schema": {}
}
}
"#;
let err = serde_json::from_str::<AbiRoot>(json)
.expect_err("Expected deserialization to fail due to schema version mismatch");
assert!(err
.to_string()
.contains("got 99.99.99: consider upgrading near-abi to a newer version"));
}
}

0 comments on commit fa1b42d

Please sign in to comment.