mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
whisper: test cases fixed
This commit is contained in:
parent
cd70abb5c5
commit
7231c605cc
6 changed files with 356 additions and 356 deletions
|
|
@ -27,67 +27,67 @@ import (
|
|||
"github.com/ethereum/go-ethereum/whisper/whisperv5"
|
||||
)
|
||||
|
||||
func TestBasic(x *testing.T) {
|
||||
func TestBasic(t *testing.T) {
|
||||
var id string = "test"
|
||||
api := NewPublicWhisperAPI()
|
||||
if api == nil {
|
||||
x.Fatalf("failed to create API.")
|
||||
t.Fatalf("failed to create API.")
|
||||
}
|
||||
|
||||
ver, err := api.Version()
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateFilter: %s.", err)
|
||||
t.Fatalf("failed generateFilter: %s.", err)
|
||||
}
|
||||
|
||||
if ver.Uint64() != whisperv5.ProtocolVersion {
|
||||
x.Fatalf("wrong version: %d.", ver.Uint64())
|
||||
t.Fatalf("wrong version: %d.", ver.Uint64())
|
||||
}
|
||||
|
||||
mail := api.GetFilterChanges(1)
|
||||
if len(mail) != 0 {
|
||||
x.Fatalf("failed GetFilterChanges: premature result")
|
||||
t.Fatalf("failed GetFilterChanges: premature result")
|
||||
}
|
||||
|
||||
exist, err := api.HasIdentity(id)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 1: %s.", err)
|
||||
t.Fatalf("failed initial HasIdentity: %s.", err)
|
||||
}
|
||||
if exist {
|
||||
x.Fatalf("failed test case 2, HasIdentity: false positive.")
|
||||
t.Fatalf("failed initial HasIdentity: false positive.")
|
||||
}
|
||||
|
||||
err = api.DeleteIdentity(id)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 3: %s.", err)
|
||||
t.Fatalf("failed DeleteIdentity: %s.", err)
|
||||
}
|
||||
|
||||
pub, err := api.NewIdentity()
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 4: %s.", err)
|
||||
t.Fatalf("failed NewIdentity: %s.", err)
|
||||
}
|
||||
if len(pub) == 0 {
|
||||
x.Fatalf("test case 5, NewIdentity: empty")
|
||||
t.Fatalf("failed NewIdentity: empty")
|
||||
}
|
||||
|
||||
exist, err = api.HasIdentity(pub)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 6: %s.", err)
|
||||
t.Fatalf("failed HasIdentity: %s.", err)
|
||||
}
|
||||
if !exist {
|
||||
x.Fatalf("failed test case 7, HasIdentity: false negative.")
|
||||
t.Fatalf("failed HasIdentity: false negative.")
|
||||
}
|
||||
|
||||
err = api.DeleteIdentity(pub)
|
||||
if err != nil {
|
||||
x.Fatalf("failed 8 DeleteIdentity: %s.", err)
|
||||
t.Fatalf("failed to delete second identity: %s.", err)
|
||||
}
|
||||
|
||||
exist, err = api.HasIdentity(pub)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 9: %s.", err)
|
||||
t.Fatalf("failed HasIdentity(): %s.", err)
|
||||
}
|
||||
if exist {
|
||||
x.Fatalf("failed test case 10, HasIdentity: false positive.")
|
||||
t.Fatalf("failed HasIdentity(): false positive.")
|
||||
}
|
||||
|
||||
id = "arbitrary text"
|
||||
|
|
@ -95,58 +95,58 @@ func TestBasic(x *testing.T) {
|
|||
|
||||
exist, err = api.HasSymKey(id)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 11: %s.", err)
|
||||
t.Fatalf("failed HasSymKey: %s.", err)
|
||||
}
|
||||
if exist {
|
||||
x.Fatalf("failed test case 12, HasSymKey: false positive.")
|
||||
t.Fatalf("failed HasSymKey: false positive.")
|
||||
}
|
||||
|
||||
err = api.GenerateSymKey(id)
|
||||
if err != nil {
|
||||
x.Fatalf("failed 13 GenerateSymKey: %s.", err)
|
||||
t.Fatalf("failed GenerateSymKey: %s.", err)
|
||||
}
|
||||
|
||||
exist, err = api.HasSymKey(id)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 14: %s.", err)
|
||||
t.Fatalf("failed HasSymKey(): %s.", err)
|
||||
}
|
||||
if !exist {
|
||||
x.Fatalf("failed test case 15, HasSymKey: false negative.")
|
||||
t.Fatalf("failed HasSymKey(): false negative.")
|
||||
}
|
||||
|
||||
err = api.AddSymKey(id, []byte("some stuff here"))
|
||||
if err == nil {
|
||||
x.Fatalf("failed test case 16: %s.", err)
|
||||
t.Fatalf("failed AddSymKey: %s.", err)
|
||||
}
|
||||
|
||||
err = api.AddSymKey(id2, []byte("some stuff here"))
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 17: %s.", err)
|
||||
t.Fatalf("failed AddSymKey: %s.", err)
|
||||
}
|
||||
|
||||
exist, err = api.HasSymKey(id2)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 18: %s.", err)
|
||||
t.Fatalf("failed HasSymKey(id2): %s.", err)
|
||||
}
|
||||
if !exist {
|
||||
x.Fatalf("failed test case 19, HasSymKey: false negative.")
|
||||
t.Fatalf("failed HasSymKey(id2): false negative.")
|
||||
}
|
||||
|
||||
err = api.DeleteSymKey(id)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 20: %s.", err)
|
||||
t.Fatalf("failed DeleteSymKey(id): %s.", err)
|
||||
}
|
||||
|
||||
exist, err = api.HasSymKey(id)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 21: %s.", err)
|
||||
t.Fatalf("failed HasSymKey(id): %s.", err)
|
||||
}
|
||||
if exist {
|
||||
x.Fatalf("failed test case 22, HasSymKey: false positive.")
|
||||
t.Fatalf("failed HasSymKey(id): false positive.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnmarshalFilterArgs(x *testing.T) {
|
||||
func TestUnmarshalFilterArgs(t *testing.T) {
|
||||
s := []byte(`{
|
||||
"to":"0x70c87d191324e6712a591f304b4eedef6ad9bb9d",
|
||||
"from":"0x9b2055d370f73ec7d8a03e965129118dc8f5bf83",
|
||||
|
|
@ -159,50 +159,50 @@ func TestUnmarshalFilterArgs(x *testing.T) {
|
|||
var f WhisperFilterArgs
|
||||
err := f.UnmarshalJSON(s)
|
||||
if err != nil {
|
||||
x.Fatalf("failed UnmarshalJSON: %s.", err)
|
||||
t.Fatalf("failed UnmarshalJSON: %s.", err)
|
||||
}
|
||||
|
||||
if f.To != "0x70c87d191324e6712a591f304b4eedef6ad9bb9d" {
|
||||
x.Fatalf("wrong To: %x.", f.To)
|
||||
t.Fatalf("wrong To: %x.", f.To)
|
||||
}
|
||||
if f.From != "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83" {
|
||||
x.Fatalf("wrong From: %x.", f.To)
|
||||
t.Fatalf("wrong From: %x.", f.To)
|
||||
}
|
||||
if f.KeyName != "testname" {
|
||||
x.Fatalf("wrong KeyName: %s.", f.KeyName)
|
||||
t.Fatalf("wrong KeyName: %s.", f.KeyName)
|
||||
}
|
||||
if f.PoW != 2.34 {
|
||||
x.Fatalf("wrong pow: %f.", f.PoW)
|
||||
t.Fatalf("wrong pow: %f.", f.PoW)
|
||||
}
|
||||
if !f.AcceptP2P {
|
||||
x.Fatalf("wrong AcceptP2P: %v.", f.AcceptP2P)
|
||||
t.Fatalf("wrong AcceptP2P: %v.", f.AcceptP2P)
|
||||
}
|
||||
if len(f.Topics) != 4 {
|
||||
x.Fatalf("wrong topics number: %d.", len(f.Topics))
|
||||
t.Fatalf("wrong topics number: %d.", len(f.Topics))
|
||||
}
|
||||
|
||||
i := 0
|
||||
if f.Topics[i] != (whisperv5.TopicType{0x00, 0x00, 0x00, 0x00}) {
|
||||
x.Fatalf("wrong topic[%d]: %x.", i, f.Topics[i])
|
||||
t.Fatalf("wrong topic[%d]: %x.", i, f.Topics[i])
|
||||
}
|
||||
|
||||
i++
|
||||
if f.Topics[i] != (whisperv5.TopicType{0x00, 0x7f, 0x80, 0xff}) {
|
||||
x.Fatalf("wrong topic[%d]: %x.", i, f.Topics[i])
|
||||
t.Fatalf("wrong topic[%d]: %x.", i, f.Topics[i])
|
||||
}
|
||||
|
||||
i++
|
||||
if f.Topics[i] != (whisperv5.TopicType{0xff, 0x80, 0x7f, 0x00}) {
|
||||
x.Fatalf("wrong topic[%d]: %x.", i, f.Topics[i])
|
||||
t.Fatalf("wrong topic[%d]: %x.", i, f.Topics[i])
|
||||
}
|
||||
|
||||
i++
|
||||
if f.Topics[i] != (whisperv5.TopicType{0xf2, 0x6e, 0x77, 0x79}) {
|
||||
x.Fatalf("wrong topic[%d]: %x.", i, f.Topics[i])
|
||||
t.Fatalf("wrong topic[%d]: %x.", i, f.Topics[i])
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnmarshalPostArgs(x *testing.T) {
|
||||
func TestUnmarshalPostArgs(t *testing.T) {
|
||||
s := []byte(`{
|
||||
"ttl":12345,
|
||||
"from":"0x70c87d191324e6712a591f304b4eedef6ad9bb9d",
|
||||
|
|
@ -220,41 +220,41 @@ func TestUnmarshalPostArgs(x *testing.T) {
|
|||
var a PostArgs
|
||||
err := json.Unmarshal(s, &a)
|
||||
if err != nil {
|
||||
x.Fatalf("failed UnmarshalJSON: %s.", err)
|
||||
t.Fatalf("failed UnmarshalJSON: %s.", err)
|
||||
}
|
||||
|
||||
if a.TTL != 12345 {
|
||||
x.Fatalf("wrong ttl: %d.", a.TTL)
|
||||
t.Fatalf("wrong ttl: %d.", a.TTL)
|
||||
}
|
||||
if a.From != "0x70c87d191324e6712a591f304b4eedef6ad9bb9d" {
|
||||
x.Fatalf("wrong From: %x.", a.To)
|
||||
t.Fatalf("wrong From: %x.", a.To)
|
||||
}
|
||||
if a.To != "0x9b2055d370f73ec7d8a03e965129118dc8f5bf83" {
|
||||
x.Fatalf("wrong To: %x.", a.To)
|
||||
t.Fatalf("wrong To: %x.", a.To)
|
||||
}
|
||||
if a.KeyName != "shh_test" {
|
||||
x.Fatalf("wrong KeyName: %s.", a.KeyName)
|
||||
t.Fatalf("wrong KeyName: %s.", a.KeyName)
|
||||
}
|
||||
if a.Topic != (whisperv5.TopicType{0xf2, 0x6e, 0x77, 0x79}) {
|
||||
x.Fatalf("wrong topic: %x.", a.Topic)
|
||||
t.Fatalf("wrong topic: %x.", a.Topic)
|
||||
}
|
||||
if string(a.Padding) != "this is my test string" {
|
||||
x.Fatalf("wrong Padding: %s.", string(a.Padding))
|
||||
t.Fatalf("wrong Padding: %s.", string(a.Padding))
|
||||
}
|
||||
if string(a.Payload) != "payload should be pseudorandom" {
|
||||
x.Fatalf("wrong Payload: %s.", string(a.Payload))
|
||||
t.Fatalf("wrong Payload: %s.", string(a.Payload))
|
||||
}
|
||||
if a.WorkTime != 777 {
|
||||
x.Fatalf("wrong WorkTime: %d.", a.WorkTime)
|
||||
t.Fatalf("wrong WorkTime: %d.", a.WorkTime)
|
||||
}
|
||||
if a.PoW != 3.1416 {
|
||||
x.Fatalf("wrong pow: %f.", a.PoW)
|
||||
t.Fatalf("wrong pow: %f.", a.PoW)
|
||||
}
|
||||
if a.FilterID != 64 {
|
||||
x.Fatalf("wrong FilterID: %d.", a.FilterID)
|
||||
t.Fatalf("wrong FilterID: %d.", a.FilterID)
|
||||
}
|
||||
if bytes.Compare(a.PeerID[:], a.Topic[:]) != 0 {
|
||||
x.Fatalf("wrong PeerID: %x.", a.PeerID)
|
||||
t.Fatalf("wrong PeerID: %x.", a.PeerID)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -271,34 +271,34 @@ func waitForMessage(api *PublicWhisperAPI, id uint32, target int) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func TestIntegrationAsym(x *testing.T) {
|
||||
func TestIntegrationAsym(t *testing.T) {
|
||||
api := NewPublicWhisperAPI()
|
||||
if api == nil {
|
||||
x.Fatalf("failed to create API.")
|
||||
t.Fatalf("failed to create API.")
|
||||
}
|
||||
|
||||
sig, err := api.NewIdentity()
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 22: %s.", err)
|
||||
t.Fatalf("failed NewIdentity: %s.", err)
|
||||
}
|
||||
if len(sig) == 0 {
|
||||
x.Fatalf("failed test case 23")
|
||||
t.Fatalf("wrong signature")
|
||||
}
|
||||
|
||||
exist, err := api.HasIdentity(sig)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 24: %s.", err)
|
||||
t.Fatalf("failed HasIdentity: %s.", err)
|
||||
}
|
||||
if !exist {
|
||||
x.Fatalf("failed test case 25, HasIdentity: false negative.")
|
||||
t.Fatalf("failed HasIdentity: false negative.")
|
||||
}
|
||||
|
||||
key, err := api.NewIdentity()
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 26: %s.", err)
|
||||
t.Fatalf("failed NewIdentity(): %s.", err)
|
||||
}
|
||||
if len(key) == 0 {
|
||||
x.Fatalf("failed test case 27")
|
||||
t.Fatalf("wrong key")
|
||||
}
|
||||
|
||||
var topics [2]whisperv5.TopicType
|
||||
|
|
@ -313,7 +313,7 @@ func TestIntegrationAsym(x *testing.T) {
|
|||
|
||||
id, err := api.NewFilter(f)
|
||||
if err != nil {
|
||||
x.Fatalf("failed to create new filter: %s.", err)
|
||||
t.Fatalf("failed to create new filter: %s.", err)
|
||||
}
|
||||
|
||||
var p PostArgs
|
||||
|
|
@ -328,73 +328,73 @@ func TestIntegrationAsym(x *testing.T) {
|
|||
|
||||
err = api.Post(p)
|
||||
if err != nil {
|
||||
x.Errorf("failed to post message: %s.", err)
|
||||
t.Errorf("failed to post message: %s.", err)
|
||||
}
|
||||
|
||||
ok := waitForMessage(api, id, 1)
|
||||
if !ok {
|
||||
x.Fatalf("failed to receive first message: timeout.")
|
||||
t.Fatalf("failed to receive first message: timeout.")
|
||||
}
|
||||
|
||||
mail := api.GetFilterChanges(id)
|
||||
if len(mail) != 1 {
|
||||
x.Fatalf("failed to GetFilterChanges: got %d messages.", len(mail))
|
||||
t.Fatalf("failed to GetFilterChanges: got %d messages.", len(mail))
|
||||
}
|
||||
|
||||
text := string(common.FromHex(mail[0].Payload))
|
||||
if text != string("extended test string") {
|
||||
x.Fatalf("failed to decrypt first message: %s.", text)
|
||||
t.Fatalf("failed to decrypt first message: %s.", text)
|
||||
}
|
||||
|
||||
p.Padding = []byte("new value")
|
||||
p.Payload = []byte("extended new value")
|
||||
err = api.Post(p)
|
||||
if err != nil {
|
||||
x.Fatalf("failed to post next message: %s.", err)
|
||||
t.Fatalf("failed to post next message: %s.", err)
|
||||
}
|
||||
|
||||
ok = waitForMessage(api, id, 2)
|
||||
if !ok {
|
||||
x.Fatalf("failed to receive second message: timeout.")
|
||||
t.Fatalf("failed to receive second message: timeout.")
|
||||
}
|
||||
|
||||
mail = api.GetFilterChanges(id)
|
||||
if len(mail) != 1 {
|
||||
x.Fatalf("failed to GetFilterChanges: got %d messages.", len(mail))
|
||||
t.Fatalf("failed to GetFilterChanges: got %d messages.", len(mail))
|
||||
}
|
||||
|
||||
text = string(common.FromHex(mail[0].Payload))
|
||||
if text != string("extended new value") {
|
||||
x.Fatalf("failed to decrypt second message: %s.", text)
|
||||
t.Fatalf("failed to decrypt second message: %s.", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntegrationSym(x *testing.T) {
|
||||
func TestIntegrationSym(t *testing.T) {
|
||||
api := NewPublicWhisperAPI()
|
||||
if api == nil {
|
||||
x.Fatalf("failed to create API.")
|
||||
t.Fatalf("failed to create API.")
|
||||
}
|
||||
|
||||
keyname := "schluessel"
|
||||
err := api.GenerateSymKey(keyname)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 1: %s.", err)
|
||||
t.Fatalf("failed GenerateSymKey: %s.", err)
|
||||
}
|
||||
|
||||
sig, err := api.NewIdentity()
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 2: %s.", err)
|
||||
t.Fatalf("failed NewIdentity: %s.", err)
|
||||
}
|
||||
if len(sig) == 0 {
|
||||
x.Fatalf("failed test case 3")
|
||||
t.Fatalf("wrong signature")
|
||||
}
|
||||
|
||||
exist, err := api.HasIdentity(sig)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 4: %s.", err)
|
||||
t.Fatalf("failed HasIdentity: %s.", err)
|
||||
}
|
||||
if !exist {
|
||||
x.Fatalf("failed test case 5, HasIdentity: false negative.")
|
||||
t.Fatalf("failed HasIdentity: false negative.")
|
||||
}
|
||||
|
||||
var topics [2]whisperv5.TopicType
|
||||
|
|
@ -409,7 +409,7 @@ func TestIntegrationSym(x *testing.T) {
|
|||
|
||||
id, err := api.NewFilter(f)
|
||||
if err != nil {
|
||||
x.Fatalf("failed 31 to create new filter: %s.", err)
|
||||
t.Fatalf("failed to create new filter: %s.", err)
|
||||
}
|
||||
|
||||
var p PostArgs
|
||||
|
|
@ -424,73 +424,73 @@ func TestIntegrationSym(x *testing.T) {
|
|||
|
||||
err = api.Post(p)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 32 (post message): %s.", err)
|
||||
t.Fatalf("failed to post first message: %s.", err)
|
||||
}
|
||||
|
||||
ok := waitForMessage(api, id, 1)
|
||||
if !ok {
|
||||
x.Fatalf("failed test case 33 (receive first message: timeout).")
|
||||
t.Fatalf("failed to receive first message: timeout.")
|
||||
}
|
||||
|
||||
mail := api.GetFilterChanges(id)
|
||||
if len(mail) != 1 {
|
||||
x.Fatalf("failed test case 34 (GetFilterChanges: got %d messages).", len(mail))
|
||||
t.Fatalf("failed GetFilterChanges: got %d messages.", len(mail))
|
||||
}
|
||||
|
||||
text := string(common.FromHex(mail[0].Payload))
|
||||
if text != string("extended test string") {
|
||||
x.Fatalf("failed test case 35 (decrypt first message): %s.", text)
|
||||
t.Fatalf("failed to decrypt first message: %s.", text)
|
||||
}
|
||||
|
||||
p.Padding = []byte("new value")
|
||||
p.Payload = []byte("extended new value")
|
||||
err = api.Post(p)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 42 (post message): %s.", err)
|
||||
t.Fatalf("failed to post second message: %s.", err)
|
||||
}
|
||||
|
||||
ok = waitForMessage(api, id, 2)
|
||||
if !ok {
|
||||
x.Fatalf("failed test case 43 (receive second message: timeout).")
|
||||
t.Fatalf("failed to receive second message: timeout.")
|
||||
}
|
||||
|
||||
mail = api.GetFilterChanges(id)
|
||||
if len(mail) != 1 {
|
||||
x.Fatalf("failed test case 44 (GetFilterChanges: got %d messages).", len(mail))
|
||||
t.Fatalf("failed second GetFilterChanges: got %d messages.", len(mail))
|
||||
}
|
||||
|
||||
text = string(common.FromHex(mail[0].Payload))
|
||||
if text != string("extended new value") {
|
||||
x.Fatalf("failed test case 45 (decrypt second message: %s).", text)
|
||||
t.Fatalf("failed to decrypt second message: %s.", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntegrationSymWithFilter(x *testing.T) {
|
||||
func TestIntegrationSymWithFilter(t *testing.T) {
|
||||
api := NewPublicWhisperAPI()
|
||||
if api == nil {
|
||||
x.Fatalf("failed to create API.")
|
||||
t.Fatalf("failed to create API.")
|
||||
}
|
||||
|
||||
keyname := "schluessel"
|
||||
err := api.GenerateSymKey(keyname)
|
||||
if err != nil {
|
||||
x.Fatalf("failed to GenerateSymKey: %s.", err)
|
||||
t.Fatalf("failed to GenerateSymKey: %s.", err)
|
||||
}
|
||||
|
||||
sig, err := api.NewIdentity()
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 2: %s.", err)
|
||||
t.Fatalf("failed NewIdentity: %s.", err)
|
||||
}
|
||||
if len(sig) == 0 {
|
||||
x.Fatalf("failed test case 3.")
|
||||
t.Fatalf("wrong signature.")
|
||||
}
|
||||
|
||||
exist, err := api.HasIdentity(sig)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 4: %s.", err)
|
||||
t.Fatalf("failed HasIdentity: %s.", err)
|
||||
}
|
||||
if !exist {
|
||||
x.Fatalf("failed test case 5.")
|
||||
t.Fatalf("failed HasIdentity: does not exist.")
|
||||
}
|
||||
|
||||
var topics [2]whisperv5.TopicType
|
||||
|
|
@ -505,7 +505,7 @@ func TestIntegrationSymWithFilter(x *testing.T) {
|
|||
|
||||
id, err := api.NewFilter(f)
|
||||
if err != nil {
|
||||
x.Fatalf("failed to create new filter: %s.", err)
|
||||
t.Fatalf("failed to create new filter: %s.", err)
|
||||
}
|
||||
|
||||
var p PostArgs
|
||||
|
|
@ -520,43 +520,43 @@ func TestIntegrationSymWithFilter(x *testing.T) {
|
|||
|
||||
err = api.Post(p)
|
||||
if err != nil {
|
||||
x.Fatalf("failed to post message: %s.", err)
|
||||
t.Fatalf("failed to post message: %s.", err)
|
||||
}
|
||||
|
||||
ok := waitForMessage(api, id, 1)
|
||||
if !ok {
|
||||
x.Fatalf("failed to receive first message: timeout.")
|
||||
t.Fatalf("failed to receive first message: timeout.")
|
||||
}
|
||||
|
||||
mail := api.GetFilterChanges(id)
|
||||
if len(mail) != 1 {
|
||||
x.Fatalf("failed to GetFilterChanges: got %d messages.", len(mail))
|
||||
t.Fatalf("failed to GetFilterChanges: got %d messages.", len(mail))
|
||||
}
|
||||
|
||||
text := string(common.FromHex(mail[0].Payload))
|
||||
if text != string("extended test string") {
|
||||
x.Fatalf("failed to decrypt first message: %s.", text)
|
||||
t.Fatalf("failed to decrypt first message: %s.", text)
|
||||
}
|
||||
|
||||
p.Padding = []byte("new value")
|
||||
p.Payload = []byte("extended new value")
|
||||
err = api.Post(p)
|
||||
if err != nil {
|
||||
x.Fatalf("failed to post next message: %s.", err)
|
||||
t.Fatalf("failed to post next message: %s.", err)
|
||||
}
|
||||
|
||||
ok = waitForMessage(api, id, 2)
|
||||
if !ok {
|
||||
x.Fatalf("failed to receive second message: timeout.")
|
||||
t.Fatalf("failed to receive second message: timeout.")
|
||||
}
|
||||
|
||||
mail = api.GetFilterChanges(id)
|
||||
if len(mail) != 1 {
|
||||
x.Fatalf("failed to GetFilterChanges: got %d messages.", len(mail))
|
||||
t.Fatalf("failed to GetFilterChanges: got %d messages.", len(mail))
|
||||
}
|
||||
|
||||
text = string(common.FromHex(mail[0].Payload))
|
||||
if text != string("extended new value") {
|
||||
x.Fatalf("failed to decrypt second message: %s.", text)
|
||||
t.Fatalf("failed to decrypt second message: %s.", text)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ type FilterTestCase struct {
|
|||
msgCnt int
|
||||
}
|
||||
|
||||
func generateFilter(x *testing.T, symmetric bool) (*Filter, error) {
|
||||
func generateFilter(t *testing.T, symmetric bool) (*Filter, error) {
|
||||
var f Filter
|
||||
f.Messages = make(map[common.Hash]*ReceivedMessage)
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ func generateFilter(x *testing.T, symmetric bool) (*Filter, error) {
|
|||
|
||||
key, err := crypto.GenerateKey()
|
||||
if err != nil {
|
||||
x.Fatalf("generateFilter 1 failed with seed %d.", seed)
|
||||
t.Fatalf("generateFilter 1 failed with seed %d.", seed)
|
||||
return nil, err
|
||||
}
|
||||
f.Src = &key.PublicKey
|
||||
|
|
@ -73,7 +73,7 @@ func generateFilter(x *testing.T, symmetric bool) (*Filter, error) {
|
|||
} else {
|
||||
f.KeyAsym, err = crypto.GenerateKey()
|
||||
if err != nil {
|
||||
x.Fatalf("generateFilter 2 failed with seed %d.", seed)
|
||||
t.Fatalf("generateFilter 2 failed with seed %d.", seed)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
@ -82,23 +82,23 @@ func generateFilter(x *testing.T, symmetric bool) (*Filter, error) {
|
|||
return &f, nil
|
||||
}
|
||||
|
||||
func generateTestCases(x *testing.T, SizeTestFilters int) []FilterTestCase {
|
||||
func generateTestCases(t *testing.T, SizeTestFilters int) []FilterTestCase {
|
||||
cases := make([]FilterTestCase, SizeTestFilters)
|
||||
for i := 0; i < SizeTestFilters; i++ {
|
||||
f, _ := generateFilter(x, true)
|
||||
f, _ := generateFilter(t, true)
|
||||
cases[i].f = f
|
||||
cases[i].alive = (rand.Int()&int(1) == 0)
|
||||
}
|
||||
return cases
|
||||
}
|
||||
|
||||
func TestInstallFilters(x *testing.T) {
|
||||
func TestInstallFilters(t *testing.T) {
|
||||
InitSingleTest()
|
||||
|
||||
const SizeTestFilters = 256
|
||||
w := NewWhisper(nil)
|
||||
filters := NewFilters(w)
|
||||
tst := generateTestCases(x, SizeTestFilters)
|
||||
tst := generateTestCases(t, SizeTestFilters)
|
||||
|
||||
var j uint32
|
||||
for i := 0; i < SizeTestFilters; i++ {
|
||||
|
|
@ -107,69 +107,69 @@ func TestInstallFilters(x *testing.T) {
|
|||
}
|
||||
|
||||
if j < SizeTestFilters-1 {
|
||||
x.Fatalf("seed %d: wrong index %d", seed, j)
|
||||
t.Fatalf("seed %d: wrong index %d", seed, j)
|
||||
}
|
||||
|
||||
for _, t := range tst {
|
||||
if !t.alive {
|
||||
filters.Uninstall(t.id)
|
||||
for _, testCase := range tst {
|
||||
if !testCase.alive {
|
||||
filters.Uninstall(testCase.id)
|
||||
}
|
||||
}
|
||||
|
||||
for i, t := range tst {
|
||||
fil := filters.Get(t.id)
|
||||
for i, testCase := range tst {
|
||||
fil := filters.Get(testCase.id)
|
||||
exist := (fil != nil)
|
||||
if exist != t.alive {
|
||||
x.Fatalf("seed %d: failed alive: %d, %v, %v", seed, i, exist, t.alive)
|
||||
if exist != testCase.alive {
|
||||
t.Fatalf("seed %d: failed alive: %d, %v, %v", seed, i, exist, testCase.alive)
|
||||
}
|
||||
if exist && fil.PoW != t.f.PoW {
|
||||
x.Fatalf("seed %d: failed Get: %d, %v, %v", seed, i, exist, t.alive)
|
||||
if exist && fil.PoW != testCase.f.PoW {
|
||||
t.Fatalf("seed %d: failed Get: %d, %v, %v", seed, i, exist, testCase.alive)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestComparePubKey(x *testing.T) {
|
||||
func TestComparePubKey(t *testing.T) {
|
||||
InitSingleTest()
|
||||
|
||||
key1, err := crypto.GenerateKey()
|
||||
if err != nil {
|
||||
x.Fatalf("failed GenerateKey 1 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed to generate first key with seed %d: %s.", seed, err)
|
||||
}
|
||||
key2, err := crypto.GenerateKey()
|
||||
if err != nil {
|
||||
x.Fatalf("failed GenerateKey 2 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed to generate second key with seed %d: %s.", seed, err)
|
||||
}
|
||||
if isPubKeyEqual(&key1.PublicKey, &key2.PublicKey) {
|
||||
x.Fatalf("failed !equal with seed %d.", seed)
|
||||
t.Fatalf("public keys are equal, seed %d.", seed)
|
||||
}
|
||||
|
||||
// generate key3 == key1
|
||||
rand.Seed(seed)
|
||||
key3, err := crypto.GenerateKey()
|
||||
if err != nil {
|
||||
x.Fatalf("failed GenerateKey 3 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed to generate third key with seed %d: %s.", seed, err)
|
||||
}
|
||||
if isPubKeyEqual(&key1.PublicKey, &key3.PublicKey) {
|
||||
x.Fatalf("failed equal with seed %d.", seed)
|
||||
t.Fatalf("key1 == key3, seed %d.", seed)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatchEnvelope(x *testing.T) {
|
||||
func TestMatchEnvelope(t *testing.T) {
|
||||
InitSingleTest()
|
||||
|
||||
fsym, err := generateFilter(x, true)
|
||||
fsym, err := generateFilter(t, true)
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateFilter 1 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateFilter with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
fasym, err := generateFilter(x, false)
|
||||
fasym, err := generateFilter(t, false)
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateFilter 2 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateFilter() with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
params, err := generateMessageParams()
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateMessageParams 3 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
params.Topic[0] = 0xFF // ensure mismatch
|
||||
|
|
@ -178,15 +178,15 @@ func TestMatchEnvelope(x *testing.T) {
|
|||
msg := NewSentMessage(params)
|
||||
env, err := msg.Wrap(params)
|
||||
if err != nil {
|
||||
x.Fatalf("failed Wrap 4 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
}
|
||||
match := fsym.MatchEnvelope(env)
|
||||
if match {
|
||||
x.Fatalf("failed test case 5 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope symmetric with seed %d.", seed)
|
||||
}
|
||||
match = fasym.MatchEnvelope(env)
|
||||
if match {
|
||||
x.Fatalf("failed test case 6 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope asymmetric with seed %d.", seed)
|
||||
}
|
||||
|
||||
// encrypt symmetrically
|
||||
|
|
@ -196,33 +196,33 @@ func TestMatchEnvelope(x *testing.T) {
|
|||
msg = NewSentMessage(params)
|
||||
env, err = msg.Wrap(params)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 7 with seed %d, test case 3: %s.", seed, err)
|
||||
t.Fatalf("failed Wrap() with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
// symmetric + matching topic: match
|
||||
match = fsym.MatchEnvelope(env)
|
||||
if !match {
|
||||
x.Fatalf("failed test case 8 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope() symmetric with seed %d.", seed)
|
||||
}
|
||||
|
||||
// asymmetric + matching topic: mismatch
|
||||
match = fasym.MatchEnvelope(env)
|
||||
if match {
|
||||
x.Fatalf("failed test case 9 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope() asymmetric with seed %d.", seed)
|
||||
}
|
||||
|
||||
// symmetric + matching topic + insufficient PoW: mismatch
|
||||
fsym.PoW = env.PoW() + 1.0
|
||||
match = fsym.MatchEnvelope(env)
|
||||
if match {
|
||||
x.Fatalf("failed test case 10 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(symmetric + matching topic + insufficient PoW) asymmetric with seed %d.", seed)
|
||||
}
|
||||
|
||||
// symmetric + matching topic + sufficient PoW: match
|
||||
fsym.PoW = env.PoW() / 2
|
||||
match = fsym.MatchEnvelope(env)
|
||||
if !match {
|
||||
x.Fatalf("failed test case 11 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(symmetric + matching topic + sufficient PoW) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// symmetric + topics are nil (wildcard): match
|
||||
|
|
@ -230,89 +230,89 @@ func TestMatchEnvelope(x *testing.T) {
|
|||
fsym.Topics = nil
|
||||
match = fsym.MatchEnvelope(env)
|
||||
if !match {
|
||||
x.Fatalf("failed test case 12 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(symmetric + topics are nil) with seed %d.", seed)
|
||||
}
|
||||
fsym.Topics = prevTopics
|
||||
|
||||
// encrypt asymmetrically
|
||||
key, err := crypto.GenerateKey()
|
||||
if err != nil {
|
||||
x.Fatalf("failed GenerateKey 13 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed GenerateKey with seed %d: %s.", seed, err)
|
||||
}
|
||||
params.KeySym = nil
|
||||
params.Dst = &key.PublicKey
|
||||
msg = NewSentMessage(params)
|
||||
env, err = msg.Wrap(params)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 14 with seed %d, test case 3: %s.", seed, err)
|
||||
t.Fatalf("failed Wrap() with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
// encryption method mismatch
|
||||
match = fsym.MatchEnvelope(env)
|
||||
if match {
|
||||
x.Fatalf("failed test case 15 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(encryption method mismatch) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// asymmetric + mismatching topic: mismatch
|
||||
match = fasym.MatchEnvelope(env)
|
||||
if !match {
|
||||
x.Fatalf("failed test case 16 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(asymmetric + mismatching topic) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// asymmetric + matching topic: match
|
||||
fasym.Topics[i] = fasym.Topics[i+1]
|
||||
match = fasym.MatchEnvelope(env)
|
||||
if match {
|
||||
x.Fatalf("failed test case 17 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(asymmetric + matching topic) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// asymmetric + filter without topic (wildcard): match
|
||||
fasym.Topics = nil
|
||||
match = fasym.MatchEnvelope(env)
|
||||
if !match {
|
||||
x.Fatalf("failed test case 18 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(asymmetric + filter without topic) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// asymmetric + insufficient PoW: mismatch
|
||||
fasym.PoW = env.PoW() + 1.0
|
||||
match = fasym.MatchEnvelope(env)
|
||||
if match {
|
||||
x.Fatalf("failed test case 19 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(asymmetric + insufficient PoW) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// asymmetric + sufficient PoW: match
|
||||
fasym.PoW = env.PoW() / 2
|
||||
match = fasym.MatchEnvelope(env)
|
||||
if !match {
|
||||
x.Fatalf("failed test case 20 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(asymmetric + sufficient PoW) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// filter without topic + envelope without topic: match
|
||||
env.Topic = TopicType{}
|
||||
match = fasym.MatchEnvelope(env)
|
||||
if !match {
|
||||
x.Fatalf("failed test case 21 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(filter without topic + envelope without topic) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// filter with topic + envelope without topic: mismatch
|
||||
fasym.Topics = fsym.Topics
|
||||
match = fasym.MatchEnvelope(env)
|
||||
if match {
|
||||
x.Fatalf("failed test case 22 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(filter without topic + envelope without topic) with seed %d.", seed)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatchMessageSym(x *testing.T) {
|
||||
func TestMatchMessageSym(t *testing.T) {
|
||||
InitSingleTest()
|
||||
|
||||
params, err := generateMessageParams()
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
f, err := generateFilter(x, true)
|
||||
f, err := generateFilter(t, true)
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateFilter 1 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateFilter with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
const index = 1
|
||||
|
|
@ -322,91 +322,91 @@ func TestMatchMessageSym(x *testing.T) {
|
|||
sentMessage := NewSentMessage(params)
|
||||
env, err := sentMessage.Wrap(params)
|
||||
if err != nil {
|
||||
x.Fatalf("failed Wrap 2 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
msg := env.Open(f)
|
||||
if msg == nil {
|
||||
x.Fatalf("failed to open 3 with seed %d.", seed)
|
||||
t.Fatalf("failed Open with seed %d.", seed)
|
||||
}
|
||||
|
||||
// Src mismatch
|
||||
if f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 4 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchMessage(src mismatch) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// Src: match
|
||||
*f.Src.X = *params.Src.PublicKey.X
|
||||
*f.Src.Y = *params.Src.PublicKey.Y
|
||||
if !f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 5 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(src match) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// insufficient PoW: mismatch
|
||||
f.PoW = msg.PoW + 1.0
|
||||
if f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 6 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(insufficient PoW) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// sufficient PoW: match
|
||||
f.PoW = msg.PoW / 2
|
||||
if !f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 7 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(sufficient PoW) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// topic mismatch
|
||||
f.Topics[index][0]++
|
||||
if f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 8 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(topic mismatch) with seed %d.", seed)
|
||||
}
|
||||
f.Topics[index][0]--
|
||||
|
||||
// key mismatch
|
||||
f.SymKeyHash[0]++
|
||||
if f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 9 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(key mismatch) with seed %d.", seed)
|
||||
}
|
||||
f.SymKeyHash[0]--
|
||||
|
||||
// Src absent: match
|
||||
f.Src = nil
|
||||
if !f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 10 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(src absent) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// key hash mismatch mismatch
|
||||
// key hash mismatch
|
||||
h := f.SymKeyHash
|
||||
f.SymKeyHash = common.Hash{}
|
||||
if f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 11 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(key hash mismatch) with seed %d.", seed)
|
||||
}
|
||||
f.SymKeyHash = h
|
||||
if !f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 12 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(key hash match) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// encryption method mismatch
|
||||
f.KeySym = nil
|
||||
f.KeyAsym, err = crypto.GenerateKey()
|
||||
if err != nil {
|
||||
x.Fatalf("failed GenerateKey 13 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed GenerateKey with seed %d: %s.", seed, err)
|
||||
}
|
||||
if f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 14 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(encryption method mismatch) with seed %d.", seed)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatchMessageAsym(x *testing.T) {
|
||||
func TestMatchMessageAsym(t *testing.T) {
|
||||
InitSingleTest()
|
||||
|
||||
f, err := generateFilter(x, false)
|
||||
f, err := generateFilter(t, false)
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateFilter with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateFilter with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
params, err := generateMessageParams()
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
const index = 1
|
||||
|
|
@ -418,42 +418,42 @@ func TestMatchMessageAsym(x *testing.T) {
|
|||
sentMessage := NewSentMessage(params)
|
||||
env, err := sentMessage.Wrap(params)
|
||||
if err != nil {
|
||||
x.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
msg := env.Open(f)
|
||||
if msg == nil {
|
||||
x.Fatalf("failed to open with seed %d.", seed)
|
||||
t.Fatalf("failed to open with seed %d.", seed)
|
||||
}
|
||||
|
||||
// Src mismatch
|
||||
if f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 4 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchMessage(src mismatch) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// Src: match
|
||||
*f.Src.X = *params.Src.PublicKey.X
|
||||
*f.Src.Y = *params.Src.PublicKey.Y
|
||||
if !f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 5 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchMessage(src match) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// insufficient PoW: mismatch
|
||||
f.PoW = msg.PoW + 1.0
|
||||
if f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 6 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(insufficient PoW) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// sufficient PoW: match
|
||||
f.PoW = msg.PoW / 2
|
||||
if !f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 7 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(sufficient PoW) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// topic mismatch
|
||||
f.Topics[index][0]++
|
||||
if f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 8 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(topic mismatch) with seed %d.", seed)
|
||||
}
|
||||
f.Topics[index][0]--
|
||||
|
||||
|
|
@ -462,21 +462,21 @@ func TestMatchMessageAsym(x *testing.T) {
|
|||
zero := *big.NewInt(0)
|
||||
*f.KeyAsym.PublicKey.X = zero
|
||||
if f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 9 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(key mismatch) with seed %d.", seed)
|
||||
}
|
||||
*f.KeyAsym.PublicKey.X = prev
|
||||
|
||||
// Src absent: match
|
||||
f.Src = nil
|
||||
if !f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 10 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(src absent) with seed %d.", seed)
|
||||
}
|
||||
|
||||
// encryption method mismatch
|
||||
f.KeySym = keySymOrig
|
||||
f.KeyAsym = nil
|
||||
if f.MatchMessage(msg) {
|
||||
x.Fatalf("failed test case 11 with seed %d.", seed)
|
||||
t.Fatalf("failed MatchEnvelope(encryption method mismatch) with seed %d.", seed)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -493,10 +493,10 @@ func cloneFilter(orig *Filter) *Filter {
|
|||
return &clone
|
||||
}
|
||||
|
||||
func generateCompatibeEnvelope(x *testing.T, f *Filter) *Envelope {
|
||||
func generateCompatibeEnvelope(t *testing.T, f *Filter) *Envelope {
|
||||
params, err := generateMessageParams()
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateMessageParams 77 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -505,13 +505,13 @@ func generateCompatibeEnvelope(x *testing.T, f *Filter) *Envelope {
|
|||
sentMessage := NewSentMessage(params)
|
||||
env, err := sentMessage.Wrap(params)
|
||||
if err != nil {
|
||||
x.Fatalf("failed Wrap 78 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
return nil
|
||||
}
|
||||
return env
|
||||
}
|
||||
|
||||
func TestWatchers(x *testing.T) {
|
||||
func TestWatchers(t *testing.T) {
|
||||
InitSingleTest()
|
||||
|
||||
const NumFilters = 16
|
||||
|
|
@ -522,7 +522,7 @@ func TestWatchers(x *testing.T) {
|
|||
|
||||
w := NewWhisper(nil)
|
||||
filters := NewFilters(w)
|
||||
tst := generateTestCases(x, NumFilters)
|
||||
tst := generateTestCases(t, NumFilters)
|
||||
for i = 0; i < NumFilters; i++ {
|
||||
tst[i].f.Src = nil
|
||||
j = filters.Install(tst[i].f)
|
||||
|
|
@ -534,7 +534,7 @@ func TestWatchers(x *testing.T) {
|
|||
var envelopes [NumMessages]*Envelope
|
||||
for i = 0; i < NumMessages; i++ {
|
||||
j = rand.Uint32() % NumFilters
|
||||
e = generateCompatibeEnvelope(x, tst[j].f)
|
||||
e = generateCompatibeEnvelope(t, tst[j].f)
|
||||
envelopes[i] = e
|
||||
tst[j].msgCnt++
|
||||
}
|
||||
|
|
@ -554,17 +554,17 @@ func TestWatchers(x *testing.T) {
|
|||
}
|
||||
|
||||
if total != NumMessages {
|
||||
x.Fatalf("failed test case 1 with seed %d: total = %d, want: %d.", seed, total, NumMessages)
|
||||
t.Fatalf("failed with seed %d: total = %d, want: %d.", seed, total, NumMessages)
|
||||
}
|
||||
|
||||
for i = 0; i < NumFilters; i++ {
|
||||
mail = tst[i].f.Retrieve()
|
||||
if len(mail) != 0 {
|
||||
x.Fatalf("failed test case 2 with seed %d: i = %d.", seed, i)
|
||||
t.Fatalf("failed with seed %d: i = %d.", seed, i)
|
||||
}
|
||||
|
||||
if tst[i].msgCnt != count[i] {
|
||||
x.Fatalf("failed test case 3 with seed %d: i = %d, get %d, want %d.", seed, i, tst[i].msgCnt, count[i])
|
||||
t.Fatalf("failed with seed %d: count[%d]: get %d, want %d.", seed, i, tst[i].msgCnt, count[i])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -582,12 +582,12 @@ func TestWatchers(x *testing.T) {
|
|||
}
|
||||
|
||||
// make sure that the first watcher receives at least one message
|
||||
e = generateCompatibeEnvelope(x, tst[0].f)
|
||||
e = generateCompatibeEnvelope(t, tst[0].f)
|
||||
envelopes[0] = e
|
||||
tst[0].msgCnt++
|
||||
for i = 1; i < NumMessages; i++ {
|
||||
j = rand.Uint32() % NumFilters
|
||||
e = generateCompatibeEnvelope(x, tst[j].f)
|
||||
e = generateCompatibeEnvelope(t, tst[j].f)
|
||||
envelopes[i] = e
|
||||
tst[j].msgCnt++
|
||||
}
|
||||
|
|
@ -604,25 +604,25 @@ func TestWatchers(x *testing.T) {
|
|||
|
||||
combined := tst[0].msgCnt + tst[last].msgCnt
|
||||
if total != NumMessages+count[0] {
|
||||
x.Fatalf("failed test case 4 with seed %d: total = %d, count[0] = %d.", seed, total, count[0])
|
||||
t.Fatalf("failed with seed %d: total = %d, count[0] = %d.", seed, total, count[0])
|
||||
}
|
||||
|
||||
if combined != count[0] {
|
||||
x.Fatalf("failed test case 5 with seed %d: combined = %d, count[0] = %d.", seed, combined, count[0])
|
||||
t.Fatalf("failed with seed %d: combined = %d, count[0] = %d.", seed, combined, count[0])
|
||||
}
|
||||
|
||||
if combined != count[last] {
|
||||
x.Fatalf("failed test case 6 with seed %d: combined = %d, count[last] = %d.", seed, combined, count[last])
|
||||
t.Fatalf("failed with seed %d: combined = %d, count[last] = %d.", seed, combined, count[last])
|
||||
}
|
||||
|
||||
for i = 1; i < NumFilters-1; i++ {
|
||||
mail = tst[i].f.Retrieve()
|
||||
if len(mail) != 0 {
|
||||
x.Fatalf("failed test case 7 with seed %d: i = %d.", seed, i)
|
||||
t.Fatalf("failed with seed %d: i = %d.", seed, i)
|
||||
}
|
||||
|
||||
if tst[i].msgCnt != count[i] {
|
||||
x.Fatalf("failed test case 8 with seed %d: i = %d, get %d, want %d.", seed, i, tst[i].msgCnt, count[i])
|
||||
t.Fatalf("failed with seed %d: i = %d, get %d, want %d.", seed, i, tst[i].msgCnt, count[i])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -637,12 +637,12 @@ func TestWatchers(x *testing.T) {
|
|||
}
|
||||
|
||||
if total != 0 {
|
||||
x.Fatalf("failed test case 9 with seed %d.", seed)
|
||||
t.Fatalf("failed with seed %d: total: got %d, want 0.", seed, total)
|
||||
}
|
||||
|
||||
f := filters.Get(1)
|
||||
if f == nil {
|
||||
x.Fatalf("failed to get the filter with seed %d.", seed)
|
||||
t.Fatalf("failed to get the filter with seed %d.", seed)
|
||||
}
|
||||
f.AcceptP2P = true
|
||||
total = 0
|
||||
|
|
@ -654,6 +654,6 @@ func TestWatchers(x *testing.T) {
|
|||
}
|
||||
|
||||
if total != 1 {
|
||||
x.Fatalf("failed test case 10 with seed %d: total = %d.", seed, total)
|
||||
t.Fatalf("failed with seed %d: total: got %d, want 1.", seed, total)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,15 +57,15 @@ func generateMessageParams() (*MessageParams, error) {
|
|||
return &p, nil
|
||||
}
|
||||
|
||||
func singleMessageTest(x *testing.T, symmetric bool) {
|
||||
func singleMessageTest(t *testing.T, symmetric bool) {
|
||||
params, err := generateMessageParams()
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
key, err := crypto.GenerateKey()
|
||||
if err != nil {
|
||||
x.Fatalf("failed GenerateKey with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed GenerateKey with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
if !symmetric {
|
||||
|
|
@ -83,7 +83,7 @@ func singleMessageTest(x *testing.T, symmetric bool) {
|
|||
msg := NewSentMessage(params)
|
||||
env, err := msg.Wrap(params)
|
||||
if err != nil {
|
||||
x.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
var decrypted *ReceivedMessage
|
||||
|
|
@ -94,49 +94,49 @@ func singleMessageTest(x *testing.T, symmetric bool) {
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
x.Fatalf("failed to encrypt with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed to encrypt with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
if !decrypted.Validate() {
|
||||
x.Fatalf("failed to validate with seed %d.", seed)
|
||||
t.Fatalf("failed to validate with seed %d.", seed)
|
||||
}
|
||||
|
||||
padsz := len(decrypted.Padding)
|
||||
if bytes.Compare(steg[:padsz], decrypted.Padding) != 0 {
|
||||
x.Fatalf("failed with seed %d: compare padding.", seed)
|
||||
t.Fatalf("failed with seed %d: compare padding.", seed)
|
||||
}
|
||||
if bytes.Compare(text, decrypted.Payload) != 0 {
|
||||
x.Fatalf("failed with seed %d: compare payload.", seed)
|
||||
t.Fatalf("failed with seed %d: compare payload.", seed)
|
||||
}
|
||||
if !isMessageSigned(decrypted.Raw[0]) {
|
||||
x.Fatalf("failed with seed %d: unsigned.", seed)
|
||||
t.Fatalf("failed with seed %d: unsigned.", seed)
|
||||
}
|
||||
if len(decrypted.Signature) != signatureLength {
|
||||
x.Fatalf("failed with seed %d: signature len %d.", seed, len(decrypted.Signature))
|
||||
t.Fatalf("failed with seed %d: signature len %d.", seed, len(decrypted.Signature))
|
||||
}
|
||||
if !isPubKeyEqual(decrypted.Src, ¶ms.Src.PublicKey) {
|
||||
x.Fatalf("failed with seed %d: signature mismatch.", seed)
|
||||
t.Fatalf("failed with seed %d: signature mismatch.", seed)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMessageEncryption(x *testing.T) {
|
||||
func TestMessageEncryption(t *testing.T) {
|
||||
InitSingleTest()
|
||||
|
||||
var symmetric bool
|
||||
for i := 0; i < 256; i++ {
|
||||
singleMessageTest(x, symmetric)
|
||||
singleMessageTest(t, symmetric)
|
||||
symmetric = !symmetric
|
||||
}
|
||||
}
|
||||
|
||||
func TestMessageWrap(x *testing.T) {
|
||||
func TestMessageWrap(t *testing.T) {
|
||||
seed = int64(1777444222)
|
||||
rand.Seed(seed)
|
||||
target := 128.0
|
||||
|
||||
params, err := generateMessageParams()
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
msg := NewSentMessage(params)
|
||||
|
|
@ -145,23 +145,23 @@ func TestMessageWrap(x *testing.T) {
|
|||
params.PoW = target
|
||||
env, err := msg.Wrap(params)
|
||||
if err != nil {
|
||||
x.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
pow := env.PoW()
|
||||
if pow < target {
|
||||
x.Fatalf("failed Wrap with seed %d: pow < target (%f vs. %f).", seed, pow, target)
|
||||
t.Fatalf("failed Wrap with seed %d: pow < target (%f vs. %f).", seed, pow, target)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMessageSeal(x *testing.T) {
|
||||
func TestMessageSeal(t *testing.T) {
|
||||
// this test depends on deterministic choice of seed (1976726903)
|
||||
seed = int64(1976726903)
|
||||
rand.Seed(seed)
|
||||
|
||||
params, err := generateMessageParams()
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
msg := NewSentMessage(params)
|
||||
|
|
@ -173,7 +173,7 @@ func TestMessageSeal(x *testing.T) {
|
|||
|
||||
env := NewEnvelope(params.TTL, params.Topic, salt, aesnonce, msg)
|
||||
if err != nil {
|
||||
x.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
env.Expiry = uint32(seed) // make it deterministic
|
||||
|
|
@ -185,7 +185,7 @@ func TestMessageSeal(x *testing.T) {
|
|||
env.calculatePoW(0)
|
||||
pow := env.PoW()
|
||||
if pow < target {
|
||||
x.Fatalf("failed Wrap with seed %d: pow < target (%f vs. %f).", seed, pow, target)
|
||||
t.Fatalf("failed Wrap with seed %d: pow < target (%f vs. %f).", seed, pow, target)
|
||||
}
|
||||
|
||||
params.WorkTime = 1
|
||||
|
|
@ -194,29 +194,29 @@ func TestMessageSeal(x *testing.T) {
|
|||
env.calculatePoW(0)
|
||||
pow = env.PoW()
|
||||
if pow < 2*target {
|
||||
x.Fatalf("failed Wrap with seed %d: pow too small %f.", seed, pow)
|
||||
t.Fatalf("failed Wrap with seed %d: pow too small %f.", seed, pow)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnvelopeOpen(x *testing.T) {
|
||||
func TestEnvelopeOpen(t *testing.T) {
|
||||
InitSingleTest()
|
||||
|
||||
var symmetric bool
|
||||
for i := 0; i < 256; i++ {
|
||||
singleEnvelopeOpenTest(x, symmetric)
|
||||
singleEnvelopeOpenTest(t, symmetric)
|
||||
symmetric = !symmetric
|
||||
}
|
||||
}
|
||||
|
||||
func singleEnvelopeOpenTest(x *testing.T, symmetric bool) {
|
||||
func singleEnvelopeOpenTest(t *testing.T, symmetric bool) {
|
||||
params, err := generateMessageParams()
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
key, err := crypto.GenerateKey()
|
||||
if err != nil {
|
||||
x.Fatalf("failed GenerateKey with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed GenerateKey with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
if !symmetric {
|
||||
|
|
@ -234,43 +234,43 @@ func singleEnvelopeOpenTest(x *testing.T, symmetric bool) {
|
|||
msg := NewSentMessage(params)
|
||||
env, err := msg.Wrap(params)
|
||||
if err != nil {
|
||||
x.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed Wrap with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
f := Filter{KeyAsym: key, KeySym: params.KeySym}
|
||||
decrypted := env.Open(&f)
|
||||
if decrypted == nil {
|
||||
x.Fatalf("failed to open with seed %d.", seed)
|
||||
t.Fatalf("failed to open with seed %d.", seed)
|
||||
}
|
||||
|
||||
padsz := len(decrypted.Padding)
|
||||
if bytes.Compare(steg[:padsz], decrypted.Padding) != 0 {
|
||||
x.Fatalf("failed with seed %d: compare padding.", seed)
|
||||
t.Fatalf("failed with seed %d: compare padding.", seed)
|
||||
}
|
||||
if bytes.Compare(text, decrypted.Payload) != 0 {
|
||||
x.Fatalf("failed with seed %d: compare payload.", seed)
|
||||
t.Fatalf("failed with seed %d: compare payload.", seed)
|
||||
}
|
||||
if !isMessageSigned(decrypted.Raw[0]) {
|
||||
x.Fatalf("failed with seed %d: unsigned.", seed)
|
||||
t.Fatalf("failed with seed %d: unsigned.", seed)
|
||||
}
|
||||
if len(decrypted.Signature) != signatureLength {
|
||||
x.Fatalf("failed with seed %d: signature len %d.", seed, len(decrypted.Signature))
|
||||
t.Fatalf("failed with seed %d: signature len %d.", seed, len(decrypted.Signature))
|
||||
}
|
||||
if !isPubKeyEqual(decrypted.Src, ¶ms.Src.PublicKey) {
|
||||
x.Fatalf("failed with seed %d: signature mismatch.", seed)
|
||||
t.Fatalf("failed with seed %d: signature mismatch.", seed)
|
||||
}
|
||||
if decrypted.isAsymmetricEncryption() == symmetric {
|
||||
x.Fatalf("failed with seed %d: asymmetric %v vs. %v.", seed, decrypted.isAsymmetricEncryption(), symmetric)
|
||||
t.Fatalf("failed with seed %d: asymmetric %v vs. %v.", seed, decrypted.isAsymmetricEncryption(), symmetric)
|
||||
}
|
||||
if decrypted.isSymmetricEncryption() != symmetric {
|
||||
x.Fatalf("failed with seed %d: symmetric %v vs. %v.", seed, decrypted.isSymmetricEncryption(), symmetric)
|
||||
t.Fatalf("failed with seed %d: symmetric %v vs. %v.", seed, decrypted.isSymmetricEncryption(), symmetric)
|
||||
}
|
||||
if !symmetric {
|
||||
if decrypted.Dst == nil {
|
||||
x.Fatalf("failed with seed %d: dst is nil.", seed)
|
||||
t.Fatalf("failed with seed %d: dst is nil.", seed)
|
||||
}
|
||||
if !isPubKeyEqual(decrypted.Dst, &key.PublicKey) {
|
||||
x.Fatalf("failed with seed %d: Dst.", seed)
|
||||
t.Fatalf("failed with seed %d: Dst.", seed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,19 +94,19 @@ var expectedMessage []byte = []byte("per rectum ad astra")
|
|||
// 3. each node sends a number of random (undecryptable) messages,
|
||||
// 4. first node sends one expected (decryptable) message,
|
||||
// 5. checks if each node have received and decrypted exactly one message.
|
||||
func TestSimulation(x *testing.T) {
|
||||
initialize(x)
|
||||
func TestSimulation(t *testing.T) {
|
||||
initialize(t)
|
||||
|
||||
for i := 0; i < NumNodes; i++ {
|
||||
sendMsg(x, false, i)
|
||||
sendMsg(t, false, i)
|
||||
}
|
||||
|
||||
sendMsg(x, true, 0)
|
||||
checkPropagation(x)
|
||||
sendMsg(t, true, 0)
|
||||
checkPropagation(t)
|
||||
stopServers()
|
||||
}
|
||||
|
||||
func initialize(x *testing.T) {
|
||||
func initialize(t *testing.T) {
|
||||
//glog.SetV(6)
|
||||
//glog.SetToStderr(true)
|
||||
|
||||
|
|
@ -118,13 +118,13 @@ func initialize(x *testing.T) {
|
|||
var node TestNode
|
||||
node.shh = NewWhisper(nil)
|
||||
node.shh.test = true
|
||||
tt := make([]TopicType, 0)
|
||||
tt = append(tt, sharedTopic)
|
||||
f := Filter{KeySym: sharedKey, Topics: tt}
|
||||
topics := make([]TopicType, 0)
|
||||
topics = append(topics, sharedTopic)
|
||||
f := Filter{KeySym: sharedKey, Topics: topics}
|
||||
node.filerId = node.shh.Watch(&f)
|
||||
node.id, err = crypto.HexToECDSA(keys[i])
|
||||
if err != nil {
|
||||
x.Fatalf("failed convert the key: %s.", keys[i])
|
||||
t.Fatalf("failed convert the key: %s.", keys[i])
|
||||
}
|
||||
port := port0 + i
|
||||
addr := fmt.Sprintf(":%d", port) // e.g. ":30303"
|
||||
|
|
@ -154,7 +154,7 @@ func initialize(x *testing.T) {
|
|||
|
||||
err = node.server.Start()
|
||||
if err != nil {
|
||||
x.Fatalf("failed to start server %d.", i)
|
||||
t.Fatalf("failed to start server %d.", i)
|
||||
}
|
||||
|
||||
nodes[i] = &node
|
||||
|
|
@ -171,8 +171,8 @@ func stopServers() {
|
|||
}
|
||||
}
|
||||
|
||||
func checkPropagation(x *testing.T) {
|
||||
if x.Failed() {
|
||||
func checkPropagation(t *testing.T) {
|
||||
if t.Failed() {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -185,11 +185,11 @@ func checkPropagation(x *testing.T) {
|
|||
for i := 0; i < NumNodes; i++ {
|
||||
f := nodes[i].shh.GetFilter(nodes[i].filerId)
|
||||
if f == nil {
|
||||
x.Fatalf("failed to get filterId %d from node %d.", nodes[i].filerId, i)
|
||||
t.Fatalf("failed to get filterId %d from node %d.", nodes[i].filerId, i)
|
||||
}
|
||||
|
||||
mail := f.Retrieve()
|
||||
if !validateMail(x, i, mail) {
|
||||
if !validateMail(t, i, mail) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -199,10 +199,10 @@ func checkPropagation(x *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
x.Fatalf("Test was not complete: timeout %d seconds.", iterations*cycle/1000)
|
||||
t.Fatalf("Test was not complete: timeout %d seconds.", iterations*cycle/1000)
|
||||
}
|
||||
|
||||
func validateMail(x *testing.T, index int, mail []*ReceivedMessage) bool {
|
||||
func validateMail(t *testing.T, index int, mail []*ReceivedMessage) bool {
|
||||
var cnt int
|
||||
for _, m := range mail {
|
||||
if bytes.Compare(m.Payload, expectedMessage) == 0 {
|
||||
|
|
@ -215,7 +215,7 @@ func validateMail(x *testing.T, index int, mail []*ReceivedMessage) bool {
|
|||
return true
|
||||
}
|
||||
if cnt > 1 {
|
||||
x.Fatalf("node %d received %d.", index, cnt)
|
||||
t.Fatalf("node %d received %d.", index, cnt)
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ func validateMail(x *testing.T, index int, mail []*ReceivedMessage) bool {
|
|||
defer result.mutex.Unlock()
|
||||
result.counter[index] += cnt
|
||||
if result.counter[index] > 1 {
|
||||
x.Fatalf("node %d accumulated %d.", index, result.counter[index])
|
||||
t.Fatalf("node %d accumulated %d.", index, result.counter[index])
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
|
@ -250,8 +250,8 @@ func isTestComplete() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func sendMsg(x *testing.T, expected bool, id int) {
|
||||
if x.Failed() {
|
||||
func sendMsg(t *testing.T, expected bool, id int) {
|
||||
if t.Failed() {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -265,33 +265,33 @@ func sendMsg(x *testing.T, expected bool, id int) {
|
|||
msg := NewSentMessage(&opt)
|
||||
envelope, err := msg.Wrap(&opt)
|
||||
if err != nil {
|
||||
x.Fatalf("failed to seal message.")
|
||||
t.Fatalf("failed to seal message.")
|
||||
}
|
||||
|
||||
err = nodes[id].shh.Send(envelope)
|
||||
if err != nil {
|
||||
x.Fatalf("failed to send message.")
|
||||
t.Fatalf("failed to send message.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPeerBasic(x *testing.T) {
|
||||
func TestPeerBasic(t *testing.T) {
|
||||
InitSingleTest()
|
||||
|
||||
params, err := generateMessageParams()
|
||||
if err != nil {
|
||||
x.Fatalf("failed generateMessageParams with seed %d.", seed)
|
||||
t.Fatalf("failed generateMessageParams with seed %d.", seed)
|
||||
}
|
||||
|
||||
params.PoW = 0.001
|
||||
msg := NewSentMessage(params)
|
||||
env, err := msg.Wrap(params)
|
||||
if err != nil {
|
||||
x.Fatalf("failed Wrap with seed %d.", seed)
|
||||
t.Fatalf("failed Wrap with seed %d.", seed)
|
||||
}
|
||||
|
||||
p := newPeer(nil, nil, nil)
|
||||
p.mark(env)
|
||||
if !p.marked(env) {
|
||||
x.Fatalf("failed mark with seed %d.", seed)
|
||||
t.Fatalf("failed mark with seed %d.", seed)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ var topicStringTests = []struct {
|
|||
{topic: TopicType{0xf2, 0x6e, 0x77, 0x79}, str: "0xf26e7779"},
|
||||
}
|
||||
|
||||
func TestTopicString(x *testing.T) {
|
||||
func TestTopicString(t *testing.T) {
|
||||
for i, tst := range topicStringTests {
|
||||
s := tst.topic.String()
|
||||
if s != tst.str {
|
||||
x.Fatalf("failed test %d: have %s, want %s.", i, s, tst.str)
|
||||
t.Fatalf("failed test %d: have %s, want %s.", i, s, tst.str)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -53,11 +53,11 @@ var bytesToTopicTests = []struct {
|
|||
{topic: TopicType{0x00, 0x00, 0x00, 0x00}, data: nil},
|
||||
}
|
||||
|
||||
func TestBytesToTopic(x *testing.T) {
|
||||
func TestBytesToTopic(t *testing.T) {
|
||||
for i, tst := range bytesToTopicTests {
|
||||
t := BytesToTopic(tst.data)
|
||||
if t != tst.topic {
|
||||
x.Fatalf("failed test %d: have %v, want %v.", i, t, tst.topic)
|
||||
top := BytesToTopic(tst.data)
|
||||
if top != tst.topic {
|
||||
t.Fatalf("failed test %d: have %v, want %v.", i, t, tst.topic)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -99,38 +99,38 @@ var unmarshalTestsUgly = []struct {
|
|||
{topic: TopicType{0x01, 0x00, 0x00, 0x00}, data: []byte("00000001")},
|
||||
}
|
||||
|
||||
func TestUnmarshalTestsGood(x *testing.T) {
|
||||
func TestUnmarshalTestsGood(t *testing.T) {
|
||||
for i, tst := range unmarshalTestsGood {
|
||||
var t TopicType
|
||||
err := t.UnmarshalJSON(tst.data)
|
||||
var top TopicType
|
||||
err := top.UnmarshalJSON(tst.data)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test %d. input: %v.", i, tst.data)
|
||||
} else if t != tst.topic {
|
||||
x.Fatalf("failed test %d: have %v, want %v.", i, t, tst.topic)
|
||||
t.Fatalf("failed test %d. input: %v.", i, tst.data)
|
||||
} else if top != tst.topic {
|
||||
t.Fatalf("failed test %d: have %v, want %v.", i, t, tst.topic)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnmarshalTestsBad(x *testing.T) {
|
||||
func TestUnmarshalTestsBad(t *testing.T) {
|
||||
// in this test UnmarshalJSON() is supposed to fail
|
||||
for i, tst := range unmarshalTestsBad {
|
||||
var t TopicType
|
||||
err := t.UnmarshalJSON(tst.data)
|
||||
var top TopicType
|
||||
err := top.UnmarshalJSON(tst.data)
|
||||
if err == nil {
|
||||
x.Fatalf("failed test %d. input: %v.", i, tst.data)
|
||||
t.Fatalf("failed test %d. input: %v.", i, tst.data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnmarshalTestsUgly(x *testing.T) {
|
||||
func TestUnmarshalTestsUgly(t *testing.T) {
|
||||
// in this test UnmarshalJSON() is NOT supposed to fail, but result should be wrong
|
||||
for i, tst := range unmarshalTestsUgly {
|
||||
var t TopicType
|
||||
err := t.UnmarshalJSON(tst.data)
|
||||
var top TopicType
|
||||
err := top.UnmarshalJSON(tst.data)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test %d. input: %v.", i, tst.data)
|
||||
} else if t == tst.topic {
|
||||
x.Fatalf("failed test %d: have %v, want %v.", i, t, tst.topic)
|
||||
t.Fatalf("failed test %d. input: %v.", i, tst.data)
|
||||
} else if top == tst.topic {
|
||||
t.Fatalf("failed test %d: have %v, want %v.", i, top, tst.topic)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,101 +24,101 @@ import (
|
|||
"github.com/ethereum/go-ethereum/crypto"
|
||||
)
|
||||
|
||||
func TestWhisperBasic(x *testing.T) {
|
||||
func TestWhisperBasic(t *testing.T) {
|
||||
w := NewWhisper(nil)
|
||||
p := w.Protocols()
|
||||
shh := p[0]
|
||||
if shh.Name != ProtocolName {
|
||||
x.Fatalf("failed Protocol Name: %v.", shh.Name)
|
||||
t.Fatalf("failed Protocol Name: %v.", shh.Name)
|
||||
}
|
||||
if uint64(shh.Version) != ProtocolVersion {
|
||||
x.Fatalf("failed Protocol Version: %v.", shh.Version)
|
||||
t.Fatalf("failed Protocol Version: %v.", shh.Version)
|
||||
}
|
||||
if shh.Length != NumberOfMessageCodes {
|
||||
x.Fatalf("failed Protocol Length: %v.", shh.Length)
|
||||
t.Fatalf("failed Protocol Length: %v.", shh.Length)
|
||||
}
|
||||
if shh.Run == nil {
|
||||
x.Fatalf("failed shh.Run.")
|
||||
t.Fatalf("failed shh.Run.")
|
||||
}
|
||||
if uint64(w.Version()) != ProtocolVersion {
|
||||
x.Fatalf("failed whisper Version: %v.", shh.Version)
|
||||
t.Fatalf("failed whisper Version: %v.", shh.Version)
|
||||
}
|
||||
if w.GetFilter(0) != nil {
|
||||
x.Fatalf("failed GetFilter.")
|
||||
t.Fatalf("failed GetFilter.")
|
||||
}
|
||||
|
||||
peerID := make([]byte, 64)
|
||||
randomize(peerID)
|
||||
peer, err := w.getPeer(peerID)
|
||||
if peer != nil {
|
||||
x.Fatalf("failed GetPeer.")
|
||||
t.Fatalf("failed GetPeer.")
|
||||
}
|
||||
err = w.MarkPeerTrusted(peerID)
|
||||
if err == nil {
|
||||
x.Fatalf("failed MarkPeerTrusted.")
|
||||
t.Fatalf("failed MarkPeerTrusted.")
|
||||
}
|
||||
err = w.RequestHistoricMessages(peerID, peerID)
|
||||
if err == nil {
|
||||
x.Fatalf("failed RequestHistoricMessages.")
|
||||
t.Fatalf("failed RequestHistoricMessages.")
|
||||
}
|
||||
err = w.SendP2PMessage(peerID, nil)
|
||||
if err == nil {
|
||||
x.Fatalf("failed SendP2PMessage.")
|
||||
t.Fatalf("failed SendP2PMessage.")
|
||||
}
|
||||
exist := w.HasSymKey("non-existing")
|
||||
if exist {
|
||||
x.Fatalf("failed HasSymKey.")
|
||||
t.Fatalf("failed HasSymKey.")
|
||||
}
|
||||
key := w.GetSymKey("non-existing")
|
||||
if key != nil {
|
||||
x.Fatalf("failed GetSymKey.")
|
||||
t.Fatalf("failed GetSymKey.")
|
||||
}
|
||||
mail := w.Envelopes()
|
||||
if len(mail) != 0 {
|
||||
x.Fatalf("failed w.Envelopes().")
|
||||
t.Fatalf("failed w.Envelopes().")
|
||||
}
|
||||
m := w.Messages(0)
|
||||
if len(m) != 0 {
|
||||
x.Fatalf("failed w.Messages.")
|
||||
t.Fatalf("failed w.Messages.")
|
||||
}
|
||||
|
||||
var derived []byte
|
||||
ver := uint64(0xDEADBEEF)
|
||||
derived, err = deriveKeyMaterial(peerID, ver)
|
||||
if err != unknownVersionError(ver) {
|
||||
x.Fatalf("failed deriveKeyMaterial test case 1 with param = %v: %s.", peerID, err)
|
||||
t.Fatalf("failed deriveKeyMaterial with param = %v: %s.", peerID, err)
|
||||
}
|
||||
derived, err = deriveKeyMaterial(peerID, 0)
|
||||
if err != nil {
|
||||
x.Fatalf("failed deriveKeyMaterial test case 2 with param = %v: %s.", peerID, err)
|
||||
t.Fatalf("failed second deriveKeyMaterial with param = %v: %s.", peerID, err)
|
||||
}
|
||||
if !validateSymmetricKey(derived) {
|
||||
x.Fatalf("failed validateSymmetricKey with param = %v.", derived)
|
||||
t.Fatalf("failed validateSymmetricKey with param = %v.", derived)
|
||||
}
|
||||
if containsOnlyZeros(derived) {
|
||||
x.Fatalf("failed containsOnlyZeros with param = %v.", derived)
|
||||
t.Fatalf("failed containsOnlyZeros with param = %v.", derived)
|
||||
}
|
||||
|
||||
buf := []byte{0xFF, 0xE5, 0x80, 0x2, 0}
|
||||
le := bytesToIntLittleEndian(buf)
|
||||
be := BytesToIntBigEndian(buf)
|
||||
if le != uint64(0x280e5ff) {
|
||||
x.Fatalf("failed bytesToIntLittleEndian: %d.", le)
|
||||
t.Fatalf("failed bytesToIntLittleEndian: %d.", le)
|
||||
}
|
||||
if be != uint64(0xffe5800200) {
|
||||
x.Fatalf("failed BytesToIntBigEndian: %d.", be)
|
||||
t.Fatalf("failed BytesToIntBigEndian: %d.", be)
|
||||
}
|
||||
|
||||
pk := w.NewIdentity()
|
||||
if !validatePrivateKey(pk) {
|
||||
x.Fatalf("failed validatePrivateKey: %v.", pk)
|
||||
t.Fatalf("failed validatePrivateKey: %v.", pk)
|
||||
}
|
||||
if !ValidatePublicKey(&pk.PublicKey) {
|
||||
x.Fatalf("failed ValidatePublicKey: %v.", pk)
|
||||
t.Fatalf("failed ValidatePublicKey: %v.", pk)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWhisperIdentityManagement(x *testing.T) {
|
||||
func TestWhisperIdentityManagement(t *testing.T) {
|
||||
w := NewWhisper(nil)
|
||||
id1 := w.NewIdentity()
|
||||
id2 := w.NewIdentity()
|
||||
|
|
@ -127,16 +127,16 @@ func TestWhisperIdentityManagement(x *testing.T) {
|
|||
pk1 := w.GetIdentity(pub1)
|
||||
pk2 := w.GetIdentity(pub2)
|
||||
if !w.HasIdentity(pub1) {
|
||||
x.Fatalf("failed test case 1.")
|
||||
t.Fatalf("failed HasIdentity(pub1).")
|
||||
}
|
||||
if !w.HasIdentity(pub2) {
|
||||
x.Fatalf("failed test case 2.")
|
||||
t.Fatalf("failed HasIdentity(pub2).")
|
||||
}
|
||||
if pk1 != id1 {
|
||||
x.Fatalf("failed test case 3.")
|
||||
t.Fatalf("failed GetIdentity(pub1).")
|
||||
}
|
||||
if pk2 != id2 {
|
||||
x.Fatalf("failed test case 4.")
|
||||
t.Fatalf("failed GetIdentity(pub2).")
|
||||
}
|
||||
|
||||
// Delete one identity
|
||||
|
|
@ -144,16 +144,16 @@ func TestWhisperIdentityManagement(x *testing.T) {
|
|||
pk1 = w.GetIdentity(pub1)
|
||||
pk2 = w.GetIdentity(pub2)
|
||||
if w.HasIdentity(pub1) {
|
||||
x.Fatalf("failed test case 11.")
|
||||
t.Fatalf("failed DeleteIdentity(pub1): still exist.")
|
||||
}
|
||||
if !w.HasIdentity(pub2) {
|
||||
x.Fatalf("failed test case 12.")
|
||||
t.Fatalf("failed DeleteIdentity(pub1): pub2 does not exist.")
|
||||
}
|
||||
if pk1 != nil {
|
||||
x.Fatalf("failed test case 13.")
|
||||
t.Fatalf("failed DeleteIdentity(pub1): first key still exist.")
|
||||
}
|
||||
if pk2 != id2 {
|
||||
x.Fatalf("failed test case 14.")
|
||||
t.Fatalf("failed DeleteIdentity(pub1): second key does not exist.")
|
||||
}
|
||||
|
||||
// Delete again non-existing identity
|
||||
|
|
@ -161,16 +161,16 @@ func TestWhisperIdentityManagement(x *testing.T) {
|
|||
pk1 = w.GetIdentity(pub1)
|
||||
pk2 = w.GetIdentity(pub2)
|
||||
if w.HasIdentity(pub1) {
|
||||
x.Fatalf("failed test case 21.")
|
||||
t.Fatalf("failed delete non-existing identity: exist.")
|
||||
}
|
||||
if !w.HasIdentity(pub2) {
|
||||
x.Fatalf("failed test case 22.")
|
||||
t.Fatalf("failed delete non-existing identity: pub2 does not exist.")
|
||||
}
|
||||
if pk1 != nil {
|
||||
x.Fatalf("failed test case 23.")
|
||||
t.Fatalf("failed delete non-existing identity: first key exist.")
|
||||
}
|
||||
if pk2 != id2 {
|
||||
x.Fatalf("failed test case 24.")
|
||||
t.Fatalf("failed delete non-existing identity: second key does not exist.")
|
||||
}
|
||||
|
||||
// Delete second identity
|
||||
|
|
@ -178,20 +178,20 @@ func TestWhisperIdentityManagement(x *testing.T) {
|
|||
pk1 = w.GetIdentity(pub1)
|
||||
pk2 = w.GetIdentity(pub2)
|
||||
if w.HasIdentity(pub1) {
|
||||
x.Fatalf("failed test case 31.")
|
||||
t.Fatalf("failed delete second identity: first identity exist.")
|
||||
}
|
||||
if w.HasIdentity(pub2) {
|
||||
x.Fatalf("failed test case 32.")
|
||||
t.Fatalf("failed delete second identity: still exist.")
|
||||
}
|
||||
if pk1 != nil {
|
||||
x.Fatalf("failed test case 33.")
|
||||
t.Fatalf("failed delete second identity: first key exist.")
|
||||
}
|
||||
if pk2 != nil {
|
||||
x.Fatalf("failed test case 34.")
|
||||
t.Fatalf("failed delete second identity: second key exist.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestWhisperSymKeyManagement(x *testing.T) {
|
||||
func TestWhisperSymKeyManagement(t *testing.T) {
|
||||
InitSingleTest()
|
||||
|
||||
var k1, k2 []byte
|
||||
|
|
@ -201,22 +201,22 @@ func TestWhisperSymKeyManagement(x *testing.T) {
|
|||
|
||||
err := w.GenerateSymKey(id1)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 1 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed GenerateSymKey with seed %d: %s.", seed, err)
|
||||
}
|
||||
|
||||
k1 = w.GetSymKey(id1)
|
||||
k2 = w.GetSymKey(id2)
|
||||
if !w.HasSymKey(id1) {
|
||||
x.Fatalf("failed test case 2.")
|
||||
t.Fatalf("failed HasSymKey(id1).")
|
||||
}
|
||||
if w.HasSymKey(id2) {
|
||||
x.Fatalf("failed test case 3.")
|
||||
t.Fatalf("failed HasSymKey(id2).")
|
||||
}
|
||||
if k1 == nil {
|
||||
x.Fatalf("failed test case 4.")
|
||||
t.Fatalf("first key does not exist.")
|
||||
}
|
||||
if k2 != nil {
|
||||
x.Fatalf("failed test case 5.")
|
||||
t.Fatalf("second key still exist.")
|
||||
}
|
||||
|
||||
// add existing id, nothing should change
|
||||
|
|
@ -224,72 +224,72 @@ func TestWhisperSymKeyManagement(x *testing.T) {
|
|||
randomize(randomKey)
|
||||
err = w.AddSymKey(id1, randomKey)
|
||||
if err == nil {
|
||||
x.Fatalf("failed test case 10 with seed %d.", seed)
|
||||
t.Fatalf("failed AddSymKey with seed %d.", seed)
|
||||
}
|
||||
|
||||
k1 = w.GetSymKey(id1)
|
||||
k2 = w.GetSymKey(id2)
|
||||
if !w.HasSymKey(id1) {
|
||||
x.Fatalf("failed test case 12.")
|
||||
t.Fatalf("failed w.HasSymKey(id1).")
|
||||
}
|
||||
if w.HasSymKey(id2) {
|
||||
x.Fatalf("failed test case 13.")
|
||||
t.Fatalf("failed w.HasSymKey(id2).")
|
||||
}
|
||||
if k1 == nil {
|
||||
x.Fatalf("failed test case 14.")
|
||||
t.Fatalf("first key does not exist.")
|
||||
}
|
||||
if bytes.Compare(k1, randomKey) == 0 {
|
||||
x.Fatalf("failed test case 15: k1 == randomKey.")
|
||||
t.Fatalf("k1 == randomKey.")
|
||||
}
|
||||
if k2 != nil {
|
||||
x.Fatalf("failed test case 16.")
|
||||
t.Fatalf("second key already exist.")
|
||||
}
|
||||
|
||||
err = w.AddSymKey(id2, randomKey) // add non-existing (yet)
|
||||
if err != nil {
|
||||
x.Fatalf("failed test case 21 with seed %d: %s.", seed, err)
|
||||
t.Fatalf("failed AddSymKey(id2) with seed %d: %s.", seed, err)
|
||||
}
|
||||
k1 = w.GetSymKey(id1)
|
||||
k2 = w.GetSymKey(id2)
|
||||
if !w.HasSymKey(id1) {
|
||||
x.Fatalf("failed test case 22.")
|
||||
t.Fatalf("HasSymKey(id1) failed.")
|
||||
}
|
||||
if !w.HasSymKey(id2) {
|
||||
x.Fatalf("failed test case 23.")
|
||||
t.Fatalf("HasSymKey(id2) failed.")
|
||||
}
|
||||
if k1 == nil {
|
||||
x.Fatalf("failed test case 24.")
|
||||
t.Fatalf("k1 does not exist.")
|
||||
}
|
||||
if k2 == nil {
|
||||
x.Fatalf("failed test case 25.")
|
||||
t.Fatalf("k2 does not exist.")
|
||||
}
|
||||
if bytes.Compare(k1, k2) == 0 {
|
||||
x.Fatalf("failed test case 26.")
|
||||
t.Fatalf("k1 == k2.")
|
||||
}
|
||||
if bytes.Compare(k1, randomKey) == 0 {
|
||||
x.Fatalf("failed test case 27.")
|
||||
t.Fatalf("k1 == randomKey.")
|
||||
}
|
||||
if len(k1) != aesKeyLength {
|
||||
x.Fatalf("failed test case 28.")
|
||||
t.Fatalf("wrong length of k1.")
|
||||
}
|
||||
if len(k2) != aesKeyLength {
|
||||
x.Fatalf("failed test case 29.")
|
||||
t.Fatalf("wrong length of k2.")
|
||||
}
|
||||
|
||||
w.DeleteSymKey(id1)
|
||||
k1 = w.GetSymKey(id1)
|
||||
k2 = w.GetSymKey(id2)
|
||||
if w.HasSymKey(id1) {
|
||||
x.Fatalf("failed test case 31.")
|
||||
t.Fatalf("failed to delete first key: still exist.")
|
||||
}
|
||||
if !w.HasSymKey(id2) {
|
||||
x.Fatalf("failed test case 32.")
|
||||
t.Fatalf("failed to delete first key: second key does not exist.")
|
||||
}
|
||||
if k1 != nil {
|
||||
x.Fatalf("failed test case 33.")
|
||||
t.Fatalf("failed to delete first key.")
|
||||
}
|
||||
if k2 == nil {
|
||||
x.Fatalf("failed test case 34.")
|
||||
t.Fatalf("failed to delete first key: second key is nil.")
|
||||
}
|
||||
|
||||
w.DeleteSymKey(id1)
|
||||
|
|
@ -297,15 +297,15 @@ func TestWhisperSymKeyManagement(x *testing.T) {
|
|||
k1 = w.GetSymKey(id1)
|
||||
k2 = w.GetSymKey(id2)
|
||||
if w.HasSymKey(id1) {
|
||||
x.Fatalf("failed test case 41.")
|
||||
t.Fatalf("failed to delete second key: first key exist.")
|
||||
}
|
||||
if w.HasSymKey(id2) {
|
||||
x.Fatalf("failed test case 42.")
|
||||
t.Fatalf("failed to delete second key: still exist.")
|
||||
}
|
||||
if k1 != nil {
|
||||
x.Fatalf("failed test case 43.")
|
||||
t.Fatalf("failed to delete second key: first key is not nil.")
|
||||
}
|
||||
if k2 != nil {
|
||||
x.Fatalf("failed test case 44.")
|
||||
t.Fatalf("failed to delete second key: second key is not nil.")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue