Browse Source

Merge pull request #197 from tendermint/sed-dummy-kvstore

rename dummy to kvstore
pull/1780/head
Ethan Buchman 6 years ago
committed by GitHub
parent
commit
6d47f4afe2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 124 additions and 103 deletions
  1. +7
    -8
      README.md
  2. +31
    -9
      cmd/abci-cli/abci-cli.go
  3. +4
    -4
      example/example_test.go
  4. +6
    -6
      example/kvstore/README.md
  5. +3
    -3
      example/kvstore/helpers.go
  6. +10
    -10
      example/kvstore/kvstore.go
  7. +39
    -39
      example/kvstore/kvstore_test.go
  8. +21
    -21
      example/kvstore/persistent_kvstore.go
  9. +2
    -2
      tests/client_server_test.go
  10. +1
    -1
      tests/test_cli/test.sh

+ 7
- 8
README.md View File

@ -87,7 +87,7 @@ See [the documentation](http://tendermint.readthedocs.io/en/master/) for more de
### Examples
Check out the variety of example applications in the [example directory](example/).
It also contains the code refered to by the `counter` and `dummy` apps; these apps come
It also contains the code refered to by the `counter` and `kvstore` apps; these apps come
built into the `abci-cli` binary.
#### Counter
@ -122,21 +122,21 @@ func cmdCounter(cmd *cobra.Command, args []string) error {
and can be found in [this file](cmd/abci-cli/abci-cli.go).
#### Dummy
#### kvstore
The `abci-cli dummy` application, which illustrates a simple key-value Merkle tree
The `abci-cli kvstore` application, which illustrates a simple key-value Merkle tree
```golang
func cmdDummy(cmd *cobra.Command, args []string) error {
func cmdKVStore(cmd *cobra.Command, args []string) error {
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
// Create the application - in memory or persisted to disk
var app types.Application
if flagPersist == "" {
app = dummy.NewDummyApplication()
app = kvstore.NewKVStoreApplication()
} else {
app = dummy.NewPersistentDummyApplication(flagPersist)
app.(*dummy.PersistentDummyApplication).SetLogger(logger.With("module", "dummy"))
app = kvstore.NewPersistentKVStoreApplication(flagPersist)
app.(*kvstore.PersistentKVStoreApplication).SetLogger(logger.With("module", "kvstore"))
}
// Start the listener
@ -157,4 +157,3 @@ func cmdDummy(cmd *cobra.Command, args []string) error {
return nil
}
```

+ 31
- 9
cmd/abci-cli/abci-cli.go View File

@ -17,7 +17,7 @@ import (
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/code"
"github.com/tendermint/abci/example/counter"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/example/kvstore"
"github.com/tendermint/abci/server"
servertest "github.com/tendermint/abci/tests/server"
"github.com/tendermint/abci/types"
@ -47,7 +47,7 @@ var (
flagAddrC string
flagSerial bool
// dummy
// kvstore
flagAddrD string
flagPersist string
)
@ -59,7 +59,7 @@ var RootCmd = &cobra.Command{
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
switch cmd.Use {
case "counter", "dummy": // for the examples apps, don't pre-run
case "counter", "kvstore", "dummy": // for the examples apps, don't pre-run
return nil
case "version": // skip running for version command
return nil
@ -133,6 +133,12 @@ func addDummyFlags() {
dummyCmd.PersistentFlags().StringVarP(&flagAddrD, "addr", "", "tcp://0.0.0.0:46658", "listen address")
dummyCmd.PersistentFlags().StringVarP(&flagPersist, "persist", "", "", "directory to use for a database")
}
func addKVStoreFlags() {
kvstoreCmd.PersistentFlags().StringVarP(&flagAddrD, "addr", "", "tcp://0.0.0.0:46658", "listen address")
kvstoreCmd.PersistentFlags().StringVarP(&flagPersist, "persist", "", "", "directory to use for a database")
}
func addCommands() {
RootCmd.AddCommand(batchCmd)
RootCmd.AddCommand(consoleCmd)
@ -150,8 +156,12 @@ func addCommands() {
// examples
addCounterFlags()
RootCmd.AddCommand(counterCmd)
// deprecated, left for backwards compatibility
addDummyFlags()
RootCmd.AddCommand(dummyCmd)
// replaces dummy, see issue #196
addKVStoreFlags()
RootCmd.AddCommand(kvstoreCmd)
}
var batchCmd = &cobra.Command{
@ -285,13 +295,25 @@ var counterCmd = &cobra.Command{
},
}
// deprecated, left for backwards compatibility
var dummyCmd = &cobra.Command{
Use: "dummy",
Use: "dummy",
Deprecated: "use: [abci-cli kvstore] instead",
Short: "ABCI demo example",
Long: "ABCI demo example",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
return cmdKVStore(cmd, args)
},
}
var kvstoreCmd = &cobra.Command{
Use: "kvstore",
Short: "ABCI demo example",
Long: "ABCI demo example",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
return cmdDummy(cmd, args)
return cmdKVStore(cmd, args)
},
}
@ -654,16 +676,16 @@ func cmdCounter(cmd *cobra.Command, args []string) error {
return nil
}
func cmdDummy(cmd *cobra.Command, args []string) error {
func cmdKVStore(cmd *cobra.Command, args []string) error {
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
// Create the application - in memory or persisted to disk
var app types.Application
if flagPersist == "" {
app = dummy.NewDummyApplication()
app = kvstore.NewKVStoreApplication()
} else {
app = dummy.NewPersistentDummyApplication(flagPersist)
app.(*dummy.PersistentDummyApplication).SetLogger(logger.With("module", "dummy"))
app = kvstore.NewPersistentKVStoreApplication(flagPersist)
app.(*kvstore.PersistentKVStoreApplication).SetLogger(logger.With("module", "kvstore"))
}
// Start the listener


+ 4
- 4
example/example_test.go View File

@ -16,14 +16,14 @@ import (
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/code"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/example/kvstore"
abciserver "github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
)
func TestDummy(t *testing.T) {
fmt.Println("### Testing Dummy")
testStream(t, dummy.NewDummyApplication())
func TestKVStore(t *testing.T) {
fmt.Println("### Testing KVStore")
testStream(t, kvstore.NewKVStoreApplication())
}
func TestBaseApp(t *testing.T) {


example/dummy/README.md → example/kvstore/README.md View File


example/dummy/helpers.go → example/kvstore/helpers.go View File


example/dummy/dummy.go → example/kvstore/kvstore.go View File


example/dummy/dummy_test.go → example/kvstore/kvstore_test.go View File


example/dummy/persistent_dummy.go → example/kvstore/persistent_kvstore.go View File


+ 2
- 2
tests/client_server_test.go View File

@ -6,14 +6,14 @@ import (
"github.com/stretchr/testify/assert"
abciclient "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/example/kvstore"
abciserver "github.com/tendermint/abci/server"
)
func TestClientServerNoAddrPrefix(t *testing.T) {
addr := "localhost:46658"
transport := "socket"
app := dummy.NewDummyApplication()
app := kvstore.NewKVStoreApplication()
server, err := abciserver.NewServer(addr, transport, app)
assert.NoError(t, err, "expected no error on NewServer")


+ 1
- 1
tests/test_cli/test.sh View File

@ -35,7 +35,7 @@ function testExample() {
rm "${INPUT}".out.new
}
testExample 1 tests/test_cli/ex1.abci abci-cli dummy
testExample 1 tests/test_cli/ex1.abci abci-cli kvstore
testExample 2 tests/test_cli/ex2.abci abci-cli counter
echo ""


Loading…
Cancel
Save