diff --git a/README.md b/README.md index 4fd9201f..8b0e5219 100644 --- a/README.md +++ b/README.md @@ -38,44 +38,29 @@ Our goal is to provide: Vulcan test example: ```solidity -import { Test, expect, accounts, any, commands, Command, watchers, println } from "vulcan/test.sol"; +import { Test, expect, commands, Command, CommandResult, println } from "vulcan/test.sol"; contract TestSomething is Test { - using accounts for *; - using watchers for *; function testSomething() external { // Format strings with rust-like syntax println("Hello {s}", abi.encode("world!")); // Hello world! - println("Balance: {u:d18}", abi.encode(1e17)); // Balance: 0.1 - - // Create an address from a string, set the ETH balance and impersonate calls - address alice = accounts.create("Alice").setBalance(123).impersonate(); - // Expect style assertions! - expect(true).toBeTrue(); - expect("Hello world!").toContain("Hello"); + // Format numbers as decimals + println("Balance: {u:d18}", abi.encode(1e17)); // Balance: 0.1 // Nice external command API! Command memory ping = commands.create("ping").args(["-c", "1"]); - res = ping.arg("etherscan.io").run(); - res = ping.arg("arbiscan.io").run(); - - // Monitor calls and events! - MyContract mc = new MyContract(); - address(mc).watch().captureReverts(); // Watch calls and record their execution - mc.doSomething(); + CommandResult pingResult = ping.arg("etherscan.io").run(); - expect(address(mc).lastCall()).toHaveRevertedWith("Something went wrong"); + // Rust-like results + Bytes memory pingOutput = pingResult.expect("Ping command failed").stdout; - mc.doSomethingElse(); + println("Ping result: {s}", abi.encode(pingOutput)); - // Check event emissions - expect(address(mc).lastCall()).toHaveEmitted( - "SomeEvent(address,bytes32,uint256)", - [address(1).topic(), any()], // Event topics - abi.encode(123) // Event data - ); + // Expect style assertions! + expect(pingResult.isError()).toBeFalse(); + expect(pingResult.isOk()).toBeTrue(); // And much more! } diff --git a/docs/src/README.md b/docs/src/README.md index e633fba4..0bf06dc4 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -22,50 +22,36 @@ Our goal is to provide: Vulcan test example: ```solidity -import { Test, expect, accounts, any, commands, Command, watchers } from "vulcan/test.sol"; +```solidity +import { Test, expect, commands, Command, CommandResult, println } from "vulcan/test.sol"; contract TestSomething is Test { - using accounts for *; - using watchers for *; function testSomething() external { // Format strings with rust-like syntax println("Hello {s}", abi.encode("world!")); // Hello world! - println("Balance: {u:d18}", abi.encode(1e17)); // Balance: 0.1 - // Create an address from a string, set the ETH balance and impersonate calls - address alice = accounts.create("Alice").setBalance(123).impersonate(); - - // Expect style assertions! - expect(true).toBeTrue(); - expect("Hello world!").toContain("Hello"); + // Format numbers as decimals + println("Balance: {u:d18}", abi.encode(1e17)); // Balance: 0.1 // Nice external command API! Command memory ping = commands.create("ping").args(["-c", "1"]); - res = ping.arg("etherscan.io").run(); - res = ping.arg("arbiscan.io").run(); - - // Monitor calls and events! - MyContract mc = new MyContract(); - address(mc).watch().captureReverts(); // Watch calls and record their execution - mc.doSomething(); + CommandResult pingResult = ping.arg("etherscan.io").run(); - // Check that `doSomething()` reverted - expect(address(mc).lastCall()).toHaveRevertedWith("Something went wrong"); + // Rust-like results + Bytes memory pingOutput = pingResult.expect("Ping command failed").stdout; - mc.doSomethingElse(); + println("Ping result: {s}", abi.encode(pingOutput)); - // Check event emissions - expect(address(mc).lastCall()).toHaveEmitted( - "SomeEvent(address,bytes32,uint256)", - [address(1).topic(), any()], // Event topics - abi.encode(123) // Event data - ); + // Expect style assertions! + expect(pingResult.isError()).toBeFalse(); + expect(pingResult.isOk()).toBeTrue(); // And much more! } } ``` +``` ## Planned Features