Implementing changes after team feedback

This commit is contained in:
Samuel Hawksby-Robinson 2020-04-29 18:02:26 +01:00
parent 2ae33f621a
commit 3393ee4494
No known key found for this signature in database
GPG Key ID: 64CF99D4A64A1205
3 changed files with 4 additions and 37 deletions

View File

@ -218,13 +218,6 @@ type NewMessage struct {
TargetPeer string `json:"targetPeer"`
}
// TODO if this is dead code why not remove it? I've checked and there are no usages of this
type newMessageOverride struct { // nolint: deadcode,unused
PublicKey hexutil.Bytes
Payload hexutil.Bytes
Padding hexutil.Bytes
}
// Post posts a message on the Waku network.
// returns the hash of the message in case of success.
func (api *PublicWakuAPI) Post(ctx context.Context, req NewMessage) (hexutil.Bytes, error) {
@ -366,12 +359,7 @@ func (api *PublicWakuAPI) Messages(ctx context.Context, crit Criteria) (*rpc.Sub
}
}
for i, bt := range crit.Topics {
// TODO these checks will always be false, common.TopicType has a predefined length and so any other length
// would cause a compile error.
if len(bt) == 0 || len(bt) > 4 {
return nil, fmt.Errorf("subscribe: topic %d has wrong size: %d", i, len(bt))
}
for _, bt := range crit.Topics {
filter.Topics = append(filter.Topics, bt[:])
}
@ -447,15 +435,6 @@ type Message struct {
P2P bool `json:"bool,omitempty"`
}
// TODO why not remove? This has no usage.
type messageOverride struct { // nolint: deadcode,unused
Sig hexutil.Bytes
Payload hexutil.Bytes
Padding hexutil.Bytes
Hash hexutil.Bytes
Dst hexutil.Bytes
}
// ToWakuMessage converts an internal message into an API version.
func ToWakuMessage(message *common.ReceivedMessage) *Message {
msg := Message{

View File

@ -22,6 +22,7 @@ import (
"bytes"
"crypto/aes"
"crypto/cipher"
"github.com/stretchr/testify/require"
mrand "math/rand"
"testing"
"time"
@ -198,13 +199,11 @@ func TestMessageSeal(t *testing.T) {
t.Fatalf("failed Wrap with seed %d: pow < target (%f vs. %f).", seed, pow, target)
}
// TODO is this meant to fail? The WorkTime is set to 1 but the PoW is 1000000000.0
// Seal should fail as WorkTime is significantly lower than PoW would require
params.WorkTime = 1
params.PoW = 1000000000.0
err = env.Seal(params)
if err != nil {
t.Logf("failed to seal envelope: %s", err)
}
require.EqualError(t, err, "failed to reach the PoW target, specified pow time (1 seconds) was insufficient")
env.CalculatePoW(0)
pow = env.PoW()
if pow < 2*target {

View File

@ -21,7 +21,6 @@ package waku
import (
"bytes"
"crypto/ecdsa"
"fmt"
mrand "math/rand"
"net"
"sync"
@ -338,16 +337,6 @@ func checkTestStatus() {
cnt++
}
}
// TODO Should this be removed? debug is always false and has no method of updating, this code will never be reached
if debugMode {
if cntPrev != cnt {
fmt.Printf(" %v \t number of nodes that have received all msgs: %d, number of peers per node: %v \n",
time.Since(prevTime), cnt, arr)
prevTime = time.Now()
cntPrev = cnt
}
}
}
func isTestComplete() bool {