Skip to content

Commit

Permalink
Merge pull request #166 from zeapoz/test-naming-convention
Browse files Browse the repository at this point in the history
Adhere to new test naming convention
  • Loading branch information
niklaslong committed Sep 21, 2022
2 parents 263c4a0 + 500b960 commit 563cfc4
Show file tree
Hide file tree
Showing 23 changed files with 286 additions and 161 deletions.
3 changes: 2 additions & 1 deletion SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ For load testing, "reasonable load" and "heavy load" will need to be defined.

The tests can be run with `cargo test` once Ziggurat is properly configured and dependencies (node instance to be tested) are satisfied. See the [README](README.md) for details.

Tests are grouped into the following categories: conformance, performance, and resistance. Each test is named after the category it belongs to, in addition to what's being tested. For example, `c001_handshake_when_node_receives_connection` is the first conformance test and tests the handshake behavior on the receiving end. The full naming convention is: `id_part_t(subtest_no)_(message type)_(extra_test_desc)`.

# Types of Tests

## Conformance
Expand Down Expand Up @@ -242,7 +244,6 @@ The test index makes use of symbolic language in describing connection and messa

The node disconnects for trivial (non-fuzz, non-malicious) cases.

- `Ping` timeout.
- `Pong` with wrong nonce.
- `GetData` with mixed types in inventory list.
- `Inv` with mixed types in inventory list.
Expand Down
4 changes: 2 additions & 2 deletions src/tests/conformance/handshake/complete_handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
};

#[tokio::test]
async fn when_node_receives_connection() {
async fn c001_handshake_when_node_receives_connection() {
// ZG-CONFORMANCE-001

// Spin up a node instance.
Expand Down Expand Up @@ -34,7 +34,7 @@ async fn when_node_receives_connection() {
}

#[tokio::test]
async fn when_node_initiates_connection() {
async fn c002_handshake_when_node_initiates_connection() {
// ZG-CONFORMANCE-002

// Create a synthetic node and enable handshaking.
Expand Down
66 changes: 44 additions & 22 deletions src/tests/conformance/handshake/ignore_message_inplace_of_verack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@ mod when_node_receives_connection {
use super::*;

#[tokio::test]
async fn get_addr() {
#[allow(non_snake_case)]
async fn c005_t1_GET_ADDR() {
// zcashd: pass
// zebra: pass
run_test_case(Message::GetAddr).await.unwrap();
}

#[tokio::test]
async fn mempool() {
#[allow(non_snake_case)]
async fn c005_t2_MEMPOOL() {
// zcashd: pass
// zebra: pass
run_test_case(Message::MemPool).await.unwrap();
}

#[tokio::test]
async fn ping() {
#[allow(non_snake_case)]
async fn c005_t3_PING() {
// zcashd: pass
// zebra: pass
run_test_case(Message::Ping(Nonce::default()))
Expand All @@ -45,7 +48,8 @@ mod when_node_receives_connection {
}

#[tokio::test]
async fn pong() {
#[allow(non_snake_case)]
async fn c005_t4_PONG() {
// zcashd: pass
// zebra: pass
run_test_case(Message::Pong(Nonce::default()))
Expand All @@ -54,14 +58,16 @@ mod when_node_receives_connection {
}

#[tokio::test]
async fn addr() {
#[allow(non_snake_case)]
async fn c005_t5_ADDR() {
// zcashd: pass
// zebra: pass
run_test_case(Message::Addr(Addr::empty())).await.unwrap();
}

#[tokio::test]
async fn get_headers() {
#[allow(non_snake_case)]
async fn c005_t6_GET_HEADERS() {
// zcashd: pass
// zebra: pass
let block_hash = Block::testnet_genesis().double_sha256().unwrap();
Expand All @@ -70,7 +76,8 @@ mod when_node_receives_connection {
}

#[tokio::test]
async fn get_blocks() {
#[allow(non_snake_case)]
async fn c005_t7_GET_BLOCKS() {
// zcashd: pass
// zebra: pass
let block_hash = Block::testnet_genesis().double_sha256().unwrap();
Expand All @@ -79,15 +86,17 @@ mod when_node_receives_connection {
}

#[tokio::test]
async fn get_data_block() {
#[allow(non_snake_case)]
async fn c005_t8_GET_DATA_BLOCK() {
// zcashd: pass
// zebra: pass
let block_inv = Inv::new(vec![Block::testnet_genesis().inv_hash()]);
run_test_case(Message::GetData(block_inv)).await.unwrap();
}

#[tokio::test]
async fn get_data_tx() {
#[allow(non_snake_case)]
async fn c005_t9_GET_DATA_TX() {
// zcashd: pass
// zebra: pass
run_test_case(Message::GetData(Inv::new(vec![Block::testnet_genesis()
Expand All @@ -98,15 +107,17 @@ mod when_node_receives_connection {
}

#[tokio::test]
async fn inv() {
#[allow(non_snake_case)]
async fn c005_t10_INV() {
// zcashd: pass
// zebra: pass
let block_inv = Inv::new(vec![Block::testnet_genesis().inv_hash()]);
run_test_case(Message::Inv(block_inv)).await.unwrap();
}

#[tokio::test]
async fn not_found() {
#[allow(non_snake_case)]
async fn c005_t11_NOT_FOUND() {
// zcashd: pass
// zebra: pass
let block_inv = Inv::new(vec![Block::testnet_genesis().inv_hash()]);
Expand Down Expand Up @@ -162,21 +173,24 @@ mod when_node_initiates_connection {
use super::*;

#[tokio::test]
async fn get_addr() {
#[allow(non_snake_case)]
async fn c006_t1_GET_ADDR() {
// zcashd: pass
// zebra: pass
run_test_case(Message::GetAddr).await.unwrap();
}

#[tokio::test]
async fn mempool() {
#[allow(non_snake_case)]
async fn c006_t2_MEMPOOL() {
// zcashd: pass
// zebra: pass
run_test_case(Message::MemPool).await.unwrap();
}

#[tokio::test]
async fn ping() {
#[allow(non_snake_case)]
async fn c006_t3_PING() {
// zcashd: pass
// zebra: pass
run_test_case(Message::Ping(Nonce::default()))
Expand All @@ -185,7 +199,8 @@ mod when_node_initiates_connection {
}

#[tokio::test]
async fn pong() {
#[allow(non_snake_case)]
async fn c006_t4_PONG() {
// zcashd: pass
// zebra: pass
run_test_case(Message::Pong(Nonce::default()))
Expand All @@ -194,14 +209,16 @@ mod when_node_initiates_connection {
}

#[tokio::test]
async fn addr() {
#[allow(non_snake_case)]
async fn c006_t5_ADDR() {
// zcashd: pass
// zebra: pass
run_test_case(Message::Addr(Addr::empty())).await.unwrap();
}

#[tokio::test]
async fn get_headers() {
#[allow(non_snake_case)]
async fn c006_t6_GET_HEADERS() {
// zcashd: pass
// zebra: pass
let block_hash = Block::testnet_genesis().double_sha256().unwrap();
Expand All @@ -210,7 +227,8 @@ mod when_node_initiates_connection {
}

#[tokio::test]
async fn get_blocks() {
#[allow(non_snake_case)]
async fn c006_t7_GET_BLOCKS() {
// zcashd: pass
// zebra: pass
let block_hash = Block::testnet_genesis().double_sha256().unwrap();
Expand All @@ -219,15 +237,17 @@ mod when_node_initiates_connection {
}

#[tokio::test]
async fn get_data_block() {
#[allow(non_snake_case)]
async fn c006_t8_GET_DATA_BLOCK() {
// zcashd: pass
// zebra: pass
let block_inv = Inv::new(vec![Block::testnet_genesis().inv_hash()]);
run_test_case(Message::GetData(block_inv)).await.unwrap();
}

#[tokio::test]
async fn get_data_tx() {
#[allow(non_snake_case)]
async fn c006_t9_GET_DATA_TX() {
// zcashd: pass
// zebra: pass
run_test_case(Message::GetData(Inv::new(vec![Block::testnet_genesis()
Expand All @@ -238,15 +258,17 @@ mod when_node_initiates_connection {
}

#[tokio::test]
async fn inv() {
#[allow(non_snake_case)]
async fn c006_t10_INV() {
// zcashd: pass
// zebra: pass
let block_inv = Inv::new(vec![Block::testnet_genesis().inv_hash()]);
run_test_case(Message::Inv(block_inv)).await.unwrap();
}

#[tokio::test]
async fn not_found() {
#[allow(non_snake_case)]
async fn c006_t11_NOT_FOUND() {
// zcashd: pass
// zebra: pass
let block_inv = Inv::new(vec![Block::testnet_genesis().inv_hash()]);
Expand Down

0 comments on commit 563cfc4

Please sign in to comment.