Skip to content

Commit

Permalink
test sdk.Int & math.Int interoperability
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Jul 19, 2023
1 parent d907444 commit c238b64
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions util/bpmath/bp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
)

Expand All @@ -24,3 +25,24 @@ func TestBPToDec(t *testing.T) {
require.Equal(tc.exp.String(), bp.String(), fmt.Sprint("test-bp ", tc.name))
}
}

// Tests if it works both with sdk.Int and math.Int
func TestInt(t *testing.T) {
t.Parallel()
require := require.New(t)

bp := BP(100)
si := sdk.NewInt(1234)

var sresult sdk.Int = Mul(si, bp)
require.Equal(sresult, sdk.NewInt(12))
var mresult math.Int = Mul(si, bp)
require.Equal(mresult, math.NewInt(12))

// now let's check math.Int
mi := math.NewInt(1234)
sresult = Mul(mi, bp)
require.Equal(sresult, sdk.NewInt(12))
mresult = Mul(mi, bp)
require.Equal(mresult, math.NewInt(12))
}

0 comments on commit c238b64

Please sign in to comment.