Skip to content

Commit

Permalink
fix: add test for CalcFee
Browse files Browse the repository at this point in the history
  • Loading branch information
ZigBalthazar committed Jul 30, 2023
1 parent 7fde2bd commit 133832b
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,24 +739,23 @@ func TestCalcFee(t *testing.T) {
expectedFee int64
expectedErrCode int
}{
{1,payload.PayloadTypeTransfer, 1, td.state1.params.MinimumFee, errors.ErrInvalidFee},
{1,payload.PayloadTypeWithdraw, 1001, td.state1.params.MinimumFee, errors.ErrInvalidFee},
{1,payload.PayloadTypeBond, 1000, td.state1.params.MinimumFee, errors.ErrNone},
{1, payload.PayloadTypeTransfer, 1, td.state1.params.MinimumFee, errors.ErrInvalidFee},
{1, payload.PayloadTypeWithdraw, 1001, td.state1.params.MinimumFee, errors.ErrInvalidFee},
{1, payload.PayloadTypeBond, 1000, td.state1.params.MinimumFee, errors.ErrNone},

{1 * 1e9,payload.PayloadTypeTransfer, 1, 100000, errors.ErrInvalidFee},
{1 * 1e9,payload.PayloadTypeWithdraw, 100001, 100000, errors.ErrInvalidFee},
{1 * 1e9,payload.PayloadTypeBond, 100000, 100000, errors.ErrNone},
{1 * 1e9, payload.PayloadTypeTransfer, 1, 100000, errors.ErrInvalidFee},
{1 * 1e9, payload.PayloadTypeWithdraw, 100001, 100000, errors.ErrInvalidFee},
{1 * 1e9, payload.PayloadTypeBond, 100000, 100000, errors.ErrNone},

{1 * 1e12,payload.PayloadTypeTransfer, 1, 1000000, errors.ErrInvalidFee},
{1 * 1e12,payload.PayloadTypeWithdraw, 1000001, 1000000, errors.ErrInvalidFee},
{1 * 1e12,payload.PayloadTypeBond, 1000000, 1000000, errors.ErrNone},

{1 * 1e12,payload.PayloadTypeSortition, 0, 0, errors.ErrInvalidFee},
{1 * 1e12,payload.PayloadTypeUnbond, 0, 0, errors.ErrNone},
{1 * 1e12, payload.PayloadTypeTransfer, 1, 1000000, errors.ErrInvalidFee},
{1 * 1e12, payload.PayloadTypeWithdraw, 1000001, 1000000, errors.ErrInvalidFee},
{1 * 1e12, payload.PayloadTypeBond, 1000000, 1000000, errors.ErrNone},

{1 * 1e12, payload.PayloadTypeSortition, 0, 0, errors.ErrInvalidFee},
{1 * 1e12, payload.PayloadTypeUnbond, 0, 0, errors.ErrNone},
}
for _, test := range tests {
fee, err := td.state2.CalculateFee(test.amount,test.pldType)
fee, err := td.state2.CalculateFee(test.amount, test.pldType)
assert.NoError(t, err)
assert.Equal(t, test.expectedFee, fee)

Expand Down

0 comments on commit 133832b

Please sign in to comment.