tx
A test transaction builder; i.e. a builder for test transactions that comprise blockchain blocks.
A test transaction consists of a list of test operation calls, and a list of signing keypairs. The test transaction builder type has functions that facilitate straightforward transaction construction by passing operations and keys in various formats.
Since
0.10.4
See also
Constructors
Construct a new test transaction builder consisting of the specified list of test operation calls.
Construct a new test transaction builder consisting of the specified test operation calls.
Construct a new test transaction builder consisting of the specified list of test operation calls.
The test operation calls are given as struct<operation>
values.
For example, calls to the operation:
operation my_op(foo: integer, bar: list<text>) { ... }
may be passed as a struct<my_op>
:
rell.test.tx([
struct<my_op>(foo = 1, bar = ["a", "b"]),
struct<my_op>(foo = 2, bar = ["c", "d"])
]);
Construct a new test transaction builder consisting of the specified test operation calls.
The test operation calls are given as struct<operation>
values.
For example, calls to the operation:
operation my_op(foo: integer, bar: list<text>) { ... }
may be passed as a struct<my_op>
:
rell.test.tx(
struct<my_op>(foo = 1, bar = ["a", "b"]),
struct<my_op>(foo = 2, bar = ["c", "d"])
);
Functions
Copy this transaction builder.
Add a nop test operation call to this transaction builder.
The zero-argument rell.test.tx.nop()
is effectively an alias of rell.test.tx.nop(x: integer)
where a unique integer argument x
is passed each time, serving the purpose of distinguishing transactions that are identical except for the presence of a nop
call.
Example:
Illegal
rell.test.tx().op(my_op).run();
rell.test.tx().op(my_op).run(); // Not allowed; all transactions must be unique!
Legal
// Ok, the transactions are distinct since each nop automatically uses a different nonce.
rell.test.tx().op(my_op).nop().run();
rell.test.tx().op(my_op).nop().run();
Add a nop test operation call to this transaction builder.
Serves the purpose of distinguishing transactions that are identical except for the presence of a nop
call.
my_tx_builder.nop(x)
is equivalent to my_tx_builder.op(rell.test.nop(x))
, where rell.test.nop(x)
is equivalent to rell.test.op('nop', x.to_gtv())
, which is a test operation call to the predefined operation:
operation nop(v: gtv) {}
Example:
Illegal
rell.test.tx().op(my_op).nop(x'00').run();
rell.test.tx().op(my_op).nop(x'00').run(); // Not allowed; all transactions must be unique!
Legal
rell.test.tx().op(my_op).nop(x'00').run();
rell.test.tx().op(my_op).nop(x'01').run(); // Ok, since the transactions are distinct.
Add a nop test operation call to this transaction builder.
Serves the purpose of distinguishing transactions that are identical except for the presence of a nop
call.
my_tx_builder.nop(x)
is equivalent to my_tx_builder.op(rell.test.nop(x))
, where rell.test.nop(x)
is equivalent to rell.test.op('nop', x.to_gtv())
, which is a test operation call to the predefined operation:
operation nop(v: gtv) {}
Example:
Illegal
rell.test.tx().op(my_op).nop(0).run();
rell.test.tx().op(my_op).nop(0).run(); // Not allowed; all transactions must be unique!
Legal
rell.test.tx().op(my_op).nop(0).run();
rell.test.tx().op(my_op).nop(1).run(); // Ok, since the transactions are distinct.
Add a nop test operation call to this transaction builder.
Serves the purpose of distinguishing transactions that are identical except for the presence of a nop
call.
my_tx_builder.nop(x)
is equivalent to my_tx_builder.op(rell.test.nop(x))
, where rell.test.nop(x)
is equivalent to rell.test.op('nop', x.to_gtv())
, which is a test operation call to the predefined operation:
operation nop(v: gtv) {}
Example:
Illegal
rell.test.tx().op(my_op).nop("a").run();
rell.test.tx().op(my_op).nop("a").run(); // Not allowed; all transactions must be unique!
Legal
rell.test.tx().op(my_op).nop("a").run();
rell.test.tx().op(my_op).nop("z").run(); // Ok, since the transactions are distinct.
Add a list of test operation calls to this test transaction builder.
The test operation calls are given as struct<operation>
values.
For example, calls to the operation:
operation my_op(foo: integer, bar: list<text>) { ... }
may be passed as a struct<my_op>
:
my_transaction_builder.op([
struct<my_op>(foo = 1, bar = ["a", "b"]),
struct<my_op>(foo = 2, bar = ["c", "d"])
]);
Add a list of test operation calls to this test transaction builder.
Add the given test operation calls to this test transaction builder.
The test operation calls are given as struct<operation>
values.
For example, calls to the operation:
operation my_op(foo: integer, bar: list<text>) { ... }
may be passed as a struct<my_op>
:
my_transaction_builder.op(
struct<my_op>(foo = 1, bar = ["a", "b"]),
struct<my_op>(foo = 2, bar = ["c", "d"])
);
Add test operation calls to this test transaction builder.
Build a test block containing only this test transaction, asserting that the building fails (i.e. throws an exception).
Typically used to test operation calls that must throw an exception.
Build a test block containing only this test transaction, asserting that the building fails; i.e. throws an exception; with the given exception message.
Checks that the given message is a substring of the thrown message. For example my_tx.run_must_fail('out of bounds')
succeeds if an exception with message Run-time error: List index out of bounds: 0 (size 0)
is thrown.
Typically used to test operation calls that must throw an exception.
Add the given private keys as signers of this test transaction builder.
When this builder is built, the transaction will be signed with all given private keys.
Add the given list of private keys as signers of this test transaction builder.
When this builder is built, the transaction will be signed with all private keys in the list.
Add the given list of keypairs as signers of this test transaction builder.
When this builder is built, the transaction will be signed with all keypairs in the list.
Add the given keypairs as signers of this test transaction builder.
When this builder is built, the transaction will be signed with all given keypairs.