You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

733 lines
18 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
7 years ago
7 years ago
9 years ago
9 years ago
7 years ago
7 years ago
7 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. package main
  2. import (
  3. "bufio"
  4. "encoding/hex"
  5. "errors"
  6. "fmt"
  7. "io"
  8. "os"
  9. "strings"
  10. "github.com/spf13/cobra"
  11. cmn "github.com/tendermint/tendermint/libs/common"
  12. "github.com/tendermint/tendermint/libs/log"
  13. abcicli "github.com/tendermint/tendermint/abci/client"
  14. "github.com/tendermint/tendermint/abci/example/code"
  15. "github.com/tendermint/tendermint/abci/example/counter"
  16. "github.com/tendermint/tendermint/abci/example/kvstore"
  17. "github.com/tendermint/tendermint/abci/server"
  18. servertest "github.com/tendermint/tendermint/abci/tests/server"
  19. "github.com/tendermint/tendermint/abci/types"
  20. "github.com/tendermint/tendermint/abci/version"
  21. "github.com/tendermint/tendermint/crypto/merkle"
  22. )
  23. // client is a global variable so it can be reused by the console
  24. var (
  25. client abcicli.Client
  26. logger log.Logger
  27. )
  28. // flags
  29. var (
  30. // global
  31. flagAddress string
  32. flagAbci string
  33. flagVerbose bool // for the println output
  34. flagLogLevel string // for the logger
  35. // query
  36. flagPath string
  37. flagHeight int
  38. flagProve bool
  39. // counter
  40. flagSerial bool
  41. // kvstore
  42. flagPersist string
  43. )
  44. var RootCmd = &cobra.Command{
  45. Use: "abci-cli",
  46. Short: "the ABCI CLI tool wraps an ABCI client",
  47. Long: "the ABCI CLI tool wraps an ABCI client and is used for testing ABCI servers",
  48. PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
  49. switch cmd.Use {
  50. case "counter", "kvstore": // for the examples apps, don't pre-run
  51. return nil
  52. case "version": // skip running for version command
  53. return nil
  54. }
  55. if logger == nil {
  56. allowLevel, err := log.AllowLevel(flagLogLevel)
  57. if err != nil {
  58. return err
  59. }
  60. logger = log.NewFilter(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), allowLevel)
  61. }
  62. if client == nil {
  63. var err error
  64. client, err = abcicli.NewClient(flagAddress, flagAbci, false)
  65. if err != nil {
  66. return err
  67. }
  68. client.SetLogger(logger.With("module", "abci-client"))
  69. if err := client.Start(); err != nil {
  70. return err
  71. }
  72. }
  73. return nil
  74. },
  75. }
  76. // Structure for data passed to print response.
  77. type response struct {
  78. // generic abci response
  79. Data []byte
  80. Code uint32
  81. Info string
  82. Log string
  83. Query *queryResponse
  84. }
  85. type queryResponse struct {
  86. Key []byte
  87. Value []byte
  88. Height int64
  89. Proof *merkle.Proof
  90. }
  91. func Execute() error {
  92. addGlobalFlags()
  93. addCommands()
  94. return RootCmd.Execute()
  95. }
  96. func addGlobalFlags() {
  97. RootCmd.PersistentFlags().StringVarP(&flagAddress, "address", "", "tcp://0.0.0.0:26658", "address of application socket")
  98. RootCmd.PersistentFlags().StringVarP(&flagAbci, "abci", "", "socket", "either socket or grpc")
  99. RootCmd.PersistentFlags().BoolVarP(&flagVerbose, "verbose", "v", false, "print the command and results as if it were a console session")
  100. RootCmd.PersistentFlags().StringVarP(&flagLogLevel, "log_level", "", "debug", "set the logger level")
  101. }
  102. func addQueryFlags() {
  103. queryCmd.PersistentFlags().StringVarP(&flagPath, "path", "", "/store", "path to prefix query with")
  104. queryCmd.PersistentFlags().IntVarP(&flagHeight, "height", "", 0, "height to query the blockchain at")
  105. queryCmd.PersistentFlags().BoolVarP(&flagProve, "prove", "", false, "whether or not to return a merkle proof of the query result")
  106. }
  107. func addCounterFlags() {
  108. counterCmd.PersistentFlags().BoolVarP(&flagSerial, "serial", "", false, "enforce incrementing (serial) transactions")
  109. }
  110. func addKVStoreFlags() {
  111. kvstoreCmd.PersistentFlags().StringVarP(&flagPersist, "persist", "", "", "directory to use for a database")
  112. }
  113. func addCommands() {
  114. RootCmd.AddCommand(batchCmd)
  115. RootCmd.AddCommand(consoleCmd)
  116. RootCmd.AddCommand(echoCmd)
  117. RootCmd.AddCommand(infoCmd)
  118. RootCmd.AddCommand(setOptionCmd)
  119. RootCmd.AddCommand(deliverTxCmd)
  120. RootCmd.AddCommand(checkTxCmd)
  121. RootCmd.AddCommand(commitCmd)
  122. RootCmd.AddCommand(versionCmd)
  123. RootCmd.AddCommand(testCmd)
  124. addQueryFlags()
  125. RootCmd.AddCommand(queryCmd)
  126. // examples
  127. addCounterFlags()
  128. RootCmd.AddCommand(counterCmd)
  129. addKVStoreFlags()
  130. RootCmd.AddCommand(kvstoreCmd)
  131. }
  132. var batchCmd = &cobra.Command{
  133. Use: "batch",
  134. Short: "run a batch of abci commands against an application",
  135. Long: `run a batch of abci commands against an application
  136. This command is run by piping in a file containing a series of commands
  137. you'd like to run:
  138. abci-cli batch < example.file
  139. where example.file looks something like:
  140. set_option serial on
  141. check_tx 0x00
  142. check_tx 0xff
  143. deliver_tx 0x00
  144. check_tx 0x00
  145. deliver_tx 0x01
  146. deliver_tx 0x04
  147. info
  148. `,
  149. Args: cobra.ExactArgs(0),
  150. RunE: cmdBatch,
  151. }
  152. var consoleCmd = &cobra.Command{
  153. Use: "console",
  154. Short: "start an interactive ABCI console for multiple commands",
  155. Long: `start an interactive ABCI console for multiple commands
  156. This command opens an interactive console for running any of the other commands
  157. without opening a new connection each time
  158. `,
  159. Args: cobra.ExactArgs(0),
  160. ValidArgs: []string{"echo", "info", "set_option", "deliver_tx", "check_tx", "commit", "query"},
  161. RunE: cmdConsole,
  162. }
  163. var echoCmd = &cobra.Command{
  164. Use: "echo",
  165. Short: "have the application echo a message",
  166. Long: "have the application echo a message",
  167. Args: cobra.ExactArgs(1),
  168. RunE: cmdEcho,
  169. }
  170. var infoCmd = &cobra.Command{
  171. Use: "info",
  172. Short: "get some info about the application",
  173. Long: "get some info about the application",
  174. Args: cobra.ExactArgs(0),
  175. RunE: cmdInfo,
  176. }
  177. var setOptionCmd = &cobra.Command{
  178. Use: "set_option",
  179. Short: "set an option on the application",
  180. Long: "set an option on the application",
  181. Args: cobra.ExactArgs(2),
  182. RunE: cmdSetOption,
  183. }
  184. var deliverTxCmd = &cobra.Command{
  185. Use: "deliver_tx",
  186. Short: "deliver a new transaction to the application",
  187. Long: "deliver a new transaction to the application",
  188. Args: cobra.ExactArgs(1),
  189. RunE: cmdDeliverTx,
  190. }
  191. var checkTxCmd = &cobra.Command{
  192. Use: "check_tx",
  193. Short: "validate a transaction",
  194. Long: "validate a transaction",
  195. Args: cobra.ExactArgs(1),
  196. RunE: cmdCheckTx,
  197. }
  198. var commitCmd = &cobra.Command{
  199. Use: "commit",
  200. Short: "commit the application state and return the Merkle root hash",
  201. Long: "commit the application state and return the Merkle root hash",
  202. Args: cobra.ExactArgs(0),
  203. RunE: cmdCommit,
  204. }
  205. var versionCmd = &cobra.Command{
  206. Use: "version",
  207. Short: "print ABCI console version",
  208. Long: "print ABCI console version",
  209. Args: cobra.ExactArgs(0),
  210. RunE: func(cmd *cobra.Command, args []string) error {
  211. fmt.Println(version.Version)
  212. return nil
  213. },
  214. }
  215. var queryCmd = &cobra.Command{
  216. Use: "query",
  217. Short: "query the application state",
  218. Long: "query the application state",
  219. Args: cobra.ExactArgs(1),
  220. RunE: cmdQuery,
  221. }
  222. var counterCmd = &cobra.Command{
  223. Use: "counter",
  224. Short: "ABCI demo example",
  225. Long: "ABCI demo example",
  226. Args: cobra.ExactArgs(0),
  227. RunE: cmdCounter,
  228. }
  229. var kvstoreCmd = &cobra.Command{
  230. Use: "kvstore",
  231. Short: "ABCI demo example",
  232. Long: "ABCI demo example",
  233. Args: cobra.ExactArgs(0),
  234. RunE: cmdKVStore,
  235. }
  236. var testCmd = &cobra.Command{
  237. Use: "test",
  238. Short: "run integration tests",
  239. Long: "run integration tests",
  240. Args: cobra.ExactArgs(0),
  241. RunE: cmdTest,
  242. }
  243. // Generates new Args array based off of previous call args to maintain flag persistence
  244. func persistentArgs(line []byte) []string {
  245. // generate the arguments to run from original os.Args
  246. // to maintain flag arguments
  247. args := os.Args
  248. args = args[:len(args)-1] // remove the previous command argument
  249. if len(line) > 0 { // prevents introduction of extra space leading to argument parse errors
  250. args = append(args, strings.Split(string(line), " ")...)
  251. }
  252. return args
  253. }
  254. //--------------------------------------------------------------------------------
  255. func compose(fs []func() error) error {
  256. if len(fs) == 0 {
  257. return nil
  258. } else {
  259. err := fs[0]()
  260. if err == nil {
  261. return compose(fs[1:])
  262. } else {
  263. return err
  264. }
  265. }
  266. }
  267. func cmdTest(cmd *cobra.Command, args []string) error {
  268. return compose(
  269. []func() error{
  270. func() error { return servertest.InitChain(client) },
  271. func() error { return servertest.SetOption(client, "serial", "on") },
  272. func() error { return servertest.Commit(client, nil) },
  273. func() error { return servertest.DeliverTx(client, []byte("abc"), code.CodeTypeBadNonce, nil) },
  274. func() error { return servertest.Commit(client, nil) },
  275. func() error { return servertest.DeliverTx(client, []byte{0x00}, code.CodeTypeOK, nil) },
  276. func() error { return servertest.Commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 1}) },
  277. func() error { return servertest.DeliverTx(client, []byte{0x00}, code.CodeTypeBadNonce, nil) },
  278. func() error { return servertest.DeliverTx(client, []byte{0x01}, code.CodeTypeOK, nil) },
  279. func() error { return servertest.DeliverTx(client, []byte{0x00, 0x02}, code.CodeTypeOK, nil) },
  280. func() error { return servertest.DeliverTx(client, []byte{0x00, 0x03}, code.CodeTypeOK, nil) },
  281. func() error { return servertest.DeliverTx(client, []byte{0x00, 0x00, 0x04}, code.CodeTypeOK, nil) },
  282. func() error {
  283. return servertest.DeliverTx(client, []byte{0x00, 0x00, 0x06}, code.CodeTypeBadNonce, nil)
  284. },
  285. func() error { return servertest.Commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 5}) },
  286. })
  287. }
  288. func cmdBatch(cmd *cobra.Command, args []string) error {
  289. bufReader := bufio.NewReader(os.Stdin)
  290. LOOP:
  291. for {
  292. line, more, err := bufReader.ReadLine()
  293. switch {
  294. case more:
  295. return errors.New("Input line is too long")
  296. case err == io.EOF:
  297. break LOOP
  298. case len(line) == 0:
  299. continue
  300. case err != nil:
  301. return err
  302. }
  303. cmdArgs := persistentArgs(line)
  304. if err := muxOnCommands(cmd, cmdArgs); err != nil {
  305. return err
  306. }
  307. fmt.Println()
  308. }
  309. return nil
  310. }
  311. func cmdConsole(cmd *cobra.Command, args []string) error {
  312. for {
  313. fmt.Printf("> ")
  314. bufReader := bufio.NewReader(os.Stdin)
  315. line, more, err := bufReader.ReadLine()
  316. if more {
  317. return errors.New("Input is too long")
  318. } else if err != nil {
  319. return err
  320. }
  321. pArgs := persistentArgs(line)
  322. if err := muxOnCommands(cmd, pArgs); err != nil {
  323. return err
  324. }
  325. }
  326. }
  327. func muxOnCommands(cmd *cobra.Command, pArgs []string) error {
  328. if len(pArgs) < 2 {
  329. return errors.New("expecting persistent args of the form: abci-cli [command] <...>")
  330. }
  331. // TODO: this parsing is fragile
  332. args := []string{}
  333. for i := 0; i < len(pArgs); i++ {
  334. arg := pArgs[i]
  335. // check for flags
  336. if strings.HasPrefix(arg, "-") {
  337. // if it has an equal, we can just skip
  338. if strings.Contains(arg, "=") {
  339. continue
  340. }
  341. // if its a boolean, we can just skip
  342. _, err := cmd.Flags().GetBool(strings.TrimLeft(arg, "-"))
  343. if err == nil {
  344. continue
  345. }
  346. // otherwise, we need to skip the next one too
  347. i++
  348. continue
  349. }
  350. // append the actual arg
  351. args = append(args, arg)
  352. }
  353. var subCommand string
  354. var actualArgs []string
  355. if len(args) > 1 {
  356. subCommand = args[1]
  357. }
  358. if len(args) > 2 {
  359. actualArgs = args[2:]
  360. }
  361. cmd.Use = subCommand // for later print statements ...
  362. switch strings.ToLower(subCommand) {
  363. case "check_tx":
  364. return cmdCheckTx(cmd, actualArgs)
  365. case "commit":
  366. return cmdCommit(cmd, actualArgs)
  367. case "deliver_tx":
  368. return cmdDeliverTx(cmd, actualArgs)
  369. case "echo":
  370. return cmdEcho(cmd, actualArgs)
  371. case "info":
  372. return cmdInfo(cmd, actualArgs)
  373. case "query":
  374. return cmdQuery(cmd, actualArgs)
  375. case "set_option":
  376. return cmdSetOption(cmd, actualArgs)
  377. default:
  378. return cmdUnimplemented(cmd, pArgs)
  379. }
  380. }
  381. func cmdUnimplemented(cmd *cobra.Command, args []string) error {
  382. msg := "unimplemented command"
  383. if len(args) > 0 {
  384. msg += fmt.Sprintf(" args: [%s]", strings.Join(args, " "))
  385. }
  386. printResponse(cmd, args, response{
  387. Code: codeBad,
  388. Log: msg,
  389. })
  390. fmt.Println("Available commands:")
  391. fmt.Printf("%s: %s\n", echoCmd.Use, echoCmd.Short)
  392. fmt.Printf("%s: %s\n", infoCmd.Use, infoCmd.Short)
  393. fmt.Printf("%s: %s\n", checkTxCmd.Use, checkTxCmd.Short)
  394. fmt.Printf("%s: %s\n", deliverTxCmd.Use, deliverTxCmd.Short)
  395. fmt.Printf("%s: %s\n", queryCmd.Use, queryCmd.Short)
  396. fmt.Printf("%s: %s\n", commitCmd.Use, commitCmd.Short)
  397. fmt.Printf("%s: %s\n", setOptionCmd.Use, setOptionCmd.Short)
  398. fmt.Println("Use \"[command] --help\" for more information about a command.")
  399. return nil
  400. }
  401. // Have the application echo a message
  402. func cmdEcho(cmd *cobra.Command, args []string) error {
  403. msg := ""
  404. if len(args) > 0 {
  405. msg = args[0]
  406. }
  407. res, err := client.EchoSync(msg)
  408. if err != nil {
  409. return err
  410. }
  411. printResponse(cmd, args, response{
  412. Data: []byte(res.Message),
  413. })
  414. return nil
  415. }
  416. // Get some info from the application
  417. func cmdInfo(cmd *cobra.Command, args []string) error {
  418. var version string
  419. if len(args) == 1 {
  420. version = args[0]
  421. }
  422. res, err := client.InfoSync(types.RequestInfo{Version: version})
  423. if err != nil {
  424. return err
  425. }
  426. printResponse(cmd, args, response{
  427. Data: []byte(res.Data),
  428. })
  429. return nil
  430. }
  431. const codeBad uint32 = 10
  432. // Set an option on the application
  433. func cmdSetOption(cmd *cobra.Command, args []string) error {
  434. if len(args) < 2 {
  435. printResponse(cmd, args, response{
  436. Code: codeBad,
  437. Log: "want at least arguments of the form: <key> <value>",
  438. })
  439. return nil
  440. }
  441. key, val := args[0], args[1]
  442. _, err := client.SetOptionSync(types.RequestSetOption{Key: key, Value: val})
  443. if err != nil {
  444. return err
  445. }
  446. printResponse(cmd, args, response{Log: "OK (SetOption doesn't return anything.)"}) // NOTE: Nothing to show...
  447. return nil
  448. }
  449. // Append a new tx to application
  450. func cmdDeliverTx(cmd *cobra.Command, args []string) error {
  451. if len(args) == 0 {
  452. printResponse(cmd, args, response{
  453. Code: codeBad,
  454. Log: "want the tx",
  455. })
  456. return nil
  457. }
  458. txBytes, err := stringOrHexToBytes(args[0])
  459. if err != nil {
  460. return err
  461. }
  462. res, err := client.DeliverTxSync(types.RequestDeliverTx{Tx: txBytes})
  463. if err != nil {
  464. return err
  465. }
  466. printResponse(cmd, args, response{
  467. Code: res.Code,
  468. Data: res.Data,
  469. Info: res.Info,
  470. Log: res.Log,
  471. })
  472. return nil
  473. }
  474. // Validate a tx
  475. func cmdCheckTx(cmd *cobra.Command, args []string) error {
  476. if len(args) == 0 {
  477. printResponse(cmd, args, response{
  478. Code: codeBad,
  479. Info: "want the tx",
  480. })
  481. return nil
  482. }
  483. txBytes, err := stringOrHexToBytes(args[0])
  484. if err != nil {
  485. return err
  486. }
  487. res, err := client.CheckTxSync(types.RequestCheckTx{Tx: txBytes})
  488. if err != nil {
  489. return err
  490. }
  491. printResponse(cmd, args, response{
  492. Code: res.Code,
  493. Data: res.Data,
  494. Info: res.Info,
  495. Log: res.Log,
  496. })
  497. return nil
  498. }
  499. // Get application Merkle root hash
  500. func cmdCommit(cmd *cobra.Command, args []string) error {
  501. res, err := client.CommitSync()
  502. if err != nil {
  503. return err
  504. }
  505. printResponse(cmd, args, response{
  506. Data: res.Data,
  507. })
  508. return nil
  509. }
  510. // Query application state
  511. func cmdQuery(cmd *cobra.Command, args []string) error {
  512. if len(args) == 0 {
  513. printResponse(cmd, args, response{
  514. Code: codeBad,
  515. Info: "want the query",
  516. Log: "",
  517. })
  518. return nil
  519. }
  520. queryBytes, err := stringOrHexToBytes(args[0])
  521. if err != nil {
  522. return err
  523. }
  524. resQuery, err := client.QuerySync(types.RequestQuery{
  525. Data: queryBytes,
  526. Path: flagPath,
  527. Height: int64(flagHeight),
  528. Prove: flagProve,
  529. })
  530. if err != nil {
  531. return err
  532. }
  533. printResponse(cmd, args, response{
  534. Code: resQuery.Code,
  535. Info: resQuery.Info,
  536. Log: resQuery.Log,
  537. Query: &queryResponse{
  538. Key: resQuery.Key,
  539. Value: resQuery.Value,
  540. Height: resQuery.Height,
  541. Proof: resQuery.Proof,
  542. },
  543. })
  544. return nil
  545. }
  546. func cmdCounter(cmd *cobra.Command, args []string) error {
  547. app := counter.NewCounterApplication(flagSerial)
  548. logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
  549. // Start the listener
  550. srv, err := server.NewServer(flagAddress, flagAbci, app)
  551. if err != nil {
  552. return err
  553. }
  554. srv.SetLogger(logger.With("module", "abci-server"))
  555. if err := srv.Start(); err != nil {
  556. return err
  557. }
  558. // Stop upon receiving SIGTERM or CTRL-C.
  559. cmn.TrapSignal(logger, func() {
  560. // Cleanup
  561. srv.Stop()
  562. })
  563. // Run forever.
  564. select {}
  565. }
  566. func cmdKVStore(cmd *cobra.Command, args []string) error {
  567. logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
  568. // Create the application - in memory or persisted to disk
  569. var app types.Application
  570. if flagPersist == "" {
  571. app = kvstore.NewKVStoreApplication()
  572. } else {
  573. app = kvstore.NewPersistentKVStoreApplication(flagPersist)
  574. app.(*kvstore.PersistentKVStoreApplication).SetLogger(logger.With("module", "kvstore"))
  575. }
  576. // Start the listener
  577. srv, err := server.NewServer(flagAddress, flagAbci, app)
  578. if err != nil {
  579. return err
  580. }
  581. srv.SetLogger(logger.With("module", "abci-server"))
  582. if err := srv.Start(); err != nil {
  583. return err
  584. }
  585. // Stop upon receiving SIGTERM or CTRL-C.
  586. cmn.TrapSignal(logger, func() {
  587. // Cleanup
  588. srv.Stop()
  589. })
  590. // Run forever.
  591. select {}
  592. }
  593. //--------------------------------------------------------------------------------
  594. func printResponse(cmd *cobra.Command, args []string, rsp response) {
  595. if flagVerbose {
  596. fmt.Println(">", cmd.Use, strings.Join(args, " "))
  597. }
  598. // Always print the status code.
  599. if rsp.Code == types.CodeTypeOK {
  600. fmt.Printf("-> code: OK\n")
  601. } else {
  602. fmt.Printf("-> code: %d\n", rsp.Code)
  603. }
  604. if len(rsp.Data) != 0 {
  605. // Do no print this line when using the commit command
  606. // because the string comes out as gibberish
  607. if cmd.Use != "commit" {
  608. fmt.Printf("-> data: %s\n", rsp.Data)
  609. }
  610. fmt.Printf("-> data.hex: 0x%X\n", rsp.Data)
  611. }
  612. if rsp.Log != "" {
  613. fmt.Printf("-> log: %s\n", rsp.Log)
  614. }
  615. if rsp.Query != nil {
  616. fmt.Printf("-> height: %d\n", rsp.Query.Height)
  617. if rsp.Query.Key != nil {
  618. fmt.Printf("-> key: %s\n", rsp.Query.Key)
  619. fmt.Printf("-> key.hex: %X\n", rsp.Query.Key)
  620. }
  621. if rsp.Query.Value != nil {
  622. fmt.Printf("-> value: %s\n", rsp.Query.Value)
  623. fmt.Printf("-> value.hex: %X\n", rsp.Query.Value)
  624. }
  625. if rsp.Query.Proof != nil {
  626. fmt.Printf("-> proof: %#v\n", rsp.Query.Proof)
  627. }
  628. }
  629. }
  630. // NOTE: s is interpreted as a string unless prefixed with 0x
  631. func stringOrHexToBytes(s string) ([]byte, error) {
  632. if len(s) > 2 && strings.ToLower(s[:2]) == "0x" {
  633. b, err := hex.DecodeString(s[2:])
  634. if err != nil {
  635. err = fmt.Errorf("Error decoding hex argument: %s", err.Error())
  636. return nil, err
  637. }
  638. return b, nil
  639. }
  640. if !strings.HasPrefix(s, "\"") || !strings.HasSuffix(s, "\"") {
  641. err := fmt.Errorf("Invalid string arg: \"%s\". Must be quoted or a \"0x\"-prefixed hex string", s)
  642. return nil, err
  643. }
  644. return []byte(s[1 : len(s)-1]), nil
  645. }