This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP * WIP * Refactored structure while maintaining the old behaviour * rustfmt * Added post endpoint * Tested Tokens and Contracts payload * Renamed struct * Added unit tests for invalidation_patterns and invalidation_scope mappers * Adjusted transactions invalidation pattern * Renamed internal variable * Re-ordered match branches * Moved the consts to the module root * Changed return type and ordering of params * Added transfer variant to InvalidationPatterns
- Loading branch information
1 parent
ed4cb16
commit 40296f7
Showing
9 changed files
with
197 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
use crate::cache::cache_operations::{InvalidationPattern, InvalidationScope}; | ||
use crate::cache::{CACHE_REQS_PREFIX, CACHE_REQS_RESP_PREFIX, CACHE_RESP_PREFIX}; | ||
use crate::providers::info::TOKENS_KEY; | ||
|
||
#[test] | ||
fn invalidation_pattern_any_string() { | ||
let invalidation_pattern = | ||
InvalidationPattern::Any(InvalidationScope::Both, "some_address".to_string()); | ||
let expected = format!("{}*some_address*", CACHE_REQS_RESP_PREFIX); | ||
|
||
let actual = invalidation_pattern.to_pattern_string(); | ||
|
||
assert_eq!(expected, actual); | ||
} | ||
|
||
#[test] | ||
fn invalidation_pattern_transactions_string() { | ||
let invalidation_pattern = | ||
InvalidationPattern::Transactions(InvalidationScope::Both, "some_address".to_string()); | ||
let expected = format!("{}*/some_address/*transactions/*", CACHE_REQS_RESP_PREFIX); | ||
|
||
let actual = invalidation_pattern.to_pattern_string(); | ||
|
||
assert_eq!(expected, actual); | ||
} | ||
|
||
#[test] | ||
fn invalidation_pattern_transfers_string() { | ||
let invalidation_pattern = | ||
InvalidationPattern::Transfers(InvalidationScope::Requests, "some_address".to_string()); | ||
let expected = format!("{}*/some_address/*transfer*", CACHE_REQS_PREFIX); | ||
|
||
let actual = invalidation_pattern.to_pattern_string(); | ||
|
||
assert_eq!(expected, actual); | ||
} | ||
|
||
#[test] | ||
fn invalidation_pattern_tokens_string() { | ||
let invalidation_pattern = InvalidationPattern::Tokens; | ||
let expected = TOKENS_KEY.to_string(); | ||
|
||
let actual = invalidation_pattern.to_pattern_string(); | ||
|
||
assert_eq!(expected, actual); | ||
} | ||
|
||
#[test] | ||
fn invalidation_pattern_contracts_string() { | ||
let invalidation_pattern = InvalidationPattern::Contracts; | ||
let expected = String::from("*contract*"); | ||
|
||
let actual = invalidation_pattern.to_pattern_string(); | ||
|
||
assert_eq!(expected, actual); | ||
} | ||
|
||
#[test] | ||
fn invalidation_pattern_balances_string() { | ||
let invalidation_pattern = | ||
InvalidationPattern::Balances(InvalidationScope::Both, "some_address".to_string()); | ||
let expected = format!("{}*/some_address/balances*", CACHE_REQS_RESP_PREFIX); | ||
|
||
let actual = invalidation_pattern.to_pattern_string(); | ||
|
||
assert_eq!(expected, actual); | ||
} | ||
|
||
#[test] | ||
fn invalidation_pattern_collectibles_string() { | ||
let invalidation_pattern = | ||
InvalidationPattern::Collectibles(InvalidationScope::Both, "some_address".to_string()); | ||
let expected = format!("{}*/some_address/collectibles*", CACHE_REQS_RESP_PREFIX); | ||
|
||
let actual = invalidation_pattern.to_pattern_string(); | ||
|
||
assert_eq!(expected, actual); | ||
} | ||
|
||
#[test] | ||
fn invalidation_scope_both_to_string() { | ||
assert_eq!( | ||
CACHE_REQS_RESP_PREFIX, | ||
InvalidationScope::Both.invalidation_scope_string() | ||
) | ||
} | ||
|
||
#[test] | ||
fn invalidation_scope_requests_to_string() { | ||
assert_eq!( | ||
CACHE_REQS_PREFIX, | ||
InvalidationScope::Requests.invalidation_scope_string() | ||
) | ||
} | ||
|
||
#[test] | ||
fn invalidation_scope_responses_to_string() { | ||
assert_eq!( | ||
CACHE_RESP_PREFIX, | ||
InvalidationScope::Responses.invalidation_scope_string() | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
mod cache; | ||
mod cache_inner; | ||
mod cache_operations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters