Skip to content

Commit

Permalink
Merge branch 'main' into keyao/test-public-mempool
Browse files Browse the repository at this point in the history
  • Loading branch information
shenkeyao committed Oct 1, 2024
2 parents 31d78cf + c2b96e9 commit 1255ef9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 85 deletions.
54 changes: 0 additions & 54 deletions .github/workflows/test-demo-native-marketplace.yml

This file was deleted.

30 changes: 12 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
with:
version: nightly

- name: Install Nix
uses: cachix/install-nix-action@V27

- uses: taiki-e/install-action@nextest

- name: Checkout Repository
Expand All @@ -45,37 +48,31 @@ jobs:
- name: Enable Rust Caching
uses: Swatinem/rust-cache@v2

- name: Configure Environment
run: |
RUSTFLAGS="$RUSTFLAGS --cfg hotshot_example"
PATH="$PWD/target/release:$PATH"
- name: Build
# Build test binary with `testing` feature, which requires `hotshot_example` config
run: |
export RUSTFLAGS="$RUSTFLAGS --cfg hotshot_example"
export PATH="$PWD/target/release:$PATH"
cargo build --locked --release
cargo nextest run --locked --release --workspace --all-features --no-run
timeout-minutes: 90

- name: Test
# Build test binary with `testing` feature, which requires `hotshot_example` config
run: |
export RUSTFLAGS="$RUSTFLAGS --cfg hotshot_example"
export PATH="$PWD/target/release:$PATH"
cargo nextest run --locked --release --workspace --all-features --verbose --no-fail-fast
run: cargo nextest run --locked --release --workspace --all-features --verbose --no-fail-fast
timeout-minutes: 5

- name: Install Nix
uses: cachix/install-nix-action@V27

- name: Install process-compose
run: nix profile install nixpkgs#process-compose

- name: Pull Docker Images
run: docker compose pull || docker-compose pull

- name: Run Demo-Native
run: |
export RUSTFLAGS="$RUSTFLAGS --cfg hotshot_example"
export PATH="$PWD/target/release:$PATH"
bash -x scripts/demo-native -D
run: bash -x scripts/demo-native -D

- name: Test Integration
env:
Expand All @@ -87,11 +84,8 @@ jobs:
run: process-compose down

- name: Run Demo-Native Marketplace
run: |
export RUSTFLAGS="$RUSTFLAGS --cfg hotshot_example"
export PATH="$PWD/target/release:$PATH"
bash -x scripts/demo-native -f process-compose.yaml -f process-compose-mp.yml -D
run: bash -x scripts/demo-native -f process-compose.yaml -f process-compose-mp.yml -D

- name: Test Marketplace Integration
env:
NEXTEST_PROFILE: integration
Expand Down
34 changes: 21 additions & 13 deletions tests/demo_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ struct TestConfig {

#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
struct TestState {
block_height: Option<u64>,
txn_count: u64,
builder_balance: FeeAmount,
recipient_balance: FeeAmount,
light_client_update: u64,
pub block_height: Option<u64>,
pub txn_count: u64,
pub builder_balance: FeeAmount,
pub recipient_balance: FeeAmount,
pub light_client_update: u64,
}

impl fmt::Display for TestState {
Expand Down Expand Up @@ -213,18 +213,16 @@ async fn test_smoke() -> Result<()> {
let testing = TestConfig::new().await.unwrap();
let _ = testing.readiness().await?;

let initial = testing.test_state().await;
let mut initial = testing.test_state().await;
let initial_block_height = initial.block_height.unwrap();
println!("Initial State:{}", initial);

let mut i = 1;
loop {
sleep(Duration::from_secs(1)).await;

let new = testing.test_state().await;

println!("New State:{}", new);
if new <= initial {
panic!("Chain state not incrementing");
}

if initial.builder_balance + initial.recipient_balance
!= new.builder_balance + new.recipient_balance
Expand All @@ -238,12 +236,22 @@ async fn test_smoke() -> Result<()> {
}

// test that we progress EXPECTED_BLOCK_HEIGHT blocks from where we started
if new.block_height.unwrap()
>= testing.expected_block_height() + initial.block_height.unwrap()
{
if new.block_height.unwrap() >= testing.expected_block_height() + initial_block_height {
println!("Reached {} block(s)!", testing.expected_block_height());
break;
}

if i % 5 == 0 {
if new <= initial {
panic!("Chain state not incrementing");
}

if new.txn_count <= initial.txn_count {
panic!("Transactions not incrementing");
}
initial = new;
}
i += 1;
}
Ok(())
}

0 comments on commit 1255ef9

Please sign in to comment.