*: use require.ErrorIs instead of require.True(t, error.Is())
This is just a much better way to do the same thing. Inspired by nspcc-dev/neofs-sdk-go#407. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
8e6025fbc8
commit
433275265f
27 changed files with 109 additions and 133 deletions
|
@ -2,7 +2,6 @@ package core
|
|||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
@ -33,16 +32,16 @@ func TestVerifyHeader(t *testing.T) {
|
|||
h := prev.Hash()
|
||||
h[0] = ^h[0]
|
||||
hdr := newBlock(bc.config.ProtocolConfiguration, 1, h).Header
|
||||
require.True(t, errors.Is(bc.verifyHeader(&hdr, &prev), ErrHdrHashMismatch))
|
||||
require.ErrorIs(t, bc.verifyHeader(&hdr, &prev), ErrHdrHashMismatch)
|
||||
})
|
||||
t.Run("Index", func(t *testing.T) {
|
||||
hdr := newBlock(bc.config.ProtocolConfiguration, 3, prev.Hash()).Header
|
||||
require.True(t, errors.Is(bc.verifyHeader(&hdr, &prev), ErrHdrIndexMismatch))
|
||||
require.ErrorIs(t, bc.verifyHeader(&hdr, &prev), ErrHdrIndexMismatch)
|
||||
})
|
||||
t.Run("Timestamp", func(t *testing.T) {
|
||||
hdr := newBlock(bc.config.ProtocolConfiguration, 1, prev.Hash()).Header
|
||||
hdr.Timestamp = 0
|
||||
require.True(t, errors.Is(bc.verifyHeader(&hdr, &prev), ErrHdrInvalidTimestamp))
|
||||
require.ErrorIs(t, bc.verifyHeader(&hdr, &prev), ErrHdrInvalidTimestamp)
|
||||
})
|
||||
})
|
||||
t.Run("Valid", func(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue