This repository was archived by the owner on Jun 1, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathasset_mock.rs
More file actions
72 lines (58 loc) · 2.03 KB
/
asset_mock.rs
File metadata and controls
72 lines (58 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use crate::{
Asset, AssetId, AssetType, Chain,
asset_constants::{ETHEREUM_USDC_ASSET_ID, SOLANA_USDC_ASSET_ID, TON_USDT_ASSET_ID},
};
impl Asset {
pub fn mock() -> Self {
Asset::from_chain(Chain::Ethereum)
}
pub fn mock_sol() -> Self {
Asset::from_chain(Chain::Solana)
}
pub fn mock_spl_token() -> Self {
Asset::new(SOLANA_USDC_ASSET_ID.clone(), "USD Coin".to_string(), "USDC".to_string(), 6, AssetType::SPL)
}
pub fn mock_ethereum_usdc() -> Self {
Asset::new(ETHEREUM_USDC_ASSET_ID.clone(), "USD Coin".to_string(), "USDC".to_string(), 6, AssetType::ERC20)
}
pub fn mock_ton_usdt() -> Self {
Asset::new(TON_USDT_ASSET_ID.clone(), "Tether USD".to_string(), "USDT".to_string(), 6, AssetType::JETTON)
}
pub fn mock_eth() -> Self {
Asset::from_chain(Chain::Ethereum)
}
pub fn mock_btc() -> Self {
Asset::from_chain(Chain::Bitcoin)
}
pub fn mock_erc20() -> Self {
Asset::new(
AssetId::from_token(Chain::Ethereum, "0xA0b86a33E6441066d64bb38954e41F6b4b925c59"),
"USD Coin".to_string(),
"USDC".to_string(),
6,
AssetType::ERC20,
)
}
pub fn mock_with_chain(chain: Chain) -> Self {
Asset::from_chain(chain)
}
pub fn mock_with_params(chain: Chain, token_id: Option<String>, name: String, symbol: String, decimals: i32, asset_type: AssetType) -> Self {
Asset::new(AssetId::from(chain, token_id), name, symbol, decimals, asset_type)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_asset_mock() {
let asset = Asset::mock();
assert_eq!(asset.symbol, "ETH");
assert_eq!(asset.chain, Chain::Ethereum);
let sol_asset = Asset::mock_sol();
assert_eq!(sol_asset.symbol, "SOL");
assert_eq!(sol_asset.chain, Chain::Solana);
let spl_asset = Asset::mock_spl_token();
assert_eq!(spl_asset.symbol, "USDC");
assert_eq!(spl_asset.asset_type, AssetType::SPL);
}
}