github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/assessed_custom_fee_unit_test.go (about)

     1  //go:build all || unit
     2  // +build all unit
     3  
     4  package hedera
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/require"
    10  )
    11  
    12  /*-
    13   *
    14   * Hedera Go SDK
    15   *
    16   * Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
    17   *
    18   * Licensed under the Apache License, Version 2.0 (the "License");
    19   * you may not use this file except in compliance with the License.
    20   * You may obtain a copy of the License at
    21   *
    22   *      http://www.apache.org/licenses/LICENSE-2.0
    23   *
    24   * Unless required by applicable law or agreed to in writing, software
    25   * distributed under the License is distributed on an "AS IS" BASIS,
    26   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    27   * See the License for the specific language governing permissions and
    28   * limitations under the License.
    29   *
    30   */
    31  
    32  // The test checks the conversation methods on the AssessedCustomFee struct. We check wether it is correctly converted to protobuf and back.
    33  func TestUnitassessedCustomFee(t *testing.T) {
    34  	t.Parallel()
    35  	assessedFeeOriginal := _MockAssessedCustomFee()
    36  	assessedFeeBytes := assessedFeeOriginal.ToBytes()
    37  	assessedFeeFromBytes, err := AssessedCustomFeeFromBytes(assessedFeeBytes)
    38  	require.NoError(t, err)
    39  	require.Equal(t, assessedFeeOriginal, assessedFeeFromBytes)
    40  }
    41  
    42  func _MockAssessedCustomFee() AssessedCustomFee {
    43  	accountID, _ := AccountIDFromString("0.0.123-esxsf")
    44  	accountID.checksum = nil
    45  	return AssessedCustomFee{
    46  		Amount:                100,
    47  		TokenID:               nil,
    48  		FeeCollectorAccountId: &accountID,
    49  		PayerAccountIDs:       []*AccountID{},
    50  	}
    51  }