cmd/swarm/swarm-smoke-pss: add raw send msg

This commit is contained in:
Rafael Matias 2019-03-25 22:33:13 +01:00
parent 550c60e410
commit d2a459f3af
No known key found for this signature in database
GPG key ID: 1BC39532FB4A2DBD
2 changed files with 21 additions and 1 deletions

View file

@ -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))

View file

@ -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)