4141- [ Function ` inner_entry_function_payload ` ] ( #0x1_transaction_context_inner_entry_function_payload )
4242- [ Function ` monotonically_increasing_counter ` ] ( #0x1_transaction_context_monotonically_increasing_counter )
4343- [ Function ` monotonically_increasing_counter_internal ` ] ( #0x1_transaction_context_monotonically_increasing_counter_internal )
44+ - [ Function ` monotonically_increasing_counter_internal_for_test_only ` ] ( #0x1_transaction_context_monotonically_increasing_counter_internal_for_test_only )
4445- [ Specification] ( #@Specification_1 )
4546 - [ Function ` get_txn_hash ` ] ( #@Specification_1_get_txn_hash )
4647 - [ Function ` get_transaction_hash ` ] ( #@Specification_1_get_transaction_hash )
5960 - [ Function ` entry_function_payload_internal ` ] ( #@Specification_1_entry_function_payload_internal )
6061 - [ Function ` multisig_payload_internal ` ] ( #@Specification_1_multisig_payload_internal )
6162 - [ Function ` monotonically_increasing_counter_internal ` ] ( #@Specification_1_monotonically_increasing_counter_internal )
63+ - [ Function ` monotonically_increasing_counter_internal_for_test_only ` ] ( #@Specification_1_monotonically_increasing_counter_internal_for_test_only )
6264
6365
6466<pre ><code ><b >use</b > <a href =" ../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error " >0x1::error</a >;
@@ -997,6 +999,7 @@ Returns a monotonically increasing counter value that combines timestamp, transa
997999session counter, and local counter into a 128-bit value.
9981000Format: <code >< ; reserved_byte (8 bits)> ; || timestamp_us (64 bits) || transaction_index (32 bits) || session_counter (8 bits) || local_counter (16 bits)</code >
9991001The function aborts if the local counter overflows (after 65535 calls in a single session).
1002+ When compiled for testing, this function bypasses feature checks and returns a simplified counter value.
10001003
10011004
10021005<pre ><code ><b >public</b > <b >fun</b > <a href =" transaction_context.md#0x1_transaction_context_monotonically_increasing_counter " >monotonically_increasing_counter</a >(): u128
@@ -1009,10 +1012,12 @@ The function aborts if the local counter overflows (after 65535 calls in a singl
10091012
10101013
10111014<pre ><code ><b >public</b > <b >fun</b > <a href =" transaction_context.md#0x1_transaction_context_monotonically_increasing_counter " >monotonically_increasing_counter</a >(): u128 {
1012- <b >assert</b >!(<a href =" ../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_transaction_context_extension_enabled " >features::transaction_context_extension_enabled</a >(), <a href =" ../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_state " >error::invalid_state</a >(<a href =" transaction_context.md#0x1_transaction_context_ETRANSACTION_CONTEXT_EXTENSION_NOT_ENABLED " >ETRANSACTION_CONTEXT_EXTENSION_NOT_ENABLED</a >));
1013- <b >assert</b >!(<a href =" ../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_is_monotonically_increasing_counter_enabled " >features::is_monotonically_increasing_counter_enabled</a >(), <a href =" ../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_state " >error::invalid_state</a >(<a href =" transaction_context.md#0x1_transaction_context_EMONOTONICALLY_INCREASING_COUNTER_NOT_ENABLED " >EMONOTONICALLY_INCREASING_COUNTER_NOT_ENABLED</a >));
1014- <b >let</b > timestamp_us = <a href =" timestamp.md#0x1_timestamp_now_microseconds " >timestamp::now_microseconds</a >();
1015- <a href =" transaction_context.md#0x1_transaction_context_monotonically_increasing_counter_internal " >monotonically_increasing_counter_internal</a >(timestamp_us)
1015+ <b >if</b > (__COMPILE_FOR_TESTING__) {
1016+ <a href =" transaction_context.md#0x1_transaction_context_monotonically_increasing_counter_internal_for_test_only " >monotonically_increasing_counter_internal_for_test_only</a >()
1017+ } <b >else</b > {
1018+ <b >assert</b >!(<a href =" ../../aptos-stdlib/../move-stdlib/doc/features.md#0x1_features_is_monotonically_increasing_counter_enabled " >features::is_monotonically_increasing_counter_enabled</a >(), <a href =" ../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_state " >error::invalid_state</a >(<a href =" transaction_context.md#0x1_transaction_context_EMONOTONICALLY_INCREASING_COUNTER_NOT_ENABLED " >EMONOTONICALLY_INCREASING_COUNTER_NOT_ENABLED</a >));
1019+ <a href =" transaction_context.md#0x1_transaction_context_monotonically_increasing_counter_internal " >monotonically_increasing_counter_internal</a >(<a href =" timestamp.md#0x1_timestamp_now_microseconds " >timestamp::now_microseconds</a >())
1020+ }
10161021}
10171022</code ></pre >
10181023
@@ -1040,6 +1045,31 @@ The function aborts if the local counter overflows (after 65535 calls in a singl
10401045
10411046
10421047
1048+ </details >
1049+
1050+ <a id =" 0x1_transaction_context_monotonically_increasing_counter_internal_for_test_only " ></a >
1051+
1052+ ## Function ` monotonically_increasing_counter_internal_for_test_only `
1053+
1054+ Test-only version of monotonically_increasing_counter that returns increasing values
1055+ without requiring a user transaction context. This allows unit tests to verify
1056+ the monotonically increasing behavior.
1057+
1058+
1059+ <pre ><code ><b >fun</b > <a href =" transaction_context.md#0x1_transaction_context_monotonically_increasing_counter_internal_for_test_only " >monotonically_increasing_counter_internal_for_test_only</a >(): u128
1060+ </code ></pre >
1061+
1062+
1063+
1064+ <details >
1065+ <summary >Implementation</summary >
1066+
1067+
1068+ <pre ><code ><b >native</b > <b >fun</b > <a href =" transaction_context.md#0x1_transaction_context_monotonically_increasing_counter_internal_for_test_only " >monotonically_increasing_counter_internal_for_test_only</a >(): u128;
1069+ </code ></pre >
1070+
1071+
1072+
10431073</details >
10441074
10451075<a id =" @Specification_1 " ></a >
@@ -1376,6 +1406,22 @@ The function aborts if the local counter overflows (after 65535 calls in a singl
13761406
13771407
13781408
1409+ <pre ><code ><b >pragma</b > opaque;
1410+ </code ></pre >
1411+
1412+
1413+
1414+ <a id =" @Specification_1_monotonically_increasing_counter_internal_for_test_only " ></a >
1415+
1416+ ### Function ` monotonically_increasing_counter_internal_for_test_only `
1417+
1418+
1419+ <pre ><code ><b >fun</b > <a href =" transaction_context.md#0x1_transaction_context_monotonically_increasing_counter_internal_for_test_only " >monotonically_increasing_counter_internal_for_test_only</a >(): u128
1420+ </code ></pre >
1421+
1422+
1423+
1424+
13791425<pre ><code ><b >pragma</b > opaque;
13801426</code ></pre >
13811427
0 commit comments