Skip to content

Commit

Permalink
Update unit tests for list
Browse files Browse the repository at this point in the history
  • Loading branch information
darunrs committed Aug 1, 2024
1 parent fb88e7b commit 14dae69
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions registry/contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,19 @@ mod tests {
deleted_at_block_height: None,
forked_from: None,
};
let deleted_config = IndexerConfig {
start_block: StartBlock::Latest,
code: "var x= 1;".to_string(),
schema: String::new(),
rule: Rule::ActionAny {
affected_account_id: "social.near".to_string(),
status: Status::Success,
},
updated_at_block_height: None,
created_at_block_height: 0,
deleted_at_block_height: Some(1),
forked_from: None,
};
let account_id = "bob.near".parse::<AccountId>().unwrap();
let mut account_indexers = IndexerConfigByFunctionName::new(StorageKeys::Account(
env::sha256_array(account_id.as_bytes()),
Expand Down Expand Up @@ -1676,6 +1689,19 @@ mod tests {
deleted_at_block_height: None,
forked_from: None,
};
let deleted_config = IndexerConfig {
start_block: StartBlock::Latest,
code: "var x= 1;".to_string(),
schema: String::new(),
rule: Rule::ActionAny {
affected_account_id: "social.near".to_string(),
status: Status::Success,
},
updated_at_block_height: None,
created_at_block_height: 0,
deleted_at_block_height: Some(1),
forked_from: None,
};
let account_id = "bob.near".parse::<AccountId>().unwrap();
let mut account_indexers = IndexerConfigByFunctionName::new(StorageKeys::Account(
env::sha256_array(account_id.as_bytes()),
Expand Down Expand Up @@ -1746,6 +1772,22 @@ mod tests {
StartBlock::Latest,
None,
);
contract.register(
"delete_this".to_string(),
Some(IndexerIdentity {
account_id: "some_other_account.near".parse().unwrap(),
function_name: String::from("some_other_function"),
}),
String::from("code"),
String::from("schema"),
Rule::ActionAny {
affected_account_id: String::from("social.near"),
status: Status::Any,
},
StartBlock::Latest,
None,
);
contract.remove_indexer_function("delete_this".to_string(), None);

assert_eq!(
contract.list_all(),
Expand Down Expand Up @@ -1800,6 +1842,33 @@ mod tests {
);
}

#[test]
fn list_only_deleted_account_indexers() {
let mut contract = Contract::default();

contract.register(
"test".to_string(),
Some(IndexerIdentity {
account_id: "some_other_account.near".parse().unwrap(),
function_name: String::from("some_other_function"),
}),
String::from("code"),
String::from("schema"),
Rule::ActionAny {
affected_account_id: String::from("social.near"),
status: Status::Any,
},
StartBlock::Latest,
None,
);
contract.remove_indexer_function("test".to_string(), None);

assert_eq!(
contract.list_by_account("morgs.near".parse().unwrap()),
HashMap::new()
);
}

#[test]
fn list_account_indexers() {
let mut contract = Contract::default();
Expand Down

0 comments on commit 14dae69

Please sign in to comment.