github.com/ava-labs/avalanchego@v1.11.11/vms/platformvm/txs/fee/static_calculator_test.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package fee
     5  
     6  import (
     7  	"encoding/hex"
     8  	"testing"
     9  
    10  	"github.com/stretchr/testify/require"
    11  
    12  	"github.com/ava-labs/avalanchego/vms/platformvm/txs"
    13  )
    14  
    15  func TestStaticCalculator(t *testing.T) {
    16  	calculator := NewStaticCalculator(testStaticConfig)
    17  	for _, test := range txTests {
    18  		t.Run(test.name, func(t *testing.T) {
    19  			require := require.New(t)
    20  
    21  			txBytes, err := hex.DecodeString(test.tx)
    22  			require.NoError(err)
    23  
    24  			tx, err := txs.Parse(txs.Codec, txBytes)
    25  			require.NoError(err)
    26  
    27  			fee, err := calculator.CalculateFee(tx.Unsigned)
    28  			require.Equal(test.expectedStaticFee, fee)
    29  			require.ErrorIs(err, test.expectedStaticFeeErr)
    30  		})
    31  	}
    32  }