Skip to content

Commit

Permalink
#716: Renamed test subcommands to be more intuitive
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgeddes committed Dec 11, 2023
1 parent 09bb5ca commit f0e151c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions crates/wasm_cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use clap::{Parser, Subcommand};

use crate::commands::{
assertbalance::AssertBalanceOpts, describe::DescribeOpts, execute::ExecuteOpts,
inittestdb::InitTestDBOpts, test::TestOpts, validate::ValidateOpts,
testbalance::TestBalanceOpts, describe::DescribeOpts, execute::ExecuteOpts,
testinitdb::TestInitDBOpts, testcontract::TestContractOpts, validate::ValidateOpts,
};

#[derive(Parser)]
Expand All @@ -22,9 +22,9 @@ pub enum WasmCommands {
/// Validates a WASM module's ability to execute
Validate(ValidateOpts),
/// Initialise a test database
InitTestDB(InitTestDBOpts),
TestInitDB(TestInitDBOpts),
/// A test to check the balance of a given account
AssertBalance(AssertBalanceOpts),
TestBalance(TestBalanceOpts),
/// A subcommand for executing/testing a smart contract function.
Test(TestOpts),
TestContract(TestContractOpts),
}
6 changes: 3 additions & 3 deletions crates/wasm_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod assertbalance;
pub mod testbalance;
pub mod describe;
pub mod execute;
pub mod inittestdb;
pub mod test;
pub mod testinitdb;
pub mod testcontract;
pub mod validate;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clap::Parser;
use ethereum_types::U256;

#[derive(Parser, Debug)]
pub struct AssertBalanceOpts {
pub struct TestBalanceOpts {
/// This is the path to the database to be created/used. #716, this path is what we'll feed
/// into the database driver.
#[clap(short, long)]
Expand All @@ -18,7 +18,7 @@ pub struct AssertBalanceOpts {

/// Checks the balance of an address matches the value provided and returns Ok/0 to the operating
/// system if it does, otherwise returns Err/1 to the operating system if they don't match.
pub fn run(opts: &AssertBalanceOpts) -> Result<()> {
pub fn run(opts: &TestBalanceOpts) -> Result<()> {
// #716 Here we should do a query for the provided address, and compare its balance with the
// balance provided. If they match, we should return success. If they don't, we should return
// failure. It may even be worth returning a different failure if the account doesn't exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use wasm_runtime::{
use wasmer::{Cranelift, Target};

#[derive(Parser, Debug)]
pub struct TestOpts {
pub struct TestContractOpts {
/// This is the path to the database to be created/used. #716, this path is what we'll feed
/// into the database driver.
#[clap(short, long)]
Expand Down Expand Up @@ -48,7 +48,7 @@ pub struct TestOpts {
/// targeted toward developers of WASM modules. It should attempt to describe
/// how the module might, or might not, be viable as an off-chain smart contract
/// compute job.
pub fn run(opts: &TestOpts) -> Result<()> {
pub fn run(opts: &TestContractOpts) -> Result<()> {
let wasmfile = opts
.wasm
.to_str()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use clap::Parser;

#[derive(Parser, Debug)]
pub struct InitTestDBOpts {
pub struct TestInitDBOpts {
/// This is the path to the database to be created/used. #716, this path is what we'll feed
/// into the database driver.
#[clap(short, long)]
Expand All @@ -22,7 +22,7 @@ pub struct InitTestDBOpts {
/// Initialises a new database for keeping standalone state typically provided by a blockchain.
/// This allows some standalone testing of smart contracts without needing access to a testnet and
/// can also potentially be integrated into common CI/CD frameworks.
pub fn run(opts: &InitTestDBOpts) -> Result<()> {
pub fn run(opts: &TestInitDBOpts) -> Result<()> {
// #716, here we want to create a new database to be used by the rest of the functionality in
// issue #716. This database could be SQLite3 or similar, but with some caveats:
// - The database can be written to a single file
Expand Down
12 changes: 6 additions & 6 deletions crates/wasm_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ fn main() -> Result<()> {
Some(cli::WasmCommands::Validate(opts)) => {
commands::validate::run(opts)?;
}
Some(cli::WasmCommands::InitTestDB(opts)) => {
commands::inittestdb::run(opts)?;
Some(cli::WasmCommands::TestInitDB(opts)) => {
commands::testinitdb::run(opts)?;
}
Some(cli::WasmCommands::AssertBalance(opts)) => {
commands::assertbalance::run(opts)?;
Some(cli::WasmCommands::TestBalance(opts)) => {
commands::testbalance::run(opts)?;
}
Some(cli::WasmCommands::Test(opts)) => {
commands::test::run(opts)?;
Some(cli::WasmCommands::TestContract(opts)) => {
commands::testcontract::run(opts)?;
}
None => {}
}
Expand Down

0 comments on commit f0e151c

Please sign in to comment.