forked from RiemaLabs/cdk-validium-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors_test.go
37 lines (26 loc) · 842 Bytes
/
errors_test.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
28
29
30
31
32
33
34
35
36
37
package etherman
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTryParseWithExactMatch(t *testing.T) {
expected := ErrTimestampMustBeInsideRange
smartContractErr := expected
actualErr, ok := tryParseError(smartContractErr)
assert.ErrorIs(t, actualErr, expected)
assert.True(t, ok)
}
func TestTryParseWithContains(t *testing.T) {
expected := ErrTimestampMustBeInsideRange
smartContractErr := fmt.Errorf(" execution reverted: ProofOfEfficiency::sequenceBatches: %s", expected)
actualErr, ok := tryParseError(smartContractErr)
assert.ErrorIs(t, actualErr, expected)
assert.True(t, ok)
}
func TestTryParseWithNonExistingErr(t *testing.T) {
smartContractErr := fmt.Errorf("some non-existing err")
actualErr, ok := tryParseError(smartContractErr)
assert.Nil(t, actualErr)
assert.False(t, ok)
}