Skip to content

Commit

Permalink
Update test values
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-pease committed Aug 20, 2024
1 parent 746d6bb commit 5ad5148
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 49 deletions.
18 changes: 9 additions & 9 deletions stellar_rust_sdk/src/liquidity_pools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async fn test_get_all_liquidity_pools() {
"4cd1f6defba237eecbc5fefe259f89ebc4b5edd49116beb5536c4034fc48d63f";
const RSP_1_LIQUIDITY_POOL_FEE_BP: i64 = 30;
const RSP_1_LIQUIDITY_POOL_TYPE: &str = "constant_product";
const RSP_1_LIQUIDITY_POOL_TOTAL_TRUSTLINES: &str = "1";
const RSP_1_LIQUIDITY_POOL_TOTAL_TRUSTLINES: &str = "2";
const RSP_1_LIQUIDITY_POOL_RESERVE_ASSET_0: &str = "native";
const RSP_1_LIQUIDITY_POOL_RESERVE_ASSET_1: &str =
"USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5";
Expand All @@ -94,10 +94,10 @@ async fn test_get_all_liquidity_pools() {
const RSP_2_LIQUIDITY_POOL_TOTAL_TRUSTLINES: &str = "1";
const RSP_2_LIQUIDITY_POOL_TOTAL_SHARES: &str = "249.0000000";
const RSP_2_LIQUIDITY_POOL_RESERVE_ASSET_0: &str = "native";
const RSP_2_LIQUIDITY_POOL_RESERVE_AMOUNT_0: &str = "1249.0000000";
const RSP_2_LIQUIDITY_POOL_RESERVE_AMOUNT_0: &str = "2939.0000000";
const RSP_2_LIQUIDITY_POOL_RESERVE_ASSET_1: &str =
"FLUTTER:GCGTOQSNERFVVJ6Y7YZYDF3MTZIY63KIEFMKA26Q7YPV3AFYD2JSRNYN";
const RSP_2_LIQUIDITY_POOL_RESERVE_AMOUNT_1: &str = "49.7600322";
const RSP_2_LIQUIDITY_POOL_RESERVE_AMOUNT_1: &str = "21.1917647";

const RSP_3_LIQUIDITY_POOL_ID: &str =
"0b3c88caa5aeada296646c1810893e3b04cba0426cff8ff6a63cf6f35cc7f5b3";
Expand All @@ -109,10 +109,10 @@ async fn test_get_all_liquidity_pools() {
const RSP_3_LIQUIDITY_POOL_TOTAL_SHARES: &str = "150.0000000";
const RSP_3_LIQUIDITY_POOL_RESERVE_ASSET_0: &str =
"SDK:GAGTRBIF75N7NUA37JGGJZKXIS4JJKTQERRFWTP5DN4SM4OC2T6QPMQB";
const RSP_3_LIQUIDITY_POOL_RESERVE_AMOUNT_0: &str = "160.0000000";
const RSP_3_LIQUIDITY_POOL_RESERVE_AMOUNT_0: &str = "158.0667366";
const RSP_3_LIQUIDITY_POOL_RESERVE_ASSET_1: &str =
"FLUTTER:GCGTOQSNERFVVJ6Y7YZYDF3MTZIY63KIEFMKA26Q7YPV3AFYD2JSRNYN";
const RSP_3_LIQUIDITY_POOL_RESERVE_AMOUNT_1: &str = "140.6513722";
const RSP_3_LIQUIDITY_POOL_RESERVE_AMOUNT_1: &str = "142.3768102";

let horizon_client =
HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap();
Expand Down Expand Up @@ -294,12 +294,12 @@ async fn test_get_single_liquidity_pool() {
const LIQUIDITY_POOL_TOTAL_SHARES: &str = "249.0000000";
const LIQUIDITY_POOL_RESERVE_ASSET_0: &str =
"native";
const LIQUIDITY_POOL_RESERVE_AMOUNT_0: &str = "1249.0000000";
const LIQUIDITY_POOL_RESERVE_AMOUNT_0: &str = "2939.0000000";
const LIQUIDITY_POOL_RESERVE_ASSET_1: &str =
"FLUTTER:GCGTOQSNERFVVJ6Y7YZYDF3MTZIY63KIEFMKA26Q7YPV3AFYD2JSRNYN";
const LIQUIDITY_POOL_RESERVE_AMOUNT_1: &str = "49.7600322";
const LIQUIDITY_POOL_LAST_MODIFIED_LEDGER: i64 = 716080;
const LIQUIDITY_POOL_LAST_MODIFIED_TIME: &str = "2024-07-25T11:09:01Z";
const LIQUIDITY_POOL_RESERVE_AMOUNT_1: &str = "21.1917647";
const LIQUIDITY_POOL_LAST_MODIFIED_LEDGER: i64 = 1025861;
const LIQUIDITY_POOL_LAST_MODIFIED_TIME: &str = "2024-08-13T07:20:55Z";

let horizon_client =
HorizonClient::new("https://horizon-testnet.stellar.org".to_string()).unwrap();
Expand Down
78 changes: 55 additions & 23 deletions stellar_rust_sdk/src/offers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,26 @@ pub mod test {
use super::prelude::*;
use crate::{horizon_client::HorizonClient, models::*, Paginatable};

const LINK_SELF: &str = "https://horizon-testnet.stellar.org/offers/7";
const LINK_OFFER_MAKER: &str = "https://horizon-testnet.stellar.org/accounts/GCXRNJ23TEHRNXQJEYXGQ3IYGVAWWY6Z2VOOWPP6STTYQCKXIRTNCN3E";
const OFFER_ID: &str = "7";
const PAGING_TOKEN: &str = "7";
const SELLER: &str = "GCXRNJ23TEHRNXQJEYXGQ3IYGVAWWY6Z2VOOWPP6STTYQCKXIRTNCN3E";
const SELLING_ASSET_TYPE: &str = "credit_alphanum12";
const SELLING_ASSET_CODE: &str = "MBAUDD";
const SELLING_ASSET_ISSUER: &str = "GD2YNRNSJ3EOFJAYGLKGKSIOLX2VU3UFDW3YFNOYMAHB26AEHSZBJU4U";
const BUYING_ASSET_TYPE: &str = "credit_alphanum12";
const BUYING_ASSET_CODE: &str = "TMB001128";
const BUYING_ASSET_ISSUER: &str = "GBH2HB7DZN7PRJP5RED2SQZAKSYYBH43PQCQH3NOYT2Y2KLODQZM3M2F";
const AMOUNT: &str = "41011.9400000";
const PRICE_R_N: &u32 = &50;
const PRICE_R_D: &u32 = &467;
const PRICE: &str = "0.1070664";
const LAST_MODIFIED_LEDGER: &u32 = &4739;
const LAST_MODIFIED_TIME: &str = "2024-06-12T03:45:47Z";

#[tokio::test]
async fn test_get_single_offer() {
const LINK_SELF: &str = "https://horizon-testnet.stellar.org/offers/27493";
const LINK_OFFER_MAKER: &str = "https://horizon-testnet.stellar.org/accounts/GCXRNJ23TEHRNXQJEYXGQ3IYGVAWWY6Z2VOOWPP6STTYQCKXIRTNCN3E";
const OFFER_ID: &str = "27493";
const PAGING_TOKEN: &str = "27493";
const SELLER: &str = "GCXRNJ23TEHRNXQJEYXGQ3IYGVAWWY6Z2VOOWPP6STTYQCKXIRTNCN3E";
const SELLING_ASSET_TYPE: &str = "credit_alphanum12";
const SELLING_ASSET_CODE: &str = "MBAUDD";
const SELLING_ASSET_ISSUER: &str = "GD2YNRNSJ3EOFJAYGLKGKSIOLX2VU3UFDW3YFNOYMAHB26AEHSZBJU4U";
const BUYING_ASSET_TYPE: &str = "credit_alphanum12";
const BUYING_ASSET_CODE: &str = "TMB001128";
const BUYING_ASSET_ISSUER: &str = "GBH2HB7DZN7PRJP5RED2SQZAKSYYBH43PQCQH3NOYT2Y2KLODQZM3M2F";
const AMOUNT: &str = "20081.0000000";
const PRICE_R_N: &u32 = &50;
const PRICE_R_D: &u32 = &467;
const PRICE: &str = "0.1070664";
const LAST_MODIFIED_LEDGER: &u32 = &845805;
const LAST_MODIFIED_TIME: &str = "2024-08-02T08:29:11Z";

let horizon_client =
HorizonClient::new("https://horizon-testnet.stellar.org"
.to_string())
Expand Down Expand Up @@ -142,6 +142,22 @@ pub mod test {

#[tokio::test]
async fn test_get_all_offers() {
const LINK_SELF: &str = "https://horizon-testnet.stellar.org/offers/99";
const LINK_OFFER_MAKER: &str = "https://horizon-testnet.stellar.org/accounts/GBJJ5OCBXNZWHSJJ4YQ6ECK24MBJSZMLEMINHKGGEWUA5RU2EDMPN6MS";
const OFFER_ID: &str = "99";
const PAGING_TOKEN: &str = "99";
const SELLER: &str = "GBJJ5OCBXNZWHSJJ4YQ6ECK24MBJSZMLEMINHKGGEWUA5RU2EDMPN6MS";
const SELLING_ASSET_TYPE: &str = "native";
const BUYING_ASSET_TYPE: &str = "credit_alphanum12";
const BUYING_ASSET_CODE: &str = "NewDollar";
const BUYING_ASSET_ISSUER: &str = "GBAKINTNEGR7PO6Z6XW2S5ITT5VARNW6DZ5K4OYSLFNEA2CSMUM2UEF4";
const AMOUNT: &str = "10.0000000";
const PRICE_R_N: &u32 = &1;
const PRICE_R_D: &u32 = &1;
const PRICE: &str = "1.0000000";
const LAST_MODIFIED_LEDGER: &u32 = &5858;
const LAST_MODIFIED_TIME: &str = "2024-06-12T05:23:41Z";

let horizon_client =
HorizonClient::new("https://horizon-testnet.stellar.org"
.to_string())
Expand All @@ -164,8 +180,6 @@ pub mod test {
assert_eq!(record.paging_token(), PAGING_TOKEN);
assert_eq!(record.seller(), SELLER);
assert_eq!(record.selling().asset_type(), SELLING_ASSET_TYPE);
assert_eq!(record.selling().asset_code().as_ref().unwrap(), SELLING_ASSET_CODE);
assert_eq!(record.selling().asset_issuer().as_ref().unwrap(), SELLING_ASSET_ISSUER);
assert_eq!(record.buying().asset_type(), BUYING_ASSET_TYPE);
assert_eq!(record.buying().asset_code().as_ref().unwrap(), BUYING_ASSET_CODE);
assert_eq!(record.buying().asset_issuer().as_ref().unwrap(), BUYING_ASSET_ISSUER);
Expand All @@ -190,12 +204,12 @@ pub mod test {
const BUYING_ASSET_TYPE: &str = "credit_alphanum12";
const BUYING_ASSET_CODE: &str = "EURCAllow";
const BUYING_ASSET_ISSUER: &str = "GA6HVGLFUF3BHHGR5CMYXIVZ3RYVUH5EUYAOAY4T3OKI5OQVIWVRK24R";
const AMOUNT: &str = "922307928093.4475807";
const AMOUNT: &str = "922192119415.1975807";
const PRICE_R_N: &u32 = &1;
const PRICE_R_D: &u32 = &1;
const PRICE: &str = "1.0000000";
const LAST_MODIFIED_LEDGER: &u32 = &286496;
const LAST_MODIFIED_TIME: &str = "2024-06-29T07:08:23Z";
const LAST_MODIFIED_LEDGER: &u32 = &923809;
const LAST_MODIFIED_TIME: &str = "2024-08-07T02:21:13Z";

let horizon_client =
HorizonClient::new("https://horizon-testnet.stellar.org"
Expand Down Expand Up @@ -238,6 +252,24 @@ pub mod test {
#[tokio::test]
async fn test_get_offers_for_account() {
const ACCOUNT_ID: &str = "GCXRNJ23TEHRNXQJEYXGQ3IYGVAWWY6Z2VOOWPP6STTYQCKXIRTNCN3E";
const LINK_SELF: &str = "https://horizon-testnet.stellar.org/offers/27493";
const LINK_OFFER_MAKER: &str = "https://horizon-testnet.stellar.org/accounts/GCXRNJ23TEHRNXQJEYXGQ3IYGVAWWY6Z2VOOWPP6STTYQCKXIRTNCN3E";
const OFFER_ID: &str = "27493";
const PAGING_TOKEN: &str = "27493";
const SELLER: &str = "GCXRNJ23TEHRNXQJEYXGQ3IYGVAWWY6Z2VOOWPP6STTYQCKXIRTNCN3E";
const SELLING_ASSET_TYPE: &str = "credit_alphanum12";
const SELLING_ASSET_CODE: &str = "MBAUDD";
const SELLING_ASSET_ISSUER: &str = "GD2YNRNSJ3EOFJAYGLKGKSIOLX2VU3UFDW3YFNOYMAHB26AEHSZBJU4U";
const BUYING_ASSET_TYPE: &str = "credit_alphanum12";
const BUYING_ASSET_CODE: &str = "TMB001128";
const BUYING_ASSET_ISSUER: &str = "GBH2HB7DZN7PRJP5RED2SQZAKSYYBH43PQCQH3NOYT2Y2KLODQZM3M2F";
const AMOUNT: &str = "20081.0000000";
const PRICE_R_N: &u32 = &50;
const PRICE_R_D: &u32 = &467;
const PRICE: &str = "0.1070664";
const LAST_MODIFIED_LEDGER: &u32 = &845805;
const LAST_MODIFIED_TIME: &str = "2024-08-02T08:29:11Z";

let horizon_client =
HorizonClient::new("https://horizon-testnet.stellar.org"
.to_string())
Expand Down
6 changes: 3 additions & 3 deletions stellar_rust_sdk/src/order_book/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ pub mod tests {
use crate::horizon_client;
use crate::order_book::prelude::{Asset, AssetType, DetailsRequest};

const BIDS_N: &u32 = &3;
const BIDS_D: &u32 = &2;
const BIDS_PRICE: &str = "1.5000000";
const BIDS_N: &u32 = &1;
const BIDS_D: &u32 = &5;
const BIDS_PRICE: &str = "0.2000000";
const ASKS_N: &u32 = &5;
const ASKS_D: &u32 = &1;
const ASKS_PRICE: &str = "5.0000000";
Expand Down
20 changes: 9 additions & 11 deletions stellar_rust_sdk/src/trades/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ pub mod test {
assert_eq!(response.base_asset_type().as_ref().unwrap(), BASE_ASSET_TYPE);
assert_eq!(response.base_asset_code().as_ref().unwrap(), BASE_ASSET_CODE);
assert_eq!(response.base_asset_issuer().as_ref().unwrap(), BASE_ASSET_ISSUER);
assert_eq!(response.counter_offer_id(), COUNTER_OFFER_ID);
assert_eq!(response.counter_account(), COUNTER_ACCOUNT);
assert_eq!(response.counter_offer_id().as_ref().unwrap(), COUNTER_OFFER_ID);
assert_eq!(response.counter_account().as_ref().unwrap(), COUNTER_ACCOUNT);
assert_eq!(response.counter_amount(), COUNTER_AMOUNT);
assert_eq!(response.counter_asset_type().as_ref().unwrap(), COUNTER_ASSET_TYPE);
assert_eq!(response.counter_asset_code().as_ref().unwrap(), COUNTER_ASSET_CODE);
Expand Down Expand Up @@ -211,8 +211,8 @@ pub mod test {
assert_eq!(response.base_asset_type().as_ref().unwrap(), BASE_ASSET_TYPE);
assert_eq!(response.base_asset_code().as_ref().unwrap(), BASE_ASSET_CODE);
assert_eq!(response.base_asset_issuer().as_ref().unwrap(), BASE_ASSET_ISSUER);
assert_eq!(response.counter_offer_id(), COUNTER_OFFER_ID);
assert_eq!(response.counter_account(), COUNTER_ACCOUNT);
assert_eq!(response.counter_offer_id().as_ref().unwrap(), COUNTER_OFFER_ID);
assert_eq!(response.counter_account().as_ref().unwrap(), COUNTER_ACCOUNT);
assert_eq!(response.counter_amount(), COUNTER_AMOUNT);
assert_eq!(response.counter_asset_type().as_ref().unwrap(), COUNTER_ASSET_TYPE);
assert_eq!(response.counter_asset_code().as_ref().unwrap(), COUNTER_ASSET_CODE);
Expand Down Expand Up @@ -260,7 +260,7 @@ pub mod test {
.get_trades_for_liquidity_pool(&trades_for_liquidity_pool_request)
.await;

assert!(trades_for_liquidity_pool_response.clone().is_ok());
// assert!(trades_for_liquidity_pool_response.clone().is_ok());
let binding = trades_for_liquidity_pool_response.unwrap();
let response = &binding.embedded().records()[0];
assert_eq!(response.links().self_link().href().as_ref().unwrap(), LINK_SELF);
Expand All @@ -277,8 +277,8 @@ pub mod test {
assert_eq!(response.base_asset_type().as_ref().unwrap(), BASE_ASSET_TYPE);
assert_eq!(response.base_asset_code().as_ref().unwrap(), BASE_ASSET_CODE);
assert_eq!(response.base_asset_issuer().as_ref().unwrap(), BASE_ASSET_ISSUER);
assert_eq!(response.counter_offer_id(), COUNTER_OFFER_ID);
assert_eq!(response.counter_account(), COUNTER_ACCOUNT);
assert_eq!(response.counter_offer_id().as_ref().unwrap(), COUNTER_OFFER_ID);
assert_eq!(response.counter_account().as_ref().unwrap(), COUNTER_ACCOUNT);
assert_eq!(response.counter_amount(), COUNTER_AMOUNT);
assert_eq!(response.counter_asset_type().as_ref().unwrap(), COUNTER_ASSET_TYPE);
assert_eq!(response.counter_asset_code().as_ref().unwrap(), COUNTER_ASSET_CODE);
Expand All @@ -305,7 +305,6 @@ pub mod test {
const BASE_ASSET_TYPE: &str = "credit_alphanum4";
const BASE_ASSET_CODE: &str = "XETH";
const BASE_ASSET_ISSUER: &str = "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI";
const COUNTER_OFFER_ID: &str = "21";
const COUNTER_ACCOUNT: &str = "GBHRHA3KGRJBXBFER7VHI3WS5SKUXOP5TQ3YITVD7WJ2D3INGK62FZJR";
const COUNTER_AMOUNT: &str = "1.0800000";
const COUNTER_ASSET_TYPE: &str = "credit_alphanum4";
Expand All @@ -326,7 +325,7 @@ pub mod test {
.get_trades_for_offer(&trades_for_offer_request)
.await;

// assert!(trades_for_liquidity_pools_response.clone().is_ok());
assert!(trades_for_liquidity_pools_response.clone().is_ok());
let binding = trades_for_liquidity_pools_response.unwrap();
let response = &binding.embedded().records()[0];
assert_eq!(response.links().self_link().href().as_ref().unwrap(), LINK_SELF);
Expand All @@ -343,8 +342,7 @@ pub mod test {
assert_eq!(response.base_asset_type().as_ref().unwrap(), BASE_ASSET_TYPE);
assert_eq!(response.base_asset_code().as_ref().unwrap(), BASE_ASSET_CODE);
assert_eq!(response.base_asset_issuer().as_ref().unwrap(), BASE_ASSET_ISSUER);
assert_eq!(response.counter_offer_id(), COUNTER_OFFER_ID);
assert_eq!(response.counter_account(), COUNTER_ACCOUNT);
assert_eq!(response.counter_account().as_ref().unwrap(), COUNTER_ACCOUNT);
assert_eq!(response.counter_amount(), COUNTER_AMOUNT);
assert_eq!(response.counter_asset_type().as_ref().unwrap(), COUNTER_ASSET_TYPE);
assert_eq!(response.counter_asset_code().as_ref().unwrap(), COUNTER_ASSET_CODE);
Expand Down
6 changes: 3 additions & 3 deletions stellar_rust_sdk/src/trades/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ pub struct TradeResponse {
base_asset_issuer: Option<String>,
// The counter liquidity pool ID, if this trade was executed against a liquidity pool.
counter_liquidity_pool_id: Option<String>,
// The counter offer ID.
counter_offer_id: String,
// The counter offer ID. Optional.
counter_offer_id: Option<String>,
// The account ID of the counter party for this trade.
counter_account: String,
counter_account: Option<String>,
// The amount of the counter asset that was moved from `counter_account` to `base_account`.
counter_amount: String,
// The type for the counter asset. Either `native`, `credit_alphanum4`, or `credit_alphanum12`.
Expand Down

0 comments on commit 5ad5148

Please sign in to comment.