You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
758 B

  1. package common
  2. import (
  3. "math/big"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestCalcFeeAmount(t *testing.T) {
  8. v := big.NewInt(1000)
  9. feeAmount := CalcFeeAmount(v, FeeSelector(225)) // 1000%
  10. assert.Equal(t, "10000", feeAmount.String())
  11. feeAmount = CalcFeeAmount(v, FeeSelector(224)) // 100%
  12. assert.Equal(t, "1000", feeAmount.String())
  13. feeAmount = CalcFeeAmount(v, FeeSelector(200)) // 10%
  14. assert.Equal(t, "100", feeAmount.String())
  15. feeAmount = CalcFeeAmount(v, FeeSelector(193)) // 5.11%
  16. assert.Equal(t, "51", feeAmount.String())
  17. feeAmount = CalcFeeAmount(v, FeeSelector(176)) // 1%
  18. assert.Equal(t, "10", feeAmount.String())
  19. feeAmount = CalcFeeAmount(v, FeeSelector(152)) // 0.1%
  20. assert.Equal(t, "1", feeAmount.String())
  21. }