forked from regen-network/mainnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testutil.go
27 lines (22 loc) · 897 Bytes
/
testutil.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package main
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
)
func RequireDecEqual(t *testing.T, expected, actual Dec, msgAndArgs ...interface{}) {
if !expected.IsEqual(actual) {
assert.Fail(t, fmt.Sprintf("%s != %s", expected, actual), msgAndArgs...)
t.FailNow()
}
}
func RequireAccountEqual(t *testing.T, expected, actual Account) {
RequireDecEqual(t, expected.TotalRegen, actual.TotalRegen, "TotalRegen")
require.Equal(t, expected.Address, actual.Address, "Address")
require.Equal(t, len(expected.Distributions), len(actual.Distributions), "len(Distributions)")
for i := 0; i < len(expected.Distributions); i++ {
require.Equal(t, expected.Distributions[i].Time, actual.Distributions[i].Time, "Distribution", i)
RequireDecEqual(t, expected.Distributions[i].Regen, actual.Distributions[i].Regen, "Distribution", i)
}
}