Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:KomodoPlatform/atomicDEX-API into ad…
Browse files Browse the repository at this point in the history
…ex-cli-ci-flows

Signed-off-by: ozkanonur <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed May 12, 2023
2 parents 096b1d6 + 6339139 commit 1d3ac6f
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 11 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/adex-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ jobs:
cargo fmt --manifest-path ./mm2src/adex_cli/Cargo.toml --all -- --check
cargo clippy --manifest-path ./mm2src/adex_cli/Cargo.toml --all-targets --all-features -- --D warnings
test:
timeout-minutes: 60
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3

- name: pre scripts for ci container
run: |
git config --global --add safe.directory /__w/atomicDEX-API/atomicDEX-API
echo "/bin" >> $GITHUB_PATH
echo "/usr/bin" >> $GITHUB_PATH
echo "/root/.cargo/bin" >> $GITHUB_PATH
- name: Calculate commit hash for PR commit
if: github.event_name == 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 ${{ github.event.pull_request.head.sha }})" >> $GITHUB_ENV

- name: Calculate commit hash for merge commit
if: github.event_name != 'pull_request'
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV

- name: Start testing
run: |
cargo test --manifest-path ./mm2src/adex_cli/Cargo.toml
build:
timeout-minutes: 60
runs-on: ${{ matrix.os }}
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
- PoC for ETH/UTXO and ERC20/UTXO swaps with rewards
- Improved protocol to let only the taker pay the reward
- Add passive parent coin state for keeping tokens active when platform is disabled [#1763](https://github.com/KomodoPlatform/atomicDEX-API/pull/1763)
- Optimize release compilation profile for mm2 [#1821](https://github.com/KomodoPlatform/atomicDEX-API/pull/1821)
- CI flows for `adex-cli` added [#1818](https://github.com/KomodoPlatform/atomicDEX-API/pull/1818)
- Detect a chain reorganization, if it occurs, redownload and revalidate the new best chain headers for SPV [#1728](https://github.com/KomodoPlatform/atomicDEX-API/pull/1728)

- Fix moralis request in wasm target, add moralis tests [#1817](https://github.com/KomodoPlatform/atomicDEX-API/pull/1817)

## v1.0.3-beta - 2023-04-28

Expand Down
10 changes: 2 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ exclude = [
resolver = "2"

[profile.release]
debug = 1
debug = 0
debug-assertions = false
# For some reason, opt-level 3 started causing infinite Windows builds after Cosmos integration
# TODO troubleshoot it
opt-level = 2
opt-level = 3
# strip = true
codegen-units = 1
# lto = true
Expand All @@ -63,10 +61,6 @@ panic = "abort"
# required to avoid a long running process of librustcash additional chain validation that is enabled with debug assertions
debug-assertions = false

[profile.release.overrides."*"]
# Turns debugging symbols off for the out-of-workspace dependencies.
debug = false

[profile.dev]
opt-level = 0
debug = 1
Expand Down
3 changes: 1 addition & 2 deletions mm2src/coins/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use mm2_err_handle::prelude::{MmError, MmResult};

pub(crate) mod nft_errors;
pub(crate) mod nft_structs;
#[cfg(any(test, target_arch = "wasm32"))] mod nft_tests;

use crate::WithdrawError;
use nft_errors::GetNftInfoError;
Expand Down Expand Up @@ -243,8 +244,6 @@ async fn send_moralis_request(uri: &str) -> MmResult<Json, GetNftInfoError> {
}

let result = FetchRequest::get(uri)
.cors()
.body_utf8("".to_owned())
.header(ACCEPT.as_str(), APPLICATION_JSON)
.request_str()
.await;
Expand Down
80 changes: 80 additions & 0 deletions mm2src/coins/nft/nft_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const NFT_LIST_URL_TEST: &str = "https://moralis-proxy.komodo.earth/api/v2/0x394d86994f954ed931b86791b62fe64f4c5dac37/nft?chain=POLYGON&format=decimal";
const NFT_HISTORY_URL_TEST: &str = "https://moralis-proxy.komodo.earth/api/v2/0x394d86994f954ed931b86791b62fe64f4c5dac37/nft/transfers?chain=POLYGON&format=decimal&direction=both";
const NFT_METADATA_URL_TEST: &str = "https://moralis-proxy.komodo.earth/api/v2/nft/0xed55e4477b795eaa9bb4bca24df42214e1a05c18/1111777?chain=POLYGON&format=decimal";
const TEST_WALLET_ADDR_EVM: &str = "0x394d86994f954ed931b86791b62fe64f4c5dac37";

#[cfg(all(test, not(target_arch = "wasm32")))]
mod native_tests {
use crate::nft::nft_structs::{NftTransferHistoryWrapper, NftWrapper};
use crate::nft::nft_tests::{NFT_HISTORY_URL_TEST, NFT_LIST_URL_TEST, NFT_METADATA_URL_TEST, TEST_WALLET_ADDR_EVM};
use crate::nft::send_moralis_request;
use common::block_on;

#[test]
fn test_moralis_nft_list() {
let response = block_on(send_moralis_request(NFT_LIST_URL_TEST)).unwrap();
let nfts_list = response["result"].as_array().unwrap();
assert_eq!(2, nfts_list.len());
for nft_json in nfts_list {
let nft_wrapper: NftWrapper = serde_json::from_str(&nft_json.to_string()).unwrap();
assert_eq!(TEST_WALLET_ADDR_EVM, nft_wrapper.owner_of)
}
}

#[test]
fn test_moralis_nft_transfer_history() {
let response = block_on(send_moralis_request(NFT_HISTORY_URL_TEST)).unwrap();
let transfer_list = response["result"].as_array().unwrap();
assert_eq!(2, transfer_list.len());
for transfer in transfer_list {
let transfer_wrapper: NftTransferHistoryWrapper = serde_json::from_str(&transfer.to_string()).unwrap();
assert_eq!(TEST_WALLET_ADDR_EVM, transfer_wrapper.to_address);
}
}

#[test]
fn test_moralis_nft_metadata() {
let response = block_on(send_moralis_request(NFT_METADATA_URL_TEST)).unwrap();
let nft_wrapper: NftWrapper = serde_json::from_str(&response.to_string()).unwrap();
assert_eq!(41237364, *nft_wrapper.block_number_minted)
}
}

#[cfg(target_arch = "wasm32")]
mod wasm_tests {
use crate::nft::nft_structs::{NftTransferHistoryWrapper, NftWrapper};
use crate::nft::nft_tests::{NFT_HISTORY_URL_TEST, NFT_LIST_URL_TEST, NFT_METADATA_URL_TEST, TEST_WALLET_ADDR_EVM};
use crate::nft::send_moralis_request;
use wasm_bindgen_test::*;

wasm_bindgen_test_configure!(run_in_browser);

#[wasm_bindgen_test]
async fn test_moralis_nft_list() {
let response = send_moralis_request(NFT_LIST_URL_TEST).await.unwrap();
let nfts_list = response["result"].as_array().unwrap();
assert_eq!(2, nfts_list.len());
for nft_json in nfts_list {
let nft_wrapper: NftWrapper = serde_json::from_str(&nft_json.to_string()).unwrap();
assert_eq!(TEST_WALLET_ADDR_EVM, nft_wrapper.owner_of)
}
}

#[wasm_bindgen_test]
async fn test_moralis_nft_transfer_history() {
let response = send_moralis_request(NFT_HISTORY_URL_TEST).await.unwrap();
let transfer_list = response["result"].as_array().unwrap();
assert_eq!(2, transfer_list.len());
for transfer in transfer_list {
let transfer_wrapper: NftTransferHistoryWrapper = serde_json::from_str(&transfer.to_string()).unwrap();
assert_eq!(TEST_WALLET_ADDR_EVM, transfer_wrapper.to_address);
}
}

#[wasm_bindgen_test]
async fn test_moralis_nft_metadata() {
let response = send_moralis_request(NFT_METADATA_URL_TEST).await.unwrap();
let nft_wrapper: NftWrapper = serde_json::from_str(&response.to_string()).unwrap();
assert_eq!(41237364, *nft_wrapper.block_number_minted)
}
}

0 comments on commit 1d3ac6f

Please sign in to comment.