Example #1
0
func NewLocalClient() *Client {
	eyesApp := app.NewMerkleEyesApp()
	tmspClient := tmspcli.NewLocalClient(nil, eyesApp)
	return &Client{
		Client: tmspClient,
	}
}
Example #2
0
func TestClient(t *testing.T) {

	addr := "tcp://127.0.0.1:46659"

	// Start the listener
	mApp := app.NewMerkleEyesApp()
	s, err := server.NewServer(addr, tmspType, mApp)
	if err != nil {
		t.Fatal(err.Error())
		return
	}
	defer s.Stop()

	// Create client
	cli, err := eyes.NewClient(addr, tmspType)
	if err != nil {
		t.Fatal(err.Error())
		return
	}
	defer cli.Stop()

	// Empty
	commit(t, cli, "")
	get(t, cli, "foo", "", "")
	get(t, cli, "bar", "", "")
	// Set foo=FOO
	set(t, cli, "foo", "FOO")
	commit(t, cli, "68DECA470D80183B5E979D167E3DD0956631A952")
	get(t, cli, "foo", "FOO", "")
	get(t, cli, "foa", "", "")
	get(t, cli, "foz", "", "")
	rem(t, cli, "foo")
	// Empty
	get(t, cli, "foo", "", "")
	commit(t, cli, "")
	// Set foo1, foo2, foo3...
	set(t, cli, "foo1", "1")
	set(t, cli, "foo2", "2")
	set(t, cli, "foo3", "3")
	set(t, cli, "foo1", "4")
	get(t, cli, "foo1", "4", "")
	get(t, cli, "foo2", "2", "")
	get(t, cli, "foo3", "3", "")
	rem(t, cli, "foo3")
	rem(t, cli, "foo2")
	rem(t, cli, "foo1")
	// Empty
	commit(t, cli, "")

}
Example #3
0
func cmdServer(app *cli.App, c *cli.Context) {
	addr := c.String("address")
	tmsp := c.String("tmsp")
	mApp := application.NewMerkleEyesApp()

	// Start the listener
	s, err := server.NewServer(addr, tmsp, mApp)
	if err != nil {
		Exit(err.Error())
	}

	// Wait forever
	TrapSignal(func() {
		// Cleanup
		s.Stop()
	})
}
Example #4
0
// NOTE: don't forget to close the client & server.
func CreateEyes(t *testing.T) (svr Service, cli *eyes.Client) {
	addr := "unix://eyes.sock"

	// Start the listener
	mApp := app.NewMerkleEyesApp()
	svr, err := server.NewServer(addr, tmspType, mApp)
	if err != nil {
		(err.Error())
		return
	}

	// Create client
	cli, err = eyes.NewClient(addr, tmspType)
	if err != nil {
		t.Fatal(err.Error())
		return
	}

	return svr, cli
}