gitlab.com/flarenetwork/coreth@v0.1.1/plugin/evm/tx_test.go (about) 1 // (c) 2019-2020, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package evm 5 6 import ( 7 "math/big" 8 "testing" 9 10 "gitlab.com/flarenetwork/coreth/params" 11 ) 12 13 func TestCalculateDynamicFee(t *testing.T) { 14 type test struct { 15 gas uint64 16 baseFee *big.Int 17 expectedErr error 18 expectedValue uint64 19 } 20 var tests []test = []test{ 21 { 22 gas: 1, 23 baseFee: new(big.Int).Set(x2cRate), 24 expectedValue: 1, 25 }, 26 { 27 gas: 21000, 28 baseFee: big.NewInt(25 * params.GWei), 29 expectedValue: 525000, 30 }, 31 } 32 33 for _, test := range tests { 34 cost, err := calculateDynamicFee(test.gas, test.baseFee) 35 if test.expectedErr == nil { 36 if err != nil { 37 t.Fatalf("Unexpectedly failed to calculate dynamic fee: %s", err) 38 } 39 if cost != test.expectedValue { 40 t.Fatalf("Expected value: %d, found: %d", test.expectedValue, cost) 41 } 42 } else { 43 if err != test.expectedErr { 44 t.Fatalf("Expected error: %s, found error: %s", test.expectedErr, err) 45 } 46 } 47 } 48 }