forked from envadiv/mainnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testutil.go
27 lines (22 loc) · 907 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.TotalPassage, actual.TotalPassage, "TotalPassage")
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].Passage, actual.Distributions[i].Passage, "Distribution", i)
}
}