Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class_metadata #94

Merged
merged 8 commits into from
Oct 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add unit tests
sczembor committed Oct 5, 2023
commit c28b2700ebb965e8a6fe25b5aedbc59a3165b1c2
32 changes: 32 additions & 0 deletions contracts/oracle/src/lib.rs
Original file line number Diff line number Diff line change
@@ -353,6 +353,7 @@ mod checks;
pub mod tests {
use crate::*;
use ed25519_dalek::Keypair;
use near_sdk::test_utils::test_env::alice;
use near_sdk::test_utils::VMContextBuilder;
use near_sdk::{testing_env, VMContext};

@@ -387,6 +388,16 @@ pub mod tests {
11 * SECOND
}

fn class_metadata() -> ClassMetadata {
ClassMetadata {
name: "test_1".to_string(),
symbol: None,
icon: None,
reference: None,
reference_hash: None,
}
}

/// SBT claim ttl in seconds
const CLAIM_TTL: u64 = 2;

@@ -628,4 +639,25 @@ pub mod tests {
assert!(res.is_err());
assert_bad_request(res, "IAH SBT cannot be mint during the elections period");
}

#[test]
#[should_panic(expected = "not an admin")]
fn set_class_metadata_not_admin() {
let (_, mut ctr, _) = setup(&alice(), &alice());
ctr.set_class_metadata(1, class_metadata())
}

#[test]
#[should_panic(expected = "class not found")]
fn set_class_metadata_wrong_class() {
let (_, mut ctr, _) = setup(&alice(), &acc_admin());
ctr.set_class_metadata(3, class_metadata())
}

#[test]
fn set_class_metadata() {
let (_, mut ctr, _) = setup(&alice(), &acc_admin());
ctr.set_class_metadata(1, class_metadata());
assert_eq!(ctr.class_metadata(1).unwrap(), class_metadata());
}
}
2 changes: 1 addition & 1 deletion contracts/oracle/tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -378,7 +378,7 @@ async fn migration_mainnet() -> anyhow::Result<()> {
.as_account()
.deploy(include_bytes!("../../res/oracle_sbt.wasm"))
.await?;
// .into_result()?;

assert!(res.is_success());

let new_oracle = res.into_result()?;