LCOV - code coverage report
Current view: top level - flamenco/runtime/tests/harness - fd_txn_harness.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 14 0.0 %
Date: 2025-07-01 05:00:49 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_tests_harness_fd_txn_harness_h
       2             : #define HEADER_fd_src_flamenco_runtime_tests_harness_fd_txn_harness_h
       3             : 
       4             : #include <assert.h>
       5             : 
       6             : #include "../../fd_executor.h"
       7             : #include "../../program/fd_builtin_programs.h"
       8             : #include "../../program/fd_bpf_program_util.h"
       9             : #include "../../sysvar/fd_sysvar_last_restart_slot.h"
      10             : #include "../../sysvar/fd_sysvar_slot_hashes.h"
      11             : #include "../../sysvar/fd_sysvar_recent_hashes.h"
      12             : #include "../../sysvar/fd_sysvar_stake_history.h"
      13             : #include "../../sysvar/fd_sysvar_epoch_rewards.h"
      14             : #include "../../sysvar/fd_sysvar_clock.h"
      15             : #include "../../sysvar/fd_sysvar_epoch_schedule.h"
      16             : #include "../../sysvar/fd_sysvar_rent.h"
      17             : #include "../../../fd_flamenco.h"
      18             : #include "../../../../disco/pack/fd_pack.h"
      19             : 
      20             : #include "fd_harness_common.h"
      21             : #include "generated/txn.pb.h"
      22             : 
      23             : /* Macros to append data to construct a serialized transaction
      24             :    without exceeding bounds */
      25           0 : #define FD_CHECKED_ADD_TO_TXN_DATA( _begin, _cur_data, _to_add, _sz ) __extension__({ \
      26           0 :    if( FD_UNLIKELY( (*_cur_data)+_sz>_begin+FD_TXN_MTU ) ) return ULONG_MAX;          \
      27           0 :    fd_memcpy( *_cur_data, _to_add, _sz );                                             \
      28           0 :    *_cur_data += _sz;                                                                 \
      29           0 : })
      30             : 
      31           0 : #define FD_CHECKED_ADD_CU16_TO_TXN_DATA( _begin, _cur_data, _to_add ) __extension__({ \
      32           0 :    do {                                                                               \
      33           0 :       uchar _buf[3];                                                                  \
      34           0 :       fd_bincode_encode_ctx_t _encode_ctx = { .data = _buf, .dataend = _buf+3 };      \
      35           0 :       fd_bincode_compact_u16_encode( &_to_add, &_encode_ctx );                        \
      36           0 :       ulong _sz = (ulong) ((uchar *)_encode_ctx.data - _buf );                        \
      37           0 :       FD_CHECKED_ADD_TO_TXN_DATA( _begin, _cur_data, _buf, _sz );                     \
      38           0 :    } while(0);                                                                        \
      39           0 : })
      40             : 
      41             : FD_PROTOTYPES_BEGIN
      42             : 
      43             : /* Serializes a Protobuf SanitizedTransaction that can be parsed into a txn descriptor
      44             :    and returns the number of bytes consumed. Returns ULONG_MAX if the number of bytes
      45             :    read exceeds 1232 (FD_TXN_MTU). _txn_raw_begin is assumed to be a pre-allocated
      46             :    buffer of at least 1232 bytes. */
      47             : ulong
      48             : fd_runtime_fuzz_serialize_txn( uchar *                                      txn_raw_begin,
      49             :                                fd_exec_test_sanitized_transaction_t const * tx,
      50             :                                ushort *                                     out_instr_cnt,
      51             :                                ushort *                                     out_addr_table_cnt );
      52             : 
      53             : /*
      54             :    Similar to fd_runtime_fuzz_instr_run, but executes a txn given txn context (input)
      55             : */
      56             : ulong
      57             : fd_runtime_fuzz_txn_run( fd_runtime_fuzz_runner_t * runner,
      58             :                          void const *               input_,
      59             :                          void **                    output_,
      60             :                          void *                     output_buf,
      61             :                          ulong                      output_bufsz );
      62             : 
      63             : FD_PROTOTYPES_END
      64             : 
      65             : #endif /* HEADER_fd_src_flamenco_runtime_tests_harness_fd_txn_harness_h */

Generated by: LCOV version 1.14