Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
123864fc
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
123864fc
编写于
7月 21, 2020
作者:
R
rene
提交者:
GitHub
7月 21, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
whisper/whisperv6: improve test error messages (#21348)
上级
7163a666
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
93 addition
and
96 deletion
+93
-96
whisper/whisperv6/whisper_test.go
whisper/whisperv6/whisper_test.go
+93
-96
未找到文件。
whisper/whisperv6/whisper_test.go
浏览文件 @
123864fc
...
...
@@ -42,13 +42,13 @@ func TestWhisperBasic(t *testing.T) {
t
.
Fatalf
(
"failed Protocol Length: %v."
,
shh
.
Length
)
}
if
shh
.
Run
==
nil
{
t
.
Fatal
f
(
"failed shh.Run."
)
t
.
Fatal
(
"failed shh.Run."
)
}
if
uint64
(
w
.
Version
())
!=
ProtocolVersion
{
t
.
Fatalf
(
"failed whisper Version: %v."
,
shh
.
Version
)
}
if
w
.
GetFilter
(
"non-existent"
)
!=
nil
{
t
.
Fatal
f
(
"failed GetFilter."
)
t
.
Fatal
(
"failed GetFilter."
)
}
peerID
:=
make
([]
byte
,
64
)
...
...
@@ -58,22 +58,22 @@ func TestWhisperBasic(t *testing.T) {
t
.
Fatal
(
"found peer for random key."
)
}
if
err
:=
w
.
AllowP2PMessagesFromPeer
(
peerID
);
err
==
nil
{
t
.
Fatal
f
(
"failed MarkPeerTrusted."
)
t
.
Fatal
(
"failed MarkPeerTrusted."
)
}
exist
:=
w
.
HasSymKey
(
"non-existing"
)
if
exist
{
t
.
Fatal
f
(
"failed HasSymKey."
)
t
.
Fatal
(
"failed HasSymKey."
)
}
key
,
err
:=
w
.
GetSymKey
(
"non-existing"
)
if
err
==
nil
{
t
.
Fatalf
(
"failed GetSymKey(non-existing): false positive.
"
)
t
.
Fatalf
(
"failed GetSymKey(non-existing): false positive.
key=%v"
,
key
)
}
if
key
!=
nil
{
t
.
Fatalf
(
"failed GetSymKey: false positive.
"
)
t
.
Fatalf
(
"failed GetSymKey: false positive.
key=%v"
,
key
)
}
mail
:=
w
.
Envelopes
()
if
len
(
mail
)
!=
0
{
t
.
Fatalf
(
"failed w.Envelopes().
"
)
t
.
Fatalf
(
"failed w.Envelopes().
length=%d"
,
len
(
mail
)
)
}
derived
:=
pbkdf2
.
Key
(
peerID
,
nil
,
65356
,
aesKeyLength
,
sha256
.
New
)
...
...
@@ -96,11 +96,11 @@ func TestWhisperBasic(t *testing.T) {
id
,
err
:=
w
.
NewKeyPair
()
if
err
!=
nil
{
t
.
Fatalf
(
"failed to generate new key pair: %
s
."
,
err
)
t
.
Fatalf
(
"failed to generate new key pair: %
v
."
,
err
)
}
pk
,
err
:=
w
.
GetPrivateKey
(
id
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed to retrieve new key pair: %
s
."
,
err
)
t
.
Fatalf
(
"failed to retrieve new key pair: %
v
."
,
err
)
}
if
!
validatePrivateKey
(
pk
)
{
t
.
Fatalf
(
"failed validatePrivateKey: %v."
,
pk
)
...
...
@@ -130,7 +130,7 @@ func TestWhisperAsymmetricKeyImport(t *testing.T) {
privateKeys
=
append
(
privateKeys
,
pk
)
if
!
w
.
DeleteKeyPair
(
id
)
{
t
.
Fatal
f
(
"could not delete private key"
)
t
.
Fatal
(
"could not delete private key"
)
}
}
...
...
@@ -161,101 +161,101 @@ func TestWhisperIdentityManagement(t *testing.T) {
}
if
!
w
.
HasKeyPair
(
id1
)
{
t
.
Fatal
f
(
"failed HasIdentity(pk1)."
)
t
.
Fatal
(
"failed HasIdentity(pk1)."
)
}
if
!
w
.
HasKeyPair
(
id2
)
{
t
.
Fatal
f
(
"failed HasIdentity(pk2)."
)
t
.
Fatal
(
"failed HasIdentity(pk2)."
)
}
if
pk1
==
nil
{
t
.
Fatal
f
(
"failed GetIdentity(pk1)."
)
t
.
Fatal
(
"failed GetIdentity(pk1)."
)
}
if
pk2
==
nil
{
t
.
Fatal
f
(
"failed GetIdentity(pk2)."
)
t
.
Fatal
(
"failed GetIdentity(pk2)."
)
}
if
!
validatePrivateKey
(
pk1
)
{
t
.
Fatal
f
(
"pk1 is invalid."
)
t
.
Fatal
(
"pk1 is invalid."
)
}
if
!
validatePrivateKey
(
pk2
)
{
t
.
Fatal
f
(
"pk2 is invalid."
)
t
.
Fatal
(
"pk2 is invalid."
)
}
// Delete one identity
done
:=
w
.
DeleteKeyPair
(
id1
)
if
!
done
{
t
.
Fatal
f
(
"failed to delete id1."
)
t
.
Fatal
(
"failed to delete id1."
)
}
pk1
,
err
=
w
.
GetPrivateKey
(
id1
)
if
err
==
nil
{
t
.
Fatalf
(
"retrieve the key pair: false positive.
"
)
t
.
Fatalf
(
"retrieve the key pair: false positive.
key=%v"
,
pk1
)
}
pk2
,
err
=
w
.
GetPrivateKey
(
id2
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed to retrieve the key pair: %s."
,
err
)
}
if
w
.
HasKeyPair
(
id1
)
{
t
.
Fatal
f
(
"failed DeleteIdentity(pub1): still exist."
)
t
.
Fatal
(
"failed DeleteIdentity(pub1): still exist."
)
}
if
!
w
.
HasKeyPair
(
id2
)
{
t
.
Fatal
f
(
"failed DeleteIdentity(pub1): pub2 does not exist."
)
t
.
Fatal
(
"failed DeleteIdentity(pub1): pub2 does not exist."
)
}
if
pk1
!=
nil
{
t
.
Fatal
f
(
"failed DeleteIdentity(pub1): first key still exist."
)
t
.
Fatal
(
"failed DeleteIdentity(pub1): first key still exist."
)
}
if
pk2
==
nil
{
t
.
Fatal
f
(
"failed DeleteIdentity(pub1): second key does not exist."
)
t
.
Fatal
(
"failed DeleteIdentity(pub1): second key does not exist."
)
}
// Delete again non-existing identity
done
=
w
.
DeleteKeyPair
(
id1
)
if
done
{
t
.
Fatal
f
(
"delete id1: false positive."
)
t
.
Fatal
(
"delete id1: false positive."
)
}
pk1
,
err
=
w
.
GetPrivateKey
(
id1
)
if
err
==
nil
{
t
.
Fatalf
(
"retrieve the key pair: false positive.
"
)
t
.
Fatalf
(
"retrieve the key pair: false positive.
key=%v"
,
pk1
)
}
pk2
,
err
=
w
.
GetPrivateKey
(
id2
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed to retrieve the key pair: %s."
,
err
)
}
if
w
.
HasKeyPair
(
id1
)
{
t
.
Fatal
f
(
"failed delete non-existing identity: exist."
)
t
.
Fatal
(
"failed delete non-existing identity: exist."
)
}
if
!
w
.
HasKeyPair
(
id2
)
{
t
.
Fatal
f
(
"failed delete non-existing identity: pub2 does not exist."
)
t
.
Fatal
(
"failed delete non-existing identity: pub2 does not exist."
)
}
if
pk1
!=
nil
{
t
.
Fatalf
(
"failed delete non-existing identity: first key exist.
"
)
t
.
Fatalf
(
"failed delete non-existing identity: first key exist.
key=%v"
,
pk1
)
}
if
pk2
==
nil
{
t
.
Fatal
f
(
"failed delete non-existing identity: second key does not exist."
)
t
.
Fatal
(
"failed delete non-existing identity: second key does not exist."
)
}
// Delete second identity
done
=
w
.
DeleteKeyPair
(
id2
)
if
!
done
{
t
.
Fatal
f
(
"failed to delete id2."
)
t
.
Fatal
(
"failed to delete id2."
)
}
pk1
,
err
=
w
.
GetPrivateKey
(
id1
)
if
err
==
nil
{
t
.
Fatalf
(
"retrieve the key pair: false positive.
"
)
t
.
Fatalf
(
"retrieve the key pair: false positive.
key=%v"
,
pk1
)
}
pk2
,
err
=
w
.
GetPrivateKey
(
id2
)
if
err
==
nil
{
t
.
Fatalf
(
"retrieve the key pair: false positive.
"
)
t
.
Fatalf
(
"retrieve the key pair: false positive.
key=%v"
,
pk2
)
}
if
w
.
HasKeyPair
(
id1
)
{
t
.
Fatal
f
(
"failed delete second identity: first identity exist."
)
t
.
Fatal
(
"failed delete second identity: first identity exist."
)
}
if
w
.
HasKeyPair
(
id2
)
{
t
.
Fatal
f
(
"failed delete second identity: still exist."
)
t
.
Fatal
(
"failed delete second identity: still exist."
)
}
if
pk1
!=
nil
{
t
.
Fatalf
(
"failed delete second identity: first key exist.
"
)
t
.
Fatalf
(
"failed delete second identity: first key exist.
key=%v"
,
pk1
)
}
if
pk2
!=
nil
{
t
.
Fatalf
(
"failed delete second identity: second key exist.
"
)
t
.
Fatalf
(
"failed delete second identity: second key exist.
key=%v"
,
pk2
)
}
}
...
...
@@ -274,23 +274,23 @@ func TestWhisperSymKeyManagement(t *testing.T) {
k1
,
err
=
w
.
GetSymKey
(
id1
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed GetSymKey(id1).
"
)
t
.
Fatalf
(
"failed GetSymKey(id1).
err=%v"
,
err
)
}
k2
,
err
=
w
.
GetSymKey
(
id2
)
if
err
==
nil
{
t
.
Fatalf
(
"failed GetSymKey(id2): false positive.
"
)
t
.
Fatalf
(
"failed GetSymKey(id2): false positive.
key=%v"
,
k2
)
}
if
!
w
.
HasSymKey
(
id1
)
{
t
.
Fatal
f
(
"failed HasSymKey(id1)."
)
t
.
Fatal
(
"failed HasSymKey(id1)."
)
}
if
w
.
HasSymKey
(
id2
)
{
t
.
Fatal
f
(
"failed HasSymKey(id2): false positive."
)
t
.
Fatal
(
"failed HasSymKey(id2): false positive."
)
}
if
k1
==
nil
{
t
.
Fatal
f
(
"first key does not exist."
)
t
.
Fatal
(
"first key does not exist."
)
}
if
k2
!=
nil
{
t
.
Fatalf
(
"second key still exist.
"
)
t
.
Fatalf
(
"second key still exist.
key=%v"
,
k2
)
}
// add existing id, nothing should change
...
...
@@ -303,26 +303,26 @@ func TestWhisperSymKeyManagement(t *testing.T) {
k1
,
err
=
w
.
GetSymKey
(
id1
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed w.GetSymKey(id1).
"
)
t
.
Fatalf
(
"failed w.GetSymKey(id1).
err=%v"
,
err
)
}
k2
,
err
=
w
.
GetSymKey
(
id2
)
if
err
==
nil
{
t
.
Fatalf
(
"failed w.GetSymKey(id2): false positive.
"
)
t
.
Fatalf
(
"failed w.GetSymKey(id2): false positive.
key=%v"
,
k2
)
}
if
!
w
.
HasSymKey
(
id1
)
{
t
.
Fatal
f
(
"failed w.HasSymKey(id1)."
)
t
.
Fatal
(
"failed w.HasSymKey(id1)."
)
}
if
w
.
HasSymKey
(
id2
)
{
t
.
Fatal
f
(
"failed w.HasSymKey(id2): false positive."
)
t
.
Fatal
(
"failed w.HasSymKey(id2): false positive."
)
}
if
k1
==
nil
{
t
.
Fatal
f
(
"first key does not exist."
)
t
.
Fatal
(
"first key does not exist."
)
}
if
!
bytes
.
Equal
(
k1
,
randomKey
)
{
t
.
Fatal
f
(
"k1 != randomKey."
)
t
.
Fatal
(
"k1 != randomKey."
)
}
if
k2
!=
nil
{
t
.
Fatalf
(
"second key already exist.
"
)
t
.
Fatalf
(
"second key already exist.
key=%v"
,
k2
)
}
id2
,
err
=
w
.
AddSymKeyDirect
(
randomKey
)
...
...
@@ -331,35 +331,35 @@ func TestWhisperSymKeyManagement(t *testing.T) {
}
k1
,
err
=
w
.
GetSymKey
(
id1
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed w.GetSymKey(id1).
"
)
t
.
Fatalf
(
"failed w.GetSymKey(id1).
err=%v"
,
err
)
}
k2
,
err
=
w
.
GetSymKey
(
id2
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed w.GetSymKey(id2).
"
)
t
.
Fatalf
(
"failed w.GetSymKey(id2).
err=%v"
,
err
)
}
if
!
w
.
HasSymKey
(
id1
)
{
t
.
Fatal
f
(
"HasSymKey(id1) failed."
)
t
.
Fatal
(
"HasSymKey(id1) failed."
)
}
if
!
w
.
HasSymKey
(
id2
)
{
t
.
Fatal
f
(
"HasSymKey(id2) failed."
)
t
.
Fatal
(
"HasSymKey(id2) failed."
)
}
if
k1
==
nil
{
t
.
Fatal
f
(
"k1 does not exist."
)
t
.
Fatal
(
"k1 does not exist."
)
}
if
k2
==
nil
{
t
.
Fatal
f
(
"k2 does not exist."
)
t
.
Fatal
(
"k2 does not exist."
)
}
if
!
bytes
.
Equal
(
k1
,
k2
)
{
t
.
Fatal
f
(
"k1 != k2."
)
t
.
Fatal
(
"k1 != k2."
)
}
if
!
bytes
.
Equal
(
k1
,
randomKey
)
{
t
.
Fatal
f
(
"k1 != randomKey."
)
t
.
Fatal
(
"k1 != randomKey."
)
}
if
len
(
k1
)
!=
aesKeyLength
{
t
.
Fatalf
(
"wrong length of k1.
"
)
t
.
Fatalf
(
"wrong length of k1.
length=%d"
,
len
(
k1
)
)
}
if
len
(
k2
)
!=
aesKeyLength
{
t
.
Fatalf
(
"wrong length of k2.
"
)
t
.
Fatalf
(
"wrong length of k2.
length=%d"
,
len
(
k2
)
)
}
w
.
DeleteSymKey
(
id1
)
...
...
@@ -368,49 +368,46 @@ func TestWhisperSymKeyManagement(t *testing.T) {
t
.
Fatalf
(
"failed w.GetSymKey(id1): false positive."
)
}
if
k1
!=
nil
{
t
.
Fatalf
(
"failed GetSymKey(id1): false positive.
"
)
t
.
Fatalf
(
"failed GetSymKey(id1): false positive.
key=%v"
,
k1
)
}
k2
,
err
=
w
.
GetSymKey
(
id2
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed w.GetSymKey(id2).
"
)
t
.
Fatalf
(
"failed w.GetSymKey(id2).
err=%v"
,
err
)
}
if
w
.
HasSymKey
(
id1
)
{
t
.
Fatal
f
(
"failed to delete first key: still exist."
)
t
.
Fatal
(
"failed to delete first key: still exist."
)
}
if
!
w
.
HasSymKey
(
id2
)
{
t
.
Fatalf
(
"failed to delete first key: second key does not exist."
)
}
if
k1
!=
nil
{
t
.
Fatalf
(
"failed to delete first key."
)
t
.
Fatal
(
"failed to delete first key: second key does not exist."
)
}
if
k2
==
nil
{
t
.
Fatal
f
(
"failed to delete first key: second key is nil."
)
t
.
Fatal
(
"failed to delete first key: second key is nil."
)
}
w
.
DeleteSymKey
(
id1
)
w
.
DeleteSymKey
(
id2
)
k1
,
err
=
w
.
GetSymKey
(
id1
)
if
err
==
nil
{
t
.
Fatalf
(
"failed w.GetSymKey(id1): false positive.
"
)
t
.
Fatalf
(
"failed w.GetSymKey(id1): false positive.
key=%v"
,
k1
)
}
k2
,
err
=
w
.
GetSymKey
(
id2
)
if
err
==
nil
{
t
.
Fatalf
(
"failed w.GetSymKey(id2): false positive.
"
)
t
.
Fatalf
(
"failed w.GetSymKey(id2): false positive.
key=%v"
,
k2
)
}
if
k1
!=
nil
||
k2
!=
nil
{
t
.
Fatal
f
(
"k1 or k2 is not nil"
)
t
.
Fatal
(
"k1 or k2 is not nil"
)
}
if
w
.
HasSymKey
(
id1
)
{
t
.
Fatal
f
(
"failed to delete second key: first key exist."
)
t
.
Fatal
(
"failed to delete second key: first key exist."
)
}
if
w
.
HasSymKey
(
id2
)
{
t
.
Fatal
f
(
"failed to delete second key: still exist."
)
t
.
Fatal
(
"failed to delete second key: still exist."
)
}
if
k1
!=
nil
{
t
.
Fatal
f
(
"failed to delete second key: first key is not nil."
)
t
.
Fatal
(
"failed to delete second key: first key is not nil."
)
}
if
k2
!=
nil
{
t
.
Fatal
f
(
"failed to delete second key: second key is not nil."
)
t
.
Fatal
(
"failed to delete second key: second key is not nil."
)
}
randomKey
=
make
([]
byte
,
aesKeyLength
+
1
)
...
...
@@ -431,23 +428,23 @@ func TestWhisperSymKeyManagement(t *testing.T) {
}
k1
,
err
=
w
.
GetSymKey
(
id1
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed w.GetSymKey(id1).
"
)
t
.
Fatalf
(
"failed w.GetSymKey(id1).
err=%v"
,
err
)
}
k2
,
err
=
w
.
GetSymKey
(
id2
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed w.GetSymKey(id2).
"
)
t
.
Fatalf
(
"failed w.GetSymKey(id2).
err=%v"
,
err
)
}
if
!
w
.
HasSymKey
(
id1
)
{
t
.
Fatal
f
(
"HasSymKey(id1) failed."
)
t
.
Fatal
(
"HasSymKey(id1) failed."
)
}
if
!
w
.
HasSymKey
(
id2
)
{
t
.
Fatal
f
(
"HasSymKey(id2) failed."
)
t
.
Fatal
(
"HasSymKey(id2) failed."
)
}
if
!
validateDataIntegrity
(
k2
,
aesKeyLength
)
{
t
.
Fatal
f
(
"key validation failed."
)
t
.
Fatal
(
"key validation failed."
)
}
if
!
bytes
.
Equal
(
k1
,
k2
)
{
t
.
Fatal
f
(
"k1 != k2."
)
t
.
Fatal
(
"k1 != k2."
)
}
}
...
...
@@ -606,7 +603,7 @@ func TestCustomization(t *testing.T) {
<-
ticker
.
C
mail
:=
f
.
Retrieve
()
if
len
(
mail
)
>
0
{
t
.
Fatalf
(
"received premature mail
"
)
t
.
Fatalf
(
"received premature mail
. mail=%v"
,
mail
)
}
}
...
...
@@ -693,10 +690,10 @@ func TestSymmetricSendCycle(t *testing.T) {
mail1
:=
filter1
.
Retrieve
()
mail2
:=
filter2
.
Retrieve
()
if
len
(
mail2
)
==
0
{
t
.
Fatal
f
(
"did not receive any email for filter 2
"
)
t
.
Fatal
(
"did not receive any email for filter 2.
"
)
}
if
len
(
mail1
)
==
0
{
t
.
Fatal
f
(
"did not receive any email for filter 1
"
)
t
.
Fatal
(
"did not receive any email for filter 1.
"
)
}
}
...
...
@@ -767,7 +764,7 @@ func TestSymmetricSendWithoutAKey(t *testing.T) {
<-
ticker
.
C
mail
:=
filter
.
Retrieve
()
if
len
(
mail
)
==
0
{
t
.
Fatal
f
(
"did not receive message in spite of not setting a public key"
)
t
.
Fatal
(
"did not receive message in spite of not setting a public key"
)
}
}
...
...
@@ -835,7 +832,7 @@ func TestSymmetricSendKeyMismatch(t *testing.T) {
<-
ticker
.
C
mail
:=
filter
.
Retrieve
()
if
len
(
mail
)
>
0
{
t
.
Fatalf
(
"received a message when keys weren't matching
"
)
t
.
Fatalf
(
"received a message when keys weren't matching
. message=%v"
,
mail
)
}
}
...
...
@@ -847,48 +844,48 @@ func TestBloom(t *testing.T) {
x
[
32
]
=
byte
(
1
)
x
[
BloomFilterSize
-
1
]
=
byte
(
128
)
if
!
BloomFilterMatch
(
x
,
b
)
||
!
BloomFilterMatch
(
b
,
x
)
{
t
.
Fatal
f
(
"bloom filter does not match the mask"
)
t
.
Fatal
(
"bloom filter does not match the mask"
)
}
_
,
err
:=
mrand
.
Read
(
b
)
if
err
!=
nil
{
t
.
Fatalf
(
"math rand error
"
)
t
.
Fatalf
(
"math rand error
. err=%v"
,
err
)
}
_
,
err
=
mrand
.
Read
(
x
)
if
err
!=
nil
{
t
.
Fatalf
(
"math rand error
"
)
t
.
Fatalf
(
"math rand error
. err=%v"
,
err
)
}
if
!
BloomFilterMatch
(
b
,
b
)
{
t
.
Fatal
f
(
"bloom filter does not match self"
)
t
.
Fatal
(
"bloom filter does not match self"
)
}
x
=
addBloom
(
x
,
b
)
if
!
BloomFilterMatch
(
x
,
b
)
{
t
.
Fatal
f
(
"bloom filter does not match combined bloom"
)
t
.
Fatal
(
"bloom filter does not match combined bloom"
)
}
if
!
isFullNode
(
nil
)
{
t
.
Fatal
f
(
"isFullNode did not recognize nil as full node"
)
t
.
Fatal
(
"isFullNode did not recognize nil as full node"
)
}
x
[
17
]
=
254
if
isFullNode
(
x
)
{
t
.
Fatal
f
(
"isFullNode false positive"
)
t
.
Fatal
(
"isFullNode false positive"
)
}
for
i
:=
0
;
i
<
BloomFilterSize
;
i
++
{
b
[
i
]
=
byte
(
255
)
}
if
!
isFullNode
(
b
)
{
t
.
Fatal
f
(
"isFullNode false negative"
)
t
.
Fatal
(
"isFullNode false negative"
)
}
if
BloomFilterMatch
(
x
,
b
)
{
t
.
Fatal
f
(
"bloomFilterMatch false positive"
)
t
.
Fatal
(
"bloomFilterMatch false positive"
)
}
if
!
BloomFilterMatch
(
b
,
x
)
{
t
.
Fatal
f
(
"bloomFilterMatch false negative"
)
t
.
Fatal
(
"bloomFilterMatch false negative"
)
}
w
:=
New
(
&
DefaultConfig
)
f
:=
w
.
BloomFilter
()
if
f
!=
nil
{
t
.
Fatal
f
(
"wrong bloom on creation"
)
t
.
Fatal
(
"wrong bloom on creation"
)
}
err
=
w
.
SetBloomFilter
(
x
)
if
err
!=
nil
{
...
...
@@ -896,6 +893,6 @@ func TestBloom(t *testing.T) {
}
f
=
w
.
BloomFilter
()
if
!
BloomFilterMatch
(
f
,
x
)
||
!
BloomFilterMatch
(
x
,
f
)
{
t
.
Fatal
f
(
"retireved wrong bloom filter"
)
t
.
Fatal
(
"retireved wrong bloom filter"
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录