Skip to content

Commit

Permalink
added invalid assertion for zeta amount
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Jan 29, 2024
1 parent 12cb109 commit 27c727a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
50 changes: 36 additions & 14 deletions common/coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,62 @@ package common_test
import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
"github.com/zeta-chain/zetacore/common"
)

func Test_GetAzetaDecFromAmountInZeta(t *testing.T) {
tt := []struct {
name string
zetaAmount string
name string
zetaAmount string
err assert.ErrorAssertionFunc
azetaAmount sdk.Dec
}{
{
name: "valid zeta amount",
zetaAmount: "210000000",
name: "valid zeta amount",
zetaAmount: "210000000",
err: assert.NoError,
azetaAmount: sdk.MustNewDecFromStr("210000000000000000000000000"),
},
{
name: "very high zeta amount",
zetaAmount: "21000000000000000000",
name: "very high zeta amount",
zetaAmount: "21000000000000000000",
err: assert.NoError,
azetaAmount: sdk.MustNewDecFromStr("21000000000000000000000000000000000000"),
},
{
name: "very low zeta amount",
zetaAmount: "1",
name: "very low zeta amount",
zetaAmount: "1",
err: assert.NoError,
azetaAmount: sdk.MustNewDecFromStr("1000000000000000000"),
},
{
name: "zero zeta amount",
zetaAmount: "0",
name: "zero zeta amount",
zetaAmount: "0",
err: assert.NoError,
azetaAmount: sdk.MustNewDecFromStr("0"),
},
{
name: "decimal zeta amount",
zetaAmount: "0.1",
name: "decimal zeta amount",
zetaAmount: "0.1",
err: assert.NoError,
azetaAmount: sdk.MustNewDecFromStr("100000000000000000"),
},
{
name: "invalid zeta amount",
zetaAmount: "%%%%%$#",
err: assert.Error,
azetaAmount: sdk.MustNewDecFromStr("0"),
},
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
_, err := common.GetAzetaDecFromAmountInZeta(tc.zetaAmount)
assert.NoError(t, err)
azeta, err := common.GetAzetaDecFromAmountInZeta(tc.zetaAmount)
tc.err(t, err)
if err == nil {
assert.Equal(t, tc.azetaAmount, azeta)
}
})
}

Expand Down
2 changes: 1 addition & 1 deletion x/emissions/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func BeginBlocker(ctx sdk.Context, keeper keeper.Keeper) {
return
}
if blockRewards.GT(emissonPoolBalance) {
ctx.Logger().Error(fmt.Sprintf("Block rewards %s are greater than emission pool balance %s", blockRewards.String(), emissonPoolBalance.String()))
ctx.Logger().Info(fmt.Sprintf("Block rewards %s are greater than emission pool balance %s", blockRewards.String(), emissonPoolBalance.String()))
return
}
ctx.Logger().Info(fmt.Sprintf("Block Rewards Total:%s Block Height:%d", blockRewards.String(), ctx.BlockHeight()))
Expand Down

0 comments on commit 27c727a

Please sign in to comment.