From 05e41b77953c5e07bd0505ebab34d4430c1a7844 Mon Sep 17 00:00:00 2001 From: Ruslan Akhtariev Date: Fri, 12 May 2023 13:19:00 +0700 Subject: [PATCH 1/2] mark helper functions --- osmomath/decimal.go | 2 ++ osmomath/int.go | 1 + 2 files changed, 3 insertions(+) diff --git a/osmomath/decimal.go b/osmomath/decimal.go index 03b6fea77bf..351c9addde3 100644 --- a/osmomath/decimal.go +++ b/osmomath/decimal.go @@ -888,12 +888,14 @@ func MaxDec(d1, d2 BigDec) BigDec { // DecEq returns true if two given decimals are equal. // Intended to be used with require/assert: require.True(t, DecEq(...)) func DecEq(t *testing.T, exp, got BigDec) (*testing.T, bool, string, string, string) { + t.Helper() return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() } // DecApproxEq returns true if the differences between two given decimals are smaller than the tolerance range. // Intended to be used with require/assert: require.True(t, DecEq(...)) func DecApproxEq(t *testing.T, d1 BigDec, d2 BigDec, tol BigDec) (*testing.T, bool, string, string, string) { + t.Helper() diff := d1.Sub(d2).Abs() return t, diff.LTE(tol), "expected |d1 - d2| <:\t%v\ngot |d1 - d2| = \t\t%v", tol.String(), diff.String() } diff --git a/osmomath/int.go b/osmomath/int.go index c3ae4ef288e..acf22025079 100644 --- a/osmomath/int.go +++ b/osmomath/int.go @@ -436,5 +436,6 @@ func (i *BigInt) UnmarshalAmino(bz []byte) error { return i.Unmarshal(bz) } // intended to be used with require/assert: require.True(IntEq(...)) func IntEq(t *testing.T, exp, got BigInt) (*testing.T, bool, string, string, string) { + t.Helper() return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() } From cc473895d0d4c7f942678dd54e8aa2c96ee3c787 Mon Sep 17 00:00:00 2001 From: Ruslan Akhtariev Date: Fri, 12 May 2023 23:13:17 +0700 Subject: [PATCH 2/2] disable thelper warnings --- osmomath/decimal.go | 6 ++++-- osmomath/int.go | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/osmomath/decimal.go b/osmomath/decimal.go index 351c9addde3..1b8e21ce001 100644 --- a/osmomath/decimal.go +++ b/osmomath/decimal.go @@ -887,15 +887,17 @@ func MaxDec(d1, d2 BigDec) BigDec { // DecEq returns true if two given decimals are equal. // Intended to be used with require/assert: require.True(t, DecEq(...)) +// +//nolint:thelper func DecEq(t *testing.T, exp, got BigDec) (*testing.T, bool, string, string, string) { - t.Helper() return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() } // DecApproxEq returns true if the differences between two given decimals are smaller than the tolerance range. // Intended to be used with require/assert: require.True(t, DecEq(...)) +// +//nolint:thelper func DecApproxEq(t *testing.T, d1 BigDec, d2 BigDec, tol BigDec) (*testing.T, bool, string, string, string) { - t.Helper() diff := d1.Sub(d2).Abs() return t, diff.LTE(tol), "expected |d1 - d2| <:\t%v\ngot |d1 - d2| = \t\t%v", tol.String(), diff.String() } diff --git a/osmomath/int.go b/osmomath/int.go index acf22025079..6b2fe80025d 100644 --- a/osmomath/int.go +++ b/osmomath/int.go @@ -435,7 +435,8 @@ func (i BigInt) MarshalAmino() ([]byte, error) { return i.Marshal() } func (i *BigInt) UnmarshalAmino(bz []byte) error { return i.Unmarshal(bz) } // intended to be used with require/assert: require.True(IntEq(...)) +// +//nolint:thelper func IntEq(t *testing.T, exp, got BigInt) (*testing.T, bool, string, string, string) { - t.Helper() return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() }