From 4cd3da99b429f66845ac35312e4170bda8b5d1c1 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 12 May 2021 19:37:14 +0300 Subject: [PATCH] core: fix ineffassign warning in test code ineffectual assignment to err (ineffassign) --- pkg/core/blockchain_test.go | 1 + pkg/core/native_designate_test.go | 4 ++-- pkg/core/stateroot_test.go | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/core/blockchain_test.go b/pkg/core/blockchain_test.go index 848c8e54d..3bbf4b043 100644 --- a/pkg/core/blockchain_test.go +++ b/pkg/core/blockchain_test.go @@ -238,6 +238,7 @@ func TestGetBlock(t *testing.T) { t.Run("non-empty block", func(t *testing.T) { tx, err := testchain.NewTransferFromOwner(bc, bc.contracts.NEO.Hash, random.Uint160(), 1, 1, 1000) + require.NoError(t, err) b := bc.newBlock(tx) require.NoError(t, bc.AddHeaders(&b.Header)) diff --git a/pkg/core/native_designate_test.go b/pkg/core/native_designate_test.go index f66d464fc..6f8bacb7f 100644 --- a/pkg/core/native_designate_test.go +++ b/pkg/core/native_designate_test.go @@ -130,10 +130,10 @@ func TestDesignate_DesignateAsRole(t *testing.T) { ic.SpawnVM() ic.VM.LoadScript([]byte{byte(opcode.RET)}) - pubs, index, err := des.GetDesignatedByRole(bc.dao, 0xFF, 255) + _, _, err := des.GetDesignatedByRole(bc.dao, 0xFF, 255) require.True(t, errors.Is(err, native.ErrInvalidRole), "got: %v", err) - pubs, index, err = des.GetDesignatedByRole(bc.dao, noderoles.Oracle, 255) + pubs, index, err := des.GetDesignatedByRole(bc.dao, noderoles.Oracle, 255) require.NoError(t, err) require.Equal(t, 0, len(pubs)) require.Equal(t, uint32(0), index) diff --git a/pkg/core/stateroot_test.go b/pkg/core/stateroot_test.go index fafdc0c82..39df0e959 100644 --- a/pkg/core/stateroot_test.go +++ b/pkg/core/stateroot_test.go @@ -215,6 +215,7 @@ func TestStateRootFull(t *testing.T) { require.Eventually(t, func() bool { return lastHeight.Load() == 2 }, time.Second, time.Millisecond) checkVoteBroadcasted(t, bc, lastValidated.Load().(*payload.Extensible), 2, 1) _, err = persistBlock(bc) + require.NoError(t, err) require.Eventually(t, func() bool { return lastHeight.Load() == 3 }, time.Second, time.Millisecond) checkVoteBroadcasted(t, bc, lastValidated.Load().(*payload.Extensible), 3, 1) @@ -257,6 +258,7 @@ func checkVoteBroadcasted(t *testing.T, bc *Blockchain, p *payload.Extensible, require.Equal(t, int32(valIndex), vote.ValidatorIndex) pubs, _, err := bc.contracts.Designate.GetDesignatedByRole(bc.dao, noderoles.StateValidator, bc.BlockHeight()) + require.NoError(t, err) require.True(t, len(pubs) > int(valIndex)) require.True(t, pubs[valIndex].VerifyHashable(vote.Signature, uint32(netmode.UnitTestNet), r)) }