Skip to content

Commit

Permalink
separate calculating tax
Browse files Browse the repository at this point in the history
  • Loading branch information
phamminh0811 committed Feb 13, 2024
1 parent 7731974 commit 49949e7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ func (s *IntegrationTestSuite) TestFeeTaxWasm() {
balance1, err := node.QuerySpecificBalance(testAddr, initialization.TerraDenom)
s.Require().NoError(err)
// 400000000 - 100000000 - 100000000 * TaxRate = 300000000 - 10000000 * TaxRate
s.Require().Equal(balance1.Amount, transferAmount.Mul(sdk.NewInt(3)).Sub(initialization.TaxRate.MulInt(transferAmount).TruncateInt()))
taxAmount := initialization.TaxRate.MulInt(transferAmount).TruncateInt()
s.Require().Equal(balance1.Amount, transferAmount.Mul(sdk.NewInt(3)).Sub(taxAmount))

stabilityFee := sdk.NewDecWithPrec(2, 2).MulInt(transferAmount)

Expand All @@ -263,13 +264,15 @@ func (s *IntegrationTestSuite) TestFeeTaxWasm() {
balance2, err := node.QuerySpecificBalance(testAddr, initialization.TerraDenom)
s.Require().NoError(err)
// balance1 - 100000000 - 100000000 * TaxRate
s.Require().Equal(balance2.Amount, balance1.Amount.Sub(transferAmount).Sub(initialization.TaxRate.MulInt(transferAmount).TruncateInt()))
taxAmount = initialization.TaxRate.MulInt(transferAmount).TruncateInt()
s.Require().Equal(balance2.Amount, balance1.Amount.Sub(transferAmount).Sub(taxAmount))

contractAddr := contracts[0]
node.WasmExecute(contractAddr, `{"donate": {}}`, transferCoin.String(), fmt.Sprintf("%duluna", stabilityFee), "test")

balance3, err := node.QuerySpecificBalance(testAddr, initialization.TerraDenom)
s.Require().NoError(err)
// balance2 - 100000000 - 100000000 * TaxRate
s.Require().Equal(balance3.Amount, balance2.Amount.Sub(transferAmount).Sub(initialization.TaxRate.MulInt(transferAmount).TruncateInt()))
taxAmount = initialization.TaxRate.MulInt(transferAmount).TruncateInt()
s.Require().Equal(balance3.Amount, balance2.Amount.Sub(transferAmount).Sub(taxAmount))
}

0 comments on commit 49949e7

Please sign in to comment.