Skip to content

Commit

Permalink
testgen: restore some uses of Tendermint
Browse files Browse the repository at this point in the history
Revert to Tendermint naming where it refers to the algorithm, specs,
or protocol-based data structures.
  • Loading branch information
mzabaluev committed Dec 15, 2023
1 parent 09b8c0e commit fb7a553
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
6 changes: 3 additions & 3 deletions testgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Apache 2.0 Licensed][license-image]][license-link]
![Rust Stable][rustc-image]

`cometbft-testgen` is a small utility for producing CometBFT data
`cometbft-testgen` is a small utility for producing Tendermint data
structures from minimal input (for testing purposes only).

## Requirements
Expand All @@ -23,8 +23,8 @@ cargo run -- --help
cargo run -- --help CMD
```

As an example, a CometBFT validator can be produced only from an identifier,
or a CometBFT header only from a set of validators.
As an example, a Tendermint validator can be produced only from an identifier,
or a Tendermint header only from a set of validators.

The parameters can be supplied in two ways:
- via STDIN: in that case they are expected to be a valid JSON object,
Expand Down
8 changes: 4 additions & 4 deletions testgen/bin/cometbft-testgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use gumdrop::Options;
use simple_error::SimpleError;

const USAGE: &str = r#"
This is a small utility for producing cometbft datastructures
This is a small utility for producing Tendermint datastructures
from minimal input (for testing purposes only).
For example, a cometbft validator can be produced only from an identifier,
or a cometbft header only from a set of validators.
For example, a Tendermint validator can be produced only from an identifier,
or a Tendermint header only from a set of validators.
To get an idea which input is needed for each datastructure, try '--help CMD':
it will list the required and optional parameters.
Expand Down Expand Up @@ -113,7 +113,7 @@ fn main() {
}
match opts.command {
None => {
eprintln!("Produce CometBFT datastructures for testing from minimal input\n");
eprintln!("Produce Tendermint datastructures for testing from minimal input\n");
eprintln!("Please specify a command:");
eprintln!("{}\n", CliOptions::command_list().unwrap());
eprintln!("{}\n", CliOptions::usage());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "Transformers for Apalache counterexamples (CEs) with CometBFT blockchains",
"description": "Transformers for Apalache counterexamples (CEs) with Tendermint blockchains",
"use": [
"cometbft.json"
"tendermint.json"
],
"input": [
{
Expand Down Expand Up @@ -101,13 +101,13 @@
},
{
"name": "ids_to_validators",
"description": "transform a non-empty array of identifiers into CometBFT validators",
"description": "transform a non-empty array of identifiers into Tendermint validators",
"kind": "INLINE",
"source": "$ | map(id_to_validator) | map(cometbft_validator)"
"source": "$ | map(id_to_validator) | map(tendermint_validator)"
},
{
"name": "ids_to_testgen_validators",
"description": "transform a non-empty array of identifiers into `CometBFT-testgen validators`",
"description": "transform a non-empty array of identifiers into `cometbft-testgen validators`",
"kind": "INLINE",
"source": "$ | map(id_to_validator)"
},
Expand All @@ -121,7 +121,7 @@
"name": "first_validator",
"description": "extract first validator from a non-empty array of identifiers",
"kind": "INLINE",
"source": "$[0] | unwrap | id_to_validator | cometbft_validator"
"source": "$[0] | unwrap | id_to_validator | tendermint_validator"
},
{
"name": "const_id",
Expand All @@ -133,11 +133,11 @@
"name": "fixed_validator",
"description": "extract first validator from a non-empty array of identifiers",
"kind": "INLINE",
"source": "$const_id | id_to_validator | cometbft_validator"
"source": "$const_id | id_to_validator | tendermint_validator"
},
{
"name": "ids_to_validator_set",
"description": "transform an array of identifiers into a JSON-encoded CometBFT validator set",
"description": "transform an array of identifiers into a JSON-encoded Tendermint validator set",
"kind": "INLINE",
"source": {
"validators": "$ | ifelse(ids_to_validators,empty_array)",
Expand All @@ -147,11 +147,11 @@
},
{
"name": "block_to_signed_header",
"description": "transform a block from Apalache CE into a JSON-encoded CometBFT signed header",
"description": "transform a block from Apalache CE into a JSON-encoded Tendermint signed header",
"kind": "INLINE",
"source": {
"header": "$ | block_to_header | cometbft_header",
"commit": "$ | block_to_commit | cometbft_commit"
"header": "$ | block_to_header | tendermint_header",
"commit": "$ | block_to_commit | tendermint_commit"
}
}
]
Expand Down
10 changes: 5 additions & 5 deletions testgen/jsonatr-lib/apalache_to_lite_test.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"description": "Transform an Apalache counterexample into a CometBFT LightClient test",
"description": "Transform an Apalache counterexample into a Tendermint LightClient test",
"use": [
"unix.json",
"apalache-cometbft.json"
"apalache-tendermint.json"
],
"input": [
{
"name": "block_to_initial_block",
"description": "transforms a block from Apalache CE into a JSON-encoded CometBFT initial light block",
"description": "transforms a block from Apalache CE into a JSON-encoded Tendermint initial light block",
"kind": "INLINE",
"source": {
"signed_header": "$ | block_to_signed_header",
Expand All @@ -18,7 +18,7 @@
},
{
"name": "state_to_lite_block_verdict",
"description": "transforms a block from Apalache CE into a JSON-encoded CometBFT light block",
"description": "transforms a block from Apalache CE into a JSON-encoded Tendermint light block",
"kind": "INLINE",
"let": {
"block": "$..[?(@.key.str == 'current')].value"
Expand All @@ -35,7 +35,7 @@
"validators": "$block | block_validators | ids_to_testgen_validators",
"next_validators": "$block | block_next_validators | ids_to_testgen_validators"
},
"now": "$..[?(@.key.str == 'now')].value | unwrap | cometbft_time",
"now": "$..[?(@.key.str == 'now')].value | unwrap | tendermint_time",
"verdict": "$..[?(@.key.str == 'verdict')].value.str | unwrap"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"description": "Transformers for generating CometBFT datastructures",
"description": "Transformers for generating Tendermint datastructures",
"prerequisites": "add cometbft-testgen to your $PATH",
"input": [
{
"name": "cometbft_validator",
"name": "tendermint_validator",
"kind": "COMMAND",
"source": "cometbft-testgen --stdin validator"
},
{
"name": "cometbft_header",
"name": "tendermint_header",
"kind": "COMMAND",
"source": "cometbft-testgen --stdin header"
},
{
"name": "cometbft_commit",
"name": "tendermint_commit",
"kind": "COMMAND",
"source": "cometbft-testgen --stdin commit"
},
{
"name": "cometbft_vote",
"name": "tendermint_vote",
"kind": "COMMAND",
"source": "cometbft-testgen --stdin vote"
},
{
"name": "cometbft_time",
"name": "tendermint_time",
"kind": "COMMAND",
"source": "cometbft-testgen --stdin time"
}
Expand Down
4 changes: 2 additions & 2 deletions testgen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `cometbft-testgen` is a small utility for producing CometBFT data
//! `cometbft-testgen` is a small utility for producing Tendermint data
//! structures from minimal input (for testing purposes only).
//!
//! See the [repository] for details.
Expand All @@ -8,7 +8,7 @@
#[macro_use]
pub mod helpers;

/// Helper types for generating CometBFT datastructures
/// Helper types for generating Tendermint datastructures
pub mod commit;
pub mod consensus;
pub mod generator;
Expand Down
2 changes: 1 addition & 1 deletion testgen/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub fn generate_validators(vals: &[Validator]) -> Result<Vec<validator::Info>, S
.collect::<Result<Vec<validator::Info>, SimpleError>>()
}

/// A helper function to sort validators according to the CometBFT specs.
/// A helper function to sort validators according to the Tendermint specs.
pub fn sort_validators(vals: &[Validator]) -> Vec<Validator> {
let mut sorted = vals.to_owned();
sorted.sort_by_key(|v| {
Expand Down

0 comments on commit fb7a553

Please sign in to comment.