From d2a459f3af9137207327dda5fc006feab0cfa938 Mon Sep 17 00:00:00 2001 From: Rafael Matias Date: Mon, 25 Mar 2019 22:33:13 +0100 Subject: [PATCH] cmd/swarm/swarm-smoke-pss: add raw send msg --- cmd/swarm/swarm-smoke-pss/main.go | 6 ++++++ cmd/swarm/swarm-smoke-pss/pss.go | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cmd/swarm/swarm-smoke-pss/main.go b/cmd/swarm/swarm-smoke-pss/main.go index 18346d3429..fa65330c54 100644 --- a/cmd/swarm/swarm-smoke-pss/main.go +++ b/cmd/swarm/swarm-smoke-pss/main.go @@ -115,6 +115,12 @@ func main() { Usage: "PSS: send and receive multiple messages across random nodes using symmetric encryption", Action: wrapCliCommand("sym", pssSymCheck), }, + { + Name: "raw", + Aliases: []string{"r"}, + Usage: "PSS: send and receive multiple raw messages across random nodes", + Action: wrapCliCommand("sym", pssRawCheck), + }, } sort.Sort(cli.FlagsByName(app.Flags)) diff --git a/cmd/swarm/swarm-smoke-pss/pss.go b/cmd/swarm/swarm-smoke-pss/pss.go index 87029040bf..b80a867a53 100644 --- a/cmd/swarm/swarm-smoke-pss/pss.go +++ b/cmd/swarm/swarm-smoke-pss/pss.go @@ -50,9 +50,11 @@ func pssAsymCheck(ctx *cli.Context, tuid string) error { func pssSymCheck(ctx *cli.Context, tuid string) error { return pssCheck(ctx, tuid, "sym", pssSymDo) } +func pssRawCheck(ctx *cli.Context, tuid string) error { + return pssCheck(ctx, tuid, "raw", pssRawDo) +} func pssCheck(ctx *cli.Context, tuid string, tag string, fn pssTestFn) error { - // use input seed if it has been set if inputSeed != 0 { seed = inputSeed @@ -275,6 +277,18 @@ func pssAsymDo(ctx *cli.Context, session *pssSession, tuid string) error { return session.waitForMsg() } +func pssRawDo(ctx *cli.Context, session *pssSession, tuid string) error { + j := session.genJob() + + err := j.sender.client.Call(nil, "pss_sendRaw", hexutil.Encode(j.receiver.addr), session.topic, hexutil.Encode(j.msg)) + if err != nil { + log.Error("error sending raw message", "err", err) + return err + } + + return session.waitForMsg() +} + func toMsgIdx(msg []byte) string { h := sha1.New() h.Write(msg)