You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: trace_context_header_data_test.rb
    path of file: ./repos/newrelic-ruby-agent/test/new_relic/agent/distributed_tracing
    
    the code of the file until where you have to start completion: # This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: 
    
          def test_trace_state_trims_if_too_long
            # Create a trace state array with 50 9 byte entries.  When joined
            # with a comma, this would be 499 bytes
            trace_state_array = (0...50).map { "#{random_text(2)}=#{random_text(6)}" }
            header_data = HeaderData.new('traceparent', 'payload', trace_state_array, 499, '')

            # setting the entry size to something > 12 should result in a trimmed trace state
            new_entry = 'a' * 13
            trace_state = header_data.trace_state(new_entry)

            expected_size = 499 - 9 + 13

            assert_equal expected_size, trace_state.bytesize
          end