|
10 | 10 | use crate::common::{ |
11 | 11 | generate_funded_wallet, get_ledger_close_time, test_transaction, with_blockchain_lock, |
12 | 12 | }; |
| 13 | +use xrpl::asynch::clients::XRPLAsyncClient; |
| 14 | +use xrpl::models::requests::account_objects::{AccountObjectType, AccountObjects}; |
| 15 | +use xrpl::models::requests::LedgerIndex; |
| 16 | +use xrpl::models::results::account_objects::AccountObjects as AccountObjectsResult; |
13 | 17 | use xrpl::models::transactions::oracle_set::OracleSet; |
14 | 18 | use xrpl::models::transactions::{CommonFields, PriceData, TransactionType}; |
15 | 19 |
|
@@ -108,6 +112,46 @@ async fn test_oracle_set_submit() { |
108 | 112 | ); |
109 | 113 |
|
110 | 114 | test_transaction(&mut oracle_set, &wallet).await; |
| 115 | + |
| 116 | + let client = crate::common::get_client().await; |
| 117 | + let response = client |
| 118 | + .request( |
| 119 | + AccountObjects::new( |
| 120 | + None, |
| 121 | + wallet.classic_address.clone().into(), |
| 122 | + None, |
| 123 | + Some(LedgerIndex::Str("validated".into())), |
| 124 | + Some(AccountObjectType::Oracle), |
| 125 | + None, |
| 126 | + None, |
| 127 | + None, |
| 128 | + ) |
| 129 | + .into(), |
| 130 | + ) |
| 131 | + .await |
| 132 | + .expect("account_objects oracle request failed"); |
| 133 | + let result: AccountObjectsResult = response |
| 134 | + .try_into() |
| 135 | + .expect("failed to parse account_objects result"); |
| 136 | + assert_eq!(result.account_objects.len(), 1); |
| 137 | + let oracle = &result.account_objects[0]; |
| 138 | + assert_eq!(oracle["LedgerEntryType"], "Oracle"); |
| 139 | + assert_eq!(oracle["Owner"], wallet.classic_address); |
| 140 | + assert_eq!(oracle["Provider"], "636861696E6C696E6B"); |
| 141 | + assert_eq!(oracle["AssetClass"], "63757272656E6379"); |
| 142 | + assert_eq!( |
| 143 | + oracle["PriceDataSeries"][0]["PriceData"]["BaseAsset"], |
| 144 | + "XRP" |
| 145 | + ); |
| 146 | + assert_eq!( |
| 147 | + oracle["PriceDataSeries"][0]["PriceData"]["QuoteAsset"], |
| 148 | + "USD" |
| 149 | + ); |
| 150 | + assert_eq!( |
| 151 | + oracle["PriceDataSeries"][0]["PriceData"]["AssetPrice"], |
| 152 | + "2e4" |
| 153 | + ); |
| 154 | + assert_eq!(oracle["PriceDataSeries"][0]["PriceData"]["Scale"], 1); |
111 | 155 | }) |
112 | 156 | .await; |
113 | 157 | } |
0 commit comments