[#1535] morph: Unify test invoke error messages

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-12-04 11:17:13 +03:00 committed by Evgenii Stratonikov
parent e37dcdf88b
commit e3487d5af5
12 changed files with 20 additions and 18 deletions

View file

@ -23,7 +23,7 @@ func (c *Client) BalanceOf(id user.ID) (*big.Int, error) {
prms, err := c.client.TestInvoke(invokePrm)
if err != nil {
return nil, fmt.Errorf("could not perform test invocation (%s): %w", balanceOfMethod, err)
return nil, fmt.Errorf("test invoke (%s): %w", balanceOfMethod, err)
} else if ln := len(prms); ln != 1 {
return nil, fmt.Errorf("unexpected stack item count (%s): %d", balanceOfMethod, ln)
}

View file

@ -14,7 +14,7 @@ func (c *Client) Decimals() (uint32, error) {
prms, err := c.client.TestInvoke(invokePrm)
if err != nil {
return 0, fmt.Errorf("could not perform test invocation (%s): %w", decimalsMethod, err)
return 0, fmt.Errorf("test invoke (%s): %w", decimalsMethod, err)
} else if ln := len(prms); ln != 1 {
return 0, fmt.Errorf("unexpected stack item count (%s): %d", decimalsMethod, ln)
}

View file

@ -39,7 +39,7 @@ func (c *Client) DeletionInfo(cid []byte) (*containercore.DelInfo, error) {
if strings.Contains(err.Error(), containerContract.NotFoundError) {
return nil, new(apistatus.ContainerNotFound)
}
return nil, fmt.Errorf("could not perform test invocation (%s): %w", deletionInfoMethod, err)
return nil, fmt.Errorf("test invoke (%s): %w", deletionInfoMethod, err)
} else if ln := len(res); ln != 1 {
return nil, fmt.Errorf("unexpected stack item count (%s): %d", deletionInfoMethod, ln)
}

View file

@ -53,7 +53,7 @@ func (c *Client) Get(cid []byte) (*containercore.Container, error) {
if strings.Contains(err.Error(), containerContract.NotFoundError) {
return nil, new(apistatus.ContainerNotFound)
}
return nil, fmt.Errorf("could not perform test invocation (%s): %w", getMethod, err)
return nil, fmt.Errorf("test invoke (%s): %w", getMethod, err)
} else if ln := len(res); ln != 1 {
return nil, fmt.Errorf("unexpected stack item count (%s): %d", getMethod, ln)
}

View file

@ -27,7 +27,7 @@ func (c *Client) list(idUser *user.ID) ([]cid.ID, error) {
res, err := c.client.TestInvoke(prm)
if err != nil {
return nil, fmt.Errorf("could not perform test invocation (%s): %w", listMethod, err)
return nil, fmt.Errorf("test invoke (%s): %w", listMethod, err)
} else if ln := len(res); ln != 1 {
return nil, fmt.Errorf("unexpected stack item count (%s): %d", listMethod, ln)
}

View file

@ -21,7 +21,7 @@ func (c *Client) GetSubject(addr util.Uint160) (*frostfsidclient.Subject, error)
res, err := c.client.TestInvoke(prm)
if err != nil {
return nil, fmt.Errorf("could not perform test invocation (%s): %w", methodGetSubject, err)
return nil, fmt.Errorf("test invoke (%s): %w", methodGetSubject, err)
}
structArr, err := checkStackItem(res)
@ -44,7 +44,7 @@ func (c *Client) GetSubjectExtended(addr util.Uint160) (*frostfsidclient.Subject
res, err := c.client.TestInvoke(prm)
if err != nil {
return nil, fmt.Errorf("could not perform test invocation (%s): %w", methodGetSubjectExtended, err)
return nil, fmt.Errorf("test invoke (%s): %w", methodGetSubjectExtended, err)
}
structArr, err := checkStackItem(res)

View file

@ -206,7 +206,7 @@ func (c *Client) ReadNetworkConfiguration() (NetworkConfiguration, error) {
items, err := c.client.TestInvoke(prm)
if err != nil {
return res, fmt.Errorf("could not perform test invocation (%s): %w",
return res, fmt.Errorf("test invoke (%s): %w",
configListMethod, err)
}
@ -292,7 +292,7 @@ func (c *Client) config(key []byte, assert func(stackitem.Item) (any, error)) (a
items, err := c.client.TestInvoke(prm)
if err != nil {
return nil, fmt.Errorf("could not perform test invocation (%s): %w",
return nil, fmt.Errorf("test invoke (%s): %w",
configMethod, err)
}

View file

@ -14,7 +14,7 @@ func (c *Client) Epoch() (uint64, error) {
items, err := c.client.TestInvoke(prm)
if err != nil {
return 0, fmt.Errorf("could not perform test invocation (%s): %w",
return 0, fmt.Errorf("test invoke (%s): %w",
epochMethod, err)
}
@ -38,7 +38,7 @@ func (c *Client) LastEpochBlock() (uint32, error) {
items, err := c.client.TestInvoke(prm)
if err != nil {
return 0, fmt.Errorf("could not perform test invocation (%s): %w",
return 0, fmt.Errorf("test invoke (%s): %w",
lastEpochBlockMethod, err)
}

View file

@ -46,7 +46,7 @@ func (c *Client) GetInnerRingList() (keys.PublicKeys, error) {
prms, err := c.client.TestInvoke(invokePrm)
if err != nil {
return nil, fmt.Errorf("could not perform test invocation (%s): %w", innerRingListMethod, err)
return nil, fmt.Errorf("test invoke (%s): %w", innerRingListMethod, err)
}
return irKeysFromStackItem(prms, innerRingListMethod)

View file

@ -18,7 +18,7 @@ func (c *Client) GetNetMapByEpoch(epoch uint64) (*netmap.NetMap, error) {
res, err := c.client.TestInvoke(invokePrm)
if err != nil {
return nil, fmt.Errorf("could not perform test invocation (%s): %w",
return nil, fmt.Errorf("test invoke (%s): %w",
epochSnapshotMethod, err)
}
@ -40,7 +40,7 @@ func (c *Client) GetCandidates() ([]netmap.NodeInfo, error) {
res, err := c.client.TestInvoke(invokePrm)
if err != nil {
return nil, fmt.Errorf("could not perform test invocation (%s): %w", netMapCandidatesMethod, err)
return nil, fmt.Errorf("test invoke (%s): %w", netMapCandidatesMethod, err)
}
if len(res) > 0 {
@ -57,7 +57,7 @@ func (c *Client) NetMap() (*netmap.NetMap, error) {
res, err := c.client.TestInvoke(invokePrm)
if err != nil {
return nil, fmt.Errorf("could not perform test invocation (%s): %w",
return nil, fmt.Errorf("test invoke (%s): %w",
netMapMethod, err)
}

View file

@ -1,6 +1,8 @@
package netmap
import (
"fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
)
@ -13,7 +15,7 @@ func (c *Client) GetNetMap(diff uint64) (*netmap.NetMap, error) {
res, err := c.client.TestInvoke(prm)
if err != nil {
return nil, err
return nil, fmt.Errorf("test invoke (%s): %w", snapshotMethod, err)
}
return DecodeNetMap(res)

View file

@ -239,7 +239,7 @@ func (c *Client) GetNotaryDeposit() (res int64, err error) {
items, err := c.TestInvoke(c.notary.notary, notaryBalanceOfMethod, sh)
if err != nil {
return 0, fmt.Errorf("%v: %w", notaryBalanceErrMsg, err)
return 0, fmt.Errorf("test invoke (%s): %w", notaryBalanceOfMethod, err)
}
if len(items) != 1 {
@ -654,7 +654,7 @@ func (c *Client) notaryTxValidationLimit() (uint32, error) {
func (c *Client) depositExpirationOf() (int64, error) {
expirationRes, err := c.TestInvoke(c.notary.notary, notaryExpirationOfMethod, c.acc.PrivateKey().GetScriptHash())
if err != nil {
return 0, fmt.Errorf("can't invoke method: %w", err)
return 0, fmt.Errorf("test invoke (%s): %w", notaryExpirationOfMethod, err)
}
if len(expirationRes) != 1 {