Skip to main content

rell.test.tx

rell.test.tx type provides methods for creating and executing test transactions within the Rell testing framework.

Constructors

rell.test.tx()

Creates an empty transaction builder.

Parameters:

  • None

Returns:

  • An empty transaction builder object.

rell.test.tx(op: rell.test.op...): rell.test.tx

Creates a transaction builder with the specified operations.

Parameters:

  • op: rell.test.op - One or more test operations to include in the transaction.

Returns:

  • A transaction builder object containing the specified operations.

rell.test.tx(ops: list<rell.test.op>): rell.test.tx

Creates a transaction builder with the specified list of operations.

Parameters:

  • ops: list<rell.test.op> - A list of test operations to include in the transaction.

Returns:

  • A transaction builder object containing the specified list of operations.

Functions

function op(op: rell.test.op...): rell.test.tx

Adds the specified operations to this transaction builder.

Parameters:

  • op: rell.test.op - One or more test operations to add to the transaction.

Returns:

  • The transaction builder object (allowing for method chaining).

function op(ops: list<rell.test.op>): rell.test.tx

Adds the specified list of operations to this transaction builder.

Parameters:

  • ops: list<rell.test.op> - A list of test operations to add to the transaction.

Returns:

  • The transaction builder object (allowing for method chaining).

function nop(): rell.test.tx

Adds a no-operation (NOP) to the transaction. Equivalent to .op(rell.test.nop()).

Parameters:

  • None

Returns:

  • The transaction builder object (adding a NOP).

function nop(x: integer): rell.test.tx

Adds a NOP with the specified payload to the transaction. Equivalent to .op(rell.test.nop(x)).

Parameters:

  • The payload for the NOP.

Returns:

  • The transaction builder object (adding a NOP with payload).

function nop(x: text): rell.test.tx

Adds a NOP with the specified payload to the transaction. Equivalent to .op(rell.test.nop(x)).

Parameters:

  • The payload for the NOP.

Returns:

  • The transaction builder object (adding a NOP with payload).

function nop(x: byte_array): rell.test.tx

Adds a NOP with the specified payload to the transaction. Equivalent to .op(rell.test.nop(x)).

Parameters:

  • The payload for the NOP.

Returns:

  • The transaction builder object (adding a NOP with payload).

function sign(keypair: rell.test.keypair...): rell.test.tx

Adds signer keypairs to the transaction.

Parameters:

  • keypair: rell.test.keypair - One or more keypairs to add as signers.

Returns:

  • The transaction builder object (allowing for method chaining).

function sign(keypairs: list<rell.test.keypair>): rell.test.tx

Adds the specified list of keypairs as signers to the transaction.

Parameters:

  • keypairs: list<rell.test.keypair> - A list of keypairs to add as signers.

Returns:

  • The transaction builder object (allowing for method chaining).

function sign(privkey: byte_array...): rell.test.tx

Adds signer private keys to the transaction.

Parameters:

  • privkey: byte_array - One or more private keys to add as signers.

Returns:

  • The transaction builder object (allowing for method chaining).

function sign(privkeys: list<byte_array>): rell.test.tx

Adds the specified list of private keys as signers to the transaction.

Parameters:

  • privkeys: list<byte_array> - A list of private keys to add as signers.

Returns:

  • The transaction builder object (allowing for method chaining).

function copy(): rell.test.tx

Returns a copy of this transaction builder object.

Parameters:

  • None

Returns:

  • A copy of the transaction builder object.

function run(): void

Runs a block containing this single transaction.

Parameters:

  • None

Returns:

  • Nothing.

function run_must_fail(expected: text? = null): rell.test.failure

Runs a block containing this transaction and expects it to fail. If an expected message is passed, it will pass only if the failure message contains the expected message. Throws an exception on success, not on failure.

Parameters:

  • expected (optional): Text indicating the expected error message.

Returns:

  • A rell.test.failure object if the transaction fails as expected. Throws an exception if the transaction succeeds unexpectedly.

Example

operation will_fail_sometimes(will_fail: booelan) {
require(!will_fail, "This operation has failed");
}

function test_fails() {
val tx = rell.test.tx().op(will_fail_sometimes(true));
tx.run_must_fail();
tx.run_must_fail("has failed");
}