Time Travel in Bitauth IDE with Scenarios

Testing Bitcoin and Bitcoin Cash authentication templates in Bitauth IDE is now easier with support for custom scenarios.

Testing scripts in Bitauth IDE is now easier with support for custom scenarios.

Scenarios allow you to specify transaction circumstances — like the transaction time, block height, version, inputs, and outputs — or variable values — like private keys or address data. This makes it easier to test complex scripts across each possible code path.

Here you’ll see the scenarios available for a script in one of the example templates, 2-of-2 Recoverable Vault. These scenarios allow you to preview the script’s evaluation both before and after the expected recovery time. Before, spending is prevented by an OP_CHECKLOCKTIMEVERIFY in the locking bytecode. After, the evaluation is allowed to proceed.

Scenarios allow for complete control over the simulated transaction used for script testing — this is particularly useful when developing and reviewing covenant authentication templates. Because covenant schemes must validate other inputs or/and outputs of the transactions in which they’re spent, it’s important that these can be configured for testing.

For example, CashChannels allow users to pre-authorize future payments in any currency without requiring the user to remain online (e.g. for subscription or bill payments). CashChannels work by validating the actual value being “withdrawn” from the channel by the receiver — the receiver is only allowed to withdraw the authorized amount, all additional funds must be returned to the channel in the same transaction (or the transaction will be rejected by the Bitcoin Cash network).

The CashChannels Bitauth template provides several examples of scenarios with customized testing transactions:

  • Before Payment Time — A scenario in which the receiver tries to withdraw from the channel before the authorized time (should fail).
  • Attempt $20 Charge — A scenario in which the receiver tries to withdraw more than the authorized amount (should fail).
  • After Payment Time — A scenario in which the receiver withdraws the correct amount after the authorized time (should succeed).
The scenarios available for testing the Execute Authorization path of the CashChannels Bitauth template.

For further examples, review the remaining scripts, tests, and scenarios which are combined to produce the final CashChannels covenant. You’ll find descriptions in the comments for each.

For more information on Scenarios, please refer to the Bitauth IDE Guide.

For more information or help with Bitauth IDE, please join the community Telegram group. You can also follow Bitauth on Twitter. If you’re interested in contributing, you can find Bitauth IDE on GitHub. Thanks for reading!