diff --git a/cli/wallet.go b/cli/wallet.go index 7da0c31b5..752a80bfb 100644 --- a/cli/wallet.go +++ b/cli/wallet.go @@ -413,6 +413,8 @@ var walletSign = &cli.Command{ defer closer() ctx := ReqContext(cctx) + afmt := NewAppFmt(cctx.App) + if !cctx.Args().Present() || cctx.NArg() != 2 { return fmt.Errorf("must specify signing address and message to sign") } @@ -437,7 +439,7 @@ var walletSign = &cli.Command{ sigBytes := append([]byte{byte(sig.Type)}, sig.Data...) - fmt.Println(hex.EncodeToString(sigBytes)) + afmt.Println(hex.EncodeToString(sigBytes)) return nil }, } diff --git a/cli/wallet_test.go b/cli/wallet_test.go index 9fb5ac22c..22b3bc3e4 100644 --- a/cli/wallet_test.go +++ b/cli/wallet_test.go @@ -201,7 +201,7 @@ func TestWalletExport(t *testing.T) { } func TestWalletSign(t *testing.T) { - app, mockApi, _, done := NewMockAppWithFullAPI(t, WithCategory("wallet", walletSign)) + app, mockApi, buffer, done := NewMockAppWithFullAPI(t, WithCategory("wallet", walletSign)) defer done() ctx, cancel := context.WithCancel(context.Background()) @@ -213,13 +213,19 @@ func TestWalletSign(t *testing.T) { msg, err := hex.DecodeString("01") assert.NoError(t, err) - signature := crypto.Signature{} + signature := crypto.Signature{ + Type: crypto.SigTypeSecp256k1, + Data: []byte{0x01}, + } mockApi.EXPECT().WalletSign(ctx, addr, msg).Return(&signature, nil) + sigBytes := append([]byte{byte(signature.Type)}, signature.Data...) + //stm: @CLI_WALLET_SIGN_001 err = app.Run([]string{"wallet", "sign", "f01234", "01"}) assert.NoError(t, err) + assert.Contains(t, buffer.String(), hex.EncodeToString(sigBytes)) } func TestWalletVerify(t *testing.T) {