Skip to content

Commit

Permalink
test reduce block interval in node
Browse files Browse the repository at this point in the history
  • Loading branch information
tomyrd committed Feb 27, 2025
1 parent 24e01ae commit 6eb757f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- uses: taiki-e/install-action@nextest
- run: make clean-node
- run: make node
- run: make start-node > /dev/null &
- run: RUST_LOG=none make start-node > /dev/null &
- run: make integration-test-full
- name: Kill miden-node
if: always()
Expand All @@ -63,7 +63,7 @@ jobs:
run: . ./scripts/configure-sandbox.sh
- run: make clean-node
- run: make node
- run: make start-node > /dev/null &
- run: RUST_LOG=none make start-node > /dev/null &
- run: make integration-test-web-client
- name: Kill miden-node
if: always()
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ PROVER_BRANCH="next"
PROVER_FEATURES_TESTING=--features "testing"
PROVER_PORT=50051

NODE_PARAM_FILE="crates/block-producer/src/lib.rs"

# --- Linting -------------------------------------------------------------------------------------

.PHONY: clippy
Expand Down Expand Up @@ -113,7 +115,8 @@ setup-miden-node: ## Clone the miden-node repository if it doesn't exist

.PHONY: update-node-branch
update-node-branch: setup-miden-base ## Checkout and update the specified branch in miden-node
cd $(NODE_DIR) && git checkout $(NODE_BRANCH) && git pull origin $(NODE_BRANCH)
cd $(NODE_DIR) && git checkout $(NODE_BRANCH) && git pull origin $(NODE_BRANCH) && sed -i.bak -e 's/const SERVER_BLOCK_FREQUENCY: Duration = Duration::from_secs(5);/const SERVER_BLOCK_FREQUENCY: Duration = Duration::from_millis(500);/' \
-e 's/const SERVER_BUILD_BATCH_FREQUENCY: Duration = Duration::from_secs(2);/const SERVER_BUILD_BATCH_FREQUENCY: Duration = Duration::from_millis(200);/' -- "$(NODE_PARAM_FILE)" && rm -- "$(NODE_PARAM_FILE).bak"

.PHONY: build-node
build-node: update-node-branch ## Update dependencies and build the node binary with specified features
Expand Down
2 changes: 1 addition & 1 deletion crates/web-client/test/mocha.global.setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ before(async () => {
window.helpers.waitForTransaction = async (
transactionId,
maxWaitTime = 20000,
delayInterval = 1000
delayInterval = 100
) => {
const client = window.client;
let timeWaited = 0;
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ pub async fn wait_for_tx(client: &mut TestClient, transaction_id: TransactionId)
break;
}

// 500_000_000 ns = 0.5s
std::thread::sleep(std::time::Duration::new(0, 500_000_000));
// 100_000_000 ns = 0.1s
std::thread::sleep(std::time::Duration::new(0, 100_000_000));
}
if std::env::var("LOG_WAIT_TIMES").unwrap_or_else(|_| "false".to_string()) == "true" {
let elapsed = now.elapsed();
Expand Down Expand Up @@ -271,8 +271,8 @@ pub async fn wait_for_blocks(client: &mut TestClient, amount_of_blocks: u32) ->
return summary;
}

// 500_000_000 ns = 0.5s
std::thread::sleep(std::time::Duration::new(0, 500_000_000));
// 100_000_000 ns = 0.1s
std::thread::sleep(std::time::Duration::new(0, 100_000_000));
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ async fn test_p2idr_transfer_consumed_by_sender() {
println!("Running P2IDR tx...");
let tx_request = TransactionRequestBuilder::pay_to_id(
PaymentTransactionData::new(vec![Asset::Fungible(asset)], from_account_id, to_account_id),
Some(current_block_num + 5),
Some(current_block_num + 50),
NoteType::Private,
client.rng(),
)
Expand Down Expand Up @@ -521,7 +521,7 @@ async fn test_p2idr_transfer_consumed_by_sender() {
println!("Waiting for note to be consumable by sender");
let current_block_num = client.get_sync_height().await.unwrap();

while client.get_sync_height().await.unwrap() < current_block_num + 5 {
while client.get_sync_height().await.unwrap() < current_block_num + 50 {
client.sync_state().await.unwrap();
std::thread::sleep(std::time::Duration::new(0, 100_000_000));
}
Expand Down

0 comments on commit 6eb757f

Please sign in to comment.