Skip to content

Commit

Permalink
Merge pull request #789 from getgems-io/fix_ci_tests
Browse files Browse the repository at this point in the history
fix: fix broken tests and ignore expensive tests
  • Loading branch information
akostylev0 authored Apr 22, 2024
2 parents 3b5b242 + 15c9bb1 commit f257c0d
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 29 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/pr-check.yml → .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,6 @@ jobs:
targets: x86_64-unknown-linux-gnu
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- run: cargo build -v --target x86_64-unknown-linux-gnu
env:
RUSTFLAGS: ""
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CMAKE_C_COMPILER_LAUNCHER: "sccache"
CMAKE_CXX_COMPILER_LAUNCHER: "sccache"
- run: cargo build -v --target x86_64-unknown-linux-gnu --features testnet
env:
RUSTFLAGS: ""
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CMAKE_C_COMPILER_LAUNCHER: "sccache"
CMAKE_CXX_COMPILER_LAUNCHER: "sccache"
- uses: actions-rs/clippy-check@v1
env:
RUSTFLAGS: ""
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Test PR
on:
pull_request:
branches:
- "master"
paths-ignore:
- .github/workflows/charts-*
- charts/**
- .release-please-manifest.json
- release-please-config.json
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pr-tests:
strategy:
matrix:
include:
- features: ''
- features: 'testnet'
name: Run cargo tests
runs-on:
group: "CPUBound"
permissions:
contents: read
checks: write
security-events: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libsecp256k1-dev libsodium-dev liblz4-dev
- uses: arduino/setup-protoc@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- run: cargo test --target x86_64-unknown-linux-gnu --no-fail-fast --features "${{ matrix.features }}"
env:
RUSTFLAGS: ""
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CMAKE_C_COMPILER_LAUNCHER: "sccache"
CMAKE_CXX_COMPILER_LAUNCHER: "sccache"
3 changes: 3 additions & 0 deletions adnl-tcp/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ mod tests {

#[traced_test]
#[tokio::test]
#[ignore]
async fn client_connect() -> anyhow::Result<()> {
let _ = provided_client().await?;

Expand All @@ -139,6 +140,7 @@ mod tests {

#[traced_test]
#[tokio::test]
#[ignore]
async fn client_connect_wrong_key() -> anyhow::Result<()> {
let ip: i32 = -2018147075;
let ip = Ipv4Addr::from(ip as u32);
Expand All @@ -157,6 +159,7 @@ mod tests {

#[traced_test]
#[tokio::test]
#[ignore]
async fn client_ping() -> anyhow::Result<()> {
let mut client = provided_client().await?;

Expand Down
5 changes: 5 additions & 0 deletions ton-grpc/src/account.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::blocks_in_conditions)]

use std::pin::Pin;
use std::str::FromStr;
use tonic::{async_trait, Request, Response, Status};
Expand Down Expand Up @@ -176,6 +178,7 @@ mod tests {

#[tokio::test]
#[traced_test]
#[ignore]
async fn account_get_from_to() {
tracing::info!("prep client");
let mut client = TonClientBuilder::default().await.unwrap();
Expand Down Expand Up @@ -204,6 +207,7 @@ mod tests {

#[tokio::test]
#[traced_test]
#[ignore]
async fn get_account_state_without_criteria() {
tracing::info!("prep client");
let mut client = TonClientBuilder::default().await.unwrap();
Expand All @@ -223,6 +227,7 @@ mod tests {

#[tokio::test]
#[traced_test]
#[ignore]
async fn get_shard_account_cell_without_criteria() {
tracing::info!("prep client");
let mut client = TonClientBuilder::default().await.unwrap();
Expand Down
2 changes: 2 additions & 0 deletions ton-grpc/src/block.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::blocks_in_conditions)]

use anyhow::Context;
use futures::stream::BoxStream;
use futures::{StreamExt, TryStreamExt};
Expand Down
2 changes: 2 additions & 0 deletions ton-grpc/src/message.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::blocks_in_conditions)]

use tonic::{async_trait, Request, Response, Status};
use tonlibjson_client::ton::TonClient;
use derive_new::new;
Expand Down
11 changes: 8 additions & 3 deletions ton-liteserver-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ pub struct ResponseFuture<Response> {

impl<Response> ResponseFuture<Response> {
fn new(query_id: Int256, rx: Receiver<Bytes>, responses: Arc<DashMap<Int256, tokio::sync::oneshot::Sender<Bytes>>>) -> Self {
Self { state: ResponseState::Rx { query_id, responses, rx }, _phantom: PhantomData::default() }
Self { state: ResponseState::Rx { query_id, responses, rx }, _phantom: PhantomData }
}

fn failed(error: Error) -> Self {
Self { state: ResponseState::Failed { error: Some(error) }, _phantom: PhantomData::default() }
Self { state: ResponseState::Failed { error: Some(error) }, _phantom: PhantomData }
}
}

Expand Down Expand Up @@ -184,7 +184,7 @@ impl<Response> Future for ResponseFuture<Response> where Response : BoxedType +
Ok(response) => {
let response = from_bytes::<Result<Response, LiteServerError>>(response)
.map_err(|_| Error::Deserialize)?
.map_err(|e| Error::LiteServerError(e))?;
.map_err(Error::LiteServerError)?;

Poll::Ready(Ok(response))
}
Expand All @@ -210,6 +210,7 @@ mod tests {

#[tokio::test]
#[traced_test]
#[ignore]
async fn client_get_masterchain_info() -> anyhow::Result<()> {
let client = provided_client().await?;

Expand All @@ -223,6 +224,7 @@ mod tests {

#[tokio::test]
#[traced_test]
#[ignore]
async fn client_get_all_shards_info() -> anyhow::Result<()> {
let mut client = provided_client().await?;
let response = (&mut client).oneshot((LiteServerGetMasterchainInfo {}).into_boxed()).await?.unbox();
Expand All @@ -239,6 +241,7 @@ mod tests {

#[tokio::test]
#[traced_test]
#[ignore]
async fn client_get_version() -> anyhow::Result<()> {
let client = provided_client().await?;

Expand All @@ -251,6 +254,7 @@ mod tests {

#[tokio::test]
#[traced_test]
#[ignore]
async fn client_error_test() -> anyhow::Result<()> {
let client = provided_client().await?;

Expand All @@ -264,6 +268,7 @@ mod tests {

#[tokio::test]
#[traced_test]
#[ignore]
async fn client_get_block_proof_test() -> anyhow::Result<()> {
let mut client = provided_client().await?;
let known_block = (&mut client).oneshot((LiteServerGetMasterchainInfo {}).into_boxed()).await?.unbox().last;
Expand Down
2 changes: 1 addition & 1 deletion tonlibjson-client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl Generator {

for (type_ident, types) in map {
eprintln!("type_ident = {:}", type_ident);
if skip_list.contains(&&type_ident) {
if skip_list.contains(&type_ident) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion tonlibjson-client/examples/dnsresolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tonlibjson_client::dns_discover::DnsResolverDiscover;
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt::init();

let mut discover = DnsResolverDiscover::new("ton-liteserver-headless.ton-grpc-mainnet.svc.cluster.local");
let mut discover = DnsResolverDiscover::new("ton-liteserver-headless.ton-grpc-mainnet.svc.cluster.local", "pubkey");

while let Ok(record) = discover.next().await.unwrap() {
tracing::info!(record = ?record);
Expand Down
4 changes: 3 additions & 1 deletion tonlibjson-client/examples/getgems_balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ async fn main() -> anyhow::Result<()> {
let tx: RawTransaction = tx.unwrap();
if let Some(msg) = tx.out_msgs.first() {
Some(-msg.value - tx.fee)
} else if let Some(msg) = tx.in_msg {
Some(msg.value - tx.fee)
} else {
Some(tx.in_msg.value - tx.fee)
Some(0)
}
})
.collect::<Vec<i64>>()
Expand Down
4 changes: 1 addition & 3 deletions tonlibjson-client/examples/txs.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::time::Duration;
use url::Url;
use tonlibjson_client::address::AccountAddressData;
use tonlibjson_client::block::{BlocksAccountTransactionId, RawTransaction};
use tonlibjson_client::block::{RawTransaction};
use tonlibjson_client::ton::{TonClient, TonClientBuilder};
use std::str::FromStr;
use futures::stream::StreamExt;

async fn client() -> TonClient {
Expand Down
2 changes: 1 addition & 1 deletion tonlibjson-client/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Routable for BlocksLookupBlock {
fn route(&self) -> Route {
let criteria = match self.mode {
2 => BlockCriteria::LogicalTime(self.lt),
1 | _ => BlockCriteria::Seqno { shard: self.id.shard, seqno: self.id.seqno }
_ => BlockCriteria::Seqno { shard: self.id.shard, seqno: self.id.seqno }
};

Route::Block { chain: self.id.workchain, criteria }
Expand Down
1 change: 1 addition & 0 deletions tonlibjson-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ mod tests {

#[tokio::test]
#[traced_test]
#[ignore]
async fn not_initialized_call() {
let mut client = Client::default();

Expand Down
4 changes: 1 addition & 3 deletions tonlibjson-client/src/cursor_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ impl ShardBounds {
}

fn right_next(&self) -> Option<Seqno> {
let Some(seqno) = self.right_end else {
return None;
};
let seqno = self.right_end?;

match self.right {
None => Some(seqno),
Expand Down
3 changes: 1 addition & 2 deletions tonlibjson-client/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ impl Service<&Route> for Router {
let req = *req;
let svcs = self.services.clone();
Retry::spawn(FibonacciBackoff::from_millis(32).map(jitter).take(10), move || {
let req = req.clone();
let svcs = svcs.clone();

async move { req.choose(&svcs) }
Expand Down Expand Up @@ -149,7 +148,7 @@ impl Route {
.collect());
}

return Err(RouterError::RouteUnknown);
Err(RouterError::RouteUnknown)
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions tonlibjson-client/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ async fn client() -> TonClient {

#[tokio::test]
#[traced_test]
#[ignore]
async fn get_account_tx_stream_starts_from() -> anyhow::Result<()> {
let client = client().await;
let address = "EQCjk1hh952vWaE9bRguFkAhDAL5jj3xj9p0uPWrFBq_GEMS".to_owned();
Expand All @@ -38,6 +39,7 @@ async fn get_account_tx_stream_starts_from() -> anyhow::Result<()> {

#[tokio::test]
#[traced_test]
#[ignore]
async fn get_account_tx_stream_contains_only_one_transaction() -> anyhow::Result<()> {
let client = client().await;
let address = "EQBO_mAVkaHxt6Ibz7wqIJ_UIDmxZBFcgkk7fvIzkh7l42wO".to_owned();
Expand All @@ -56,6 +58,7 @@ async fn get_account_tx_stream_contains_only_one_transaction() -> anyhow::Result

#[tokio::test]
#[traced_test]
#[ignore]
async fn get_block_tx_stream_correct() -> anyhow::Result<()> {
let client = client().await;
let block = client.look_up_block_by_seqno(0, -9223372036854775808, 34716987).await?;
Expand All @@ -70,6 +73,7 @@ async fn get_block_tx_stream_correct() -> anyhow::Result<()> {

#[tokio::test]
#[traced_test]
#[ignore]
async fn get_block_tx_stream_reverse_correct() -> anyhow::Result<()> {
let client = client().await;
let block = client.look_up_block_by_seqno(0, -9223372036854775808, 34716987).await?;
Expand All @@ -85,6 +89,7 @@ async fn get_block_tx_stream_reverse_correct() -> anyhow::Result<()> {

#[tokio::test]
#[traced_test]
#[ignore]
async fn get_block_tx_stream_unordered_correct() -> anyhow::Result<()> {
let client = client().await;
let block = client.look_up_block_by_seqno(0, -9223372036854775808, 34716987).await?;
Expand Down

0 comments on commit f257c0d

Please sign in to comment.