LCOV - code coverage report
Current view: top level - flamenco/runtime/sysvar - fd_sysvar_rent.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 32 0.0 %
Date: 2025-08-05 05:04:49 Functions: 0 3 0.0 %

          Line data    Source code
       1             : #include "fd_sysvar_rent.h"
       2             : #include "fd_sysvar.h"
       3             : #include "../fd_acc_mgr.h"
       4             : #include "../fd_system_ids.h"
       5             : #include "../context/fd_exec_slot_ctx.h"
       6             : 
       7             : #include <assert.h>
       8             : 
       9             : void
      10             : fd_sysvar_rent_write( fd_exec_slot_ctx_t * slot_ctx,
      11           0 :                       fd_rent_t const *    rent ) {
      12             : 
      13           0 :   uchar enc[ 32 ];
      14             : 
      15           0 :   ulong sz = fd_rent_size( rent );
      16           0 :   FD_TEST( sz<=sizeof(enc) );
      17           0 :   memset( enc, 0, sz );
      18             : 
      19           0 :   fd_bincode_encode_ctx_t ctx;
      20           0 :   ctx.data    = enc;
      21           0 :   ctx.dataend = enc + sz;
      22           0 :   if( fd_rent_encode( rent, &ctx ) )
      23           0 :     FD_LOG_ERR(("fd_rent_encode failed"));
      24             : 
      25           0 :   fd_sysvar_account_update( slot_ctx, &fd_sysvar_rent_id, enc, sz );
      26           0 : }
      27             : 
      28             : void
      29           0 : fd_sysvar_rent_init( fd_exec_slot_ctx_t * slot_ctx ) {
      30           0 :   fd_rent_t const * rent = fd_bank_rent_query( slot_ctx->bank );
      31           0 :   fd_sysvar_rent_write( slot_ctx, rent );
      32           0 : }
      33             : 
      34             : fd_rent_t const *
      35             : fd_sysvar_rent_read( fd_funk_t *     funk,
      36             :                      fd_funk_txn_t * funk_txn,
      37           0 :                      fd_spad_t *     spad ) {
      38           0 :   FD_TXN_ACCOUNT_DECL( acc );
      39           0 :   int rc = fd_txn_account_init_from_funk_readonly( acc, &fd_sysvar_rent_id, funk, funk_txn );
      40           0 :   if( FD_UNLIKELY( rc!=FD_ACC_MGR_SUCCESS ) ) {
      41           0 :     return NULL;
      42           0 :   }
      43             : 
      44             :   /* This check is needed as a quirk of the fuzzer. If a sysvar account
      45             :      exists in the accounts database, but doesn't have any lamports,
      46             :      this means that the account does not exist. This wouldn't happen
      47             :      in a real execution environment. */
      48           0 :   if( FD_UNLIKELY( acc->vt->get_lamports( acc )==0 ) ) {
      49           0 :     return NULL;
      50           0 :   }
      51             : 
      52           0 :   int err;
      53           0 :   return fd_bincode_decode_spad(
      54           0 :       rent, spad,
      55           0 :       acc->vt->get_data( acc ),
      56           0 :       acc->vt->get_data_len( acc ),
      57           0 :       &err );
      58           0 : }

Generated by: LCOV version 1.14