diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..a0819222 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,52 @@ +name: Cargo Build & Test + +on: + push: + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + build_and_test: + name: Rust project - latest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Install Dependencies + run: | + sudo apt-get update -y + sudo apt-get upgrade -y + sudo apt-get install libssl-dev openssl -y + + - name: Early Build + run: cargo build --workspace --tests + + - name: Install node deps + run: yarn + + - name: Setup validator + run: | + sh -c "$(curl -sSfL https://release.solana.com/v1.15.2/install)" + echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH + export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH" + ls "$HOME/.local/share/solana/install/active_release/bin" + echo "Solana Cli installed" + solana --version + echo "Generating keypair..." + solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent + solana config set --url "http://0.0.0.0:8899" + + - name: Run and Test + run: | + sh -c "solana-test-validator" & + sleep 20 && solana airdrop 10000 + cargo run & + sleep 20 && cargo test + yarn test + pkill lite-rpc + kill $(jobs -p) diff --git a/.gitignore b/.gitignore index 8eaa38f0..a59e8375 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ bench/metrics.csv *.pem* *.pks* .env +test-ledger diff --git a/Cargo.lock b/Cargo.lock index 3d2d9d88..04e4ae25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -381,13 +381,13 @@ dependencies = [ "csv", "dirs", "log", + "rand 0.8.5", "serde", "serde_json", "solana-rpc-client", "solana-sdk 1.15.0", "tokio", "tracing-subscriber", - "uuid", ] [[package]] @@ -5233,15 +5233,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" -[[package]] -name = "uuid" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" -dependencies = [ - "getrandom 0.2.8", -] - [[package]] name = "valuable" version = "0.1.0" diff --git a/bench/Cargo.toml b/bench/Cargo.toml index dd1934af..d5571df2 100644 --- a/bench/Cargo.toml +++ b/bench/Cargo.toml @@ -15,5 +15,5 @@ clap = { version = "4.1.6", features = ["derive"] } tokio = { version = "1.25.0", features = ["full", "fs"]} tracing-subscriber = "0.3.16" dirs = "4.0.0" -uuid = { version = "1.3.0", features = ["v4"] } +rand = "0.8.5" diff --git a/bench/src/helpers.rs b/bench/src/helpers.rs index 575791ce..dcec19dc 100644 --- a/bench/src/helpers.rs +++ b/bench/src/helpers.rs @@ -1,6 +1,7 @@ use std::str::FromStr; use anyhow::Context; +use rand::{distributions::Alphanumeric, prelude::Distribution}; use solana_rpc_client::nonblocking::rpc_client::RpcClient; use solana_sdk::{ commitment_config::CommitmentConfig, @@ -68,9 +69,13 @@ impl BenchHelper { funded_payer: &Keypair, blockhash: Hash, ) -> Vec { + let random_bytes: Vec = Alphanumeric + .sample_iter(rand::thread_rng()) + .take(10) + .collect(); + (0..num_of_txs) - .into_iter() - .map(|_| Self::create_memo_tx(uuid::Uuid::new_v4().as_bytes(), funded_payer, blockhash)) + .map(|_| Self::create_memo_tx(&random_bytes, funded_payer, blockhash)) .collect() }