Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added single-step-skipping JSON tests #143

Merged
merged 6 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tendermint/src/lite_impl/signed_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ impl lite::Commit for block::signed_header::SignedHeader {
if self.commit.precommits.len() != vals.validators().len() {
return Err(lite::Error::InvalidCommitSignatures);
}
// TODO: https://github.com/interchainio/tendermint-rs/pull/143/commits/0a30022fa47e909e6c7b20417dd178c8a3b84838#r374958528
// if let Some(parts) = &self.commit.block_id.parts {
// if parts.hash != self.header_hash() {
// // TODO(ismail): we need a better error here!
// return Err(lite::Error::InvalidCommit);
// }
// }
liamsi marked this conversation as resolved.
Show resolved Hide resolved
Ok(())
}
}
Expand Down
24 changes: 18 additions & 6 deletions tendermint/tests/lite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ struct Duration(u64);

#[derive(Deserialize, Clone, Debug)]
struct TestCases {
batch_name: String,
test_cases: Vec<TestCase>,
}

#[derive(Deserialize, Clone, Debug)]
struct TestCase {
test_name: String,
description: String,
initial: Initial,
input: Vec<LiteBlock>,
Expand Down Expand Up @@ -44,19 +44,31 @@ fn read_json_fixture(name: &str) -> String {

#[test]
fn val_set_tests_verify() {
let cases: TestCases = serde_json::from_str(&read_json_fixture("val_set_tests")).unwrap();
let cases: TestCases = serde_json::from_str(&read_json_fixture("single_step_sequential/val_set_tests")).unwrap();
run_test_cases(cases);
}

#[test]
fn commit_tests_verify() {
let cases: TestCases = serde_json::from_str(&read_json_fixture("commit_tests")).unwrap();
let cases: TestCases = serde_json::from_str(&read_json_fixture("single_step_sequential/commit_tests")).unwrap();
run_test_cases(cases);
}

#[test]
fn header_tests_verify() {
let cases: TestCases = serde_json::from_str(&read_json_fixture("header_tests")).unwrap();
let cases: TestCases = serde_json::from_str(&read_json_fixture("single_step_sequential/header_tests")).unwrap();
run_test_cases(cases);
}

#[test]
fn single_skip_val_set_tests_verify() {
let cases: TestCases = serde_json::from_str(&read_json_fixture("single_step_skipping/val_set_tests")).unwrap();
run_test_cases(cases);
}

#[test]
fn single_skip_commit_tests_verify() {
let cases: TestCases = serde_json::from_str(&read_json_fixture("single_step_skipping/commit_tests")).unwrap();
run_test_cases(cases);
}

Expand All @@ -76,8 +88,8 @@ fn run_test_cases(cases: TestCases) {
let tm_now = tc.initial.now;
let now = tm_now.to_system_time().unwrap();

for (_, input) in tc.input.iter().enumerate() {
println!("{}", tc.description);
for (i, input) in tc.input.iter().enumerate() {
println!("i: {}, {}", i, tc.description);
let untrusted_signed_header = &input.signed_header;
let untrusted_vals = &input.validator_set;
let untrusted_next_vals = &input.next_validator_set;
Expand Down
Loading