2016-10-29 07:11:37 -05:00
|
|
|
// Copyright 2016 The go-ethereum Authors
|
|
|
|
// This file is part of the go-ethereum library.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package whisperv5
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"crypto/ecdsa"
|
|
|
|
"net"
|
|
|
|
"sync"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/crypto"
|
|
|
|
"github.com/ethereum/go-ethereum/p2p"
|
all: new p2p node representation (#17643)
Package p2p/enode provides a generalized representation of p2p nodes
which can contain arbitrary information in key/value pairs. It is also
the new home for the node database. The "v4" identity scheme is also
moved here from p2p/enr to remove the dependency on Ethereum crypto from
that package.
Record signature handling is changed significantly. The identity scheme
registry is removed and acceptable schemes must be passed to any method
that needs identity. This means records must now be validated explicitly
after decoding.
The enode API is designed to make signature handling easy and safe: most
APIs around the codebase work with enode.Node, which is a wrapper around
a valid record. Going from enr.Record to enode.Node requires a valid
signature.
* p2p/discover: port to p2p/enode
This ports the discovery code to the new node representation in
p2p/enode. The wire protocol is unchanged, this can be considered a
refactoring change. The Kademlia table can now deal with nodes using an
arbitrary identity scheme. This requires a few incompatible API changes:
- Table.Lookup is not available anymore. It used to take a public key
as argument because v4 protocol requires one. Its replacement is
LookupRandom.
- Table.Resolve takes *enode.Node instead of NodeID. This is also for
v4 protocol compatibility because nodes cannot be looked up by ID
alone.
- Types Node and NodeID are gone. Further commits in the series will be
fixes all over the the codebase to deal with those removals.
* p2p: port to p2p/enode and discovery changes
This adapts package p2p to the changes in p2p/discover. All uses of
discover.Node and discover.NodeID are replaced by their equivalents from
p2p/enode.
New API is added to retrieve the enode.Node instance of a peer. The
behavior of Server.Self with discovery disabled is improved. It now
tries much harder to report a working IP address, falling back to
127.0.0.1 if no suitable address can be determined through other means.
These changes were needed for tests of other packages later in the
series.
* p2p/simulations, p2p/testing: port to p2p/enode
No surprises here, mostly replacements of discover.Node, discover.NodeID
with their new equivalents. The 'interesting' API changes are:
- testing.ProtocolSession tracks complete nodes, not just their IDs.
- adapters.NodeConfig has a new method to create a complete node.
These changes were needed to make swarm tests work.
Note that the NodeID change makes the code incompatible with old
simulation snapshots.
* whisper/whisperv5, whisper/whisperv6: port to p2p/enode
This port was easy because whisper uses []byte for node IDs and
URL strings in the API.
* eth: port to p2p/enode
Again, easy to port because eth uses strings for node IDs and doesn't
care about node information in any way.
* les: port to p2p/enode
Apart from replacing discover.NodeID with enode.ID, most changes are in
the server pool code. It now deals with complete nodes instead
of (Pubkey, IP, Port) triples. The database format is unchanged for now,
but we should probably change it to use the node database later.
* node: port to p2p/enode
This change simply replaces discover.Node and discover.NodeID with their
new equivalents.
* swarm/network: port to p2p/enode
Swarm has its own node address representation, BzzAddr, containing both
an overlay address (the hash of a secp256k1 public key) and an underlay
address (enode:// URL).
There are no changes to the BzzAddr format in this commit, but certain
operations such as creating a BzzAddr from a node ID are now impossible
because node IDs aren't public keys anymore.
Most swarm-related changes in the series remove uses of
NewAddrFromNodeID, replacing it with NewAddr which takes a complete node
as argument. ToOverlayAddr is removed because we can just use the node
ID directly.
2018-09-24 17:59:00 -05:00
|
|
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
2016-10-29 07:11:37 -05:00
|
|
|
"github.com/ethereum/go-ethereum/p2p/nat"
|
|
|
|
)
|
|
|
|
|
2018-05-02 01:17:17 -05:00
|
|
|
var keys = []string{
|
2016-10-29 07:11:37 -05:00
|
|
|
"d49dcf37238dc8a7aac57dc61b9fee68f0a97f062968978b9fafa7d1033d03a9",
|
|
|
|
"73fd6143c48e80ed3c56ea159fe7494a0b6b393a392227b422f4c3e8f1b54f98",
|
|
|
|
"119dd32adb1daa7a4c7bf77f847fb28730785aa92947edf42fdd997b54de40dc",
|
|
|
|
"deeda8709dea935bb772248a3144dea449ffcc13e8e5a1fd4ef20ce4e9c87837",
|
|
|
|
"5bd208a079633befa349441bdfdc4d85ba9bd56081525008380a63ac38a407cf",
|
|
|
|
"1d27fb4912002d58a2a42a50c97edb05c1b3dffc665dbaa42df1fe8d3d95c9b5",
|
|
|
|
"15def52800c9d6b8ca6f3066b7767a76afc7b611786c1276165fbc61636afb68",
|
|
|
|
"51be6ab4b2dc89f251ff2ace10f3c1cc65d6855f3e083f91f6ff8efdfd28b48c",
|
|
|
|
"ef1ef7441bf3c6419b162f05da6037474664f198b58db7315a6f4de52414b4a0",
|
|
|
|
"09bdf6985aabc696dc1fbeb5381aebd7a6421727343872eb2fadfc6d82486fd9",
|
|
|
|
"15d811bf2e01f99a224cdc91d0cf76cea08e8c67905c16fee9725c9be71185c4",
|
|
|
|
"2f83e45cf1baaea779789f755b7da72d8857aeebff19362dd9af31d3c9d14620",
|
|
|
|
"73f04e34ac6532b19c2aae8f8e52f38df1ac8f5cd10369f92325b9b0494b0590",
|
|
|
|
"1e2e07b69e5025537fb73770f483dc8d64f84ae3403775ef61cd36e3faf162c1",
|
|
|
|
"8963d9bbb3911aac6d30388c786756b1c423c4fbbc95d1f96ddbddf39809e43a",
|
|
|
|
"0422da85abc48249270b45d8de38a4cc3c02032ede1fcf0864a51092d58a2f1f",
|
|
|
|
"8ae5c15b0e8c7cade201fdc149831aa9b11ff626a7ffd27188886cc108ad0fa8",
|
|
|
|
"acd8f5a71d4aecfcb9ad00d32aa4bcf2a602939b6a9dd071bab443154184f805",
|
|
|
|
"a285a922125a7481600782ad69debfbcdb0316c1e97c267aff29ef50001ec045",
|
|
|
|
"28fd4eee78c6cd4bf78f39f8ab30c32c67c24a6223baa40e6f9c9a0e1de7cef5",
|
|
|
|
"c5cca0c9e6f043b288c6f1aef448ab59132dab3e453671af5d0752961f013fc7",
|
|
|
|
"46df99b051838cb6f8d1b73f232af516886bd8c4d0ee07af9a0a033c391380fd",
|
|
|
|
"c6a06a53cbaadbb432884f36155c8f3244e244881b5ee3e92e974cfa166d793f",
|
|
|
|
"783b90c75c63dc72e2f8d11b6f1b4de54d63825330ec76ee8db34f06b38ea211",
|
|
|
|
"9450038f10ca2c097a8013e5121b36b422b95b04892232f930a29292d9935611",
|
|
|
|
"e215e6246ed1cfdcf7310d4d8cdbe370f0d6a8371e4eb1089e2ae05c0e1bc10f",
|
|
|
|
"487110939ed9d64ebbc1f300adeab358bc58875faf4ca64990fbd7fe03b78f2b",
|
|
|
|
"824a70ea76ac81366da1d4f4ac39de851c8ac49dca456bb3f0a186ceefa269a5",
|
|
|
|
"ba8f34fa40945560d1006a328fe70c42e35cc3d1017e72d26864cd0d1b150f15",
|
|
|
|
"30a5dfcfd144997f428901ea88a43c8d176b19c79dde54cc58eea001aa3d246c",
|
|
|
|
"de59f7183aca39aa245ce66a05245fecfc7e2c75884184b52b27734a4a58efa2",
|
|
|
|
"92629e2ff5f0cb4f5f08fffe0f64492024d36f045b901efb271674b801095c5a",
|
|
|
|
"7184c1701569e3a4c4d2ddce691edd983b81e42e09196d332e1ae2f1e062cff4",
|
|
|
|
}
|
|
|
|
|
|
|
|
const NumNodes = 16 // must not exceed the number of keys (32)
|
|
|
|
|
|
|
|
type TestData struct {
|
|
|
|
counter [NumNodes]int
|
|
|
|
mutex sync.RWMutex
|
|
|
|
}
|
|
|
|
|
|
|
|
type TestNode struct {
|
|
|
|
shh *Whisper
|
|
|
|
id *ecdsa.PrivateKey
|
|
|
|
server *p2p.Server
|
2017-02-23 02:41:47 -06:00
|
|
|
filerId string
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
var result TestData
|
|
|
|
var nodes [NumNodes]*TestNode
|
2018-05-02 01:17:17 -05:00
|
|
|
var sharedKey = []byte("some arbitrary data here")
|
2016-10-29 07:11:37 -05:00
|
|
|
var sharedTopic TopicType = TopicType{0xF, 0x1, 0x2, 0}
|
2018-05-02 01:17:17 -05:00
|
|
|
var expectedMessage = []byte("per rectum ad astra")
|
2016-10-29 07:11:37 -05:00
|
|
|
|
|
|
|
// This test does the following:
|
|
|
|
// 1. creates a chain of whisper nodes,
|
|
|
|
// 2. installs the filters with shared (predefined) parameters,
|
|
|
|
// 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.
|
2016-12-01 13:09:22 -06:00
|
|
|
func TestSimulation(t *testing.T) {
|
|
|
|
initialize(t)
|
2016-10-29 07:11:37 -05:00
|
|
|
|
|
|
|
for i := 0; i < NumNodes; i++ {
|
2016-12-01 13:09:22 -06:00
|
|
|
sendMsg(t, false, i)
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
|
2016-12-01 13:09:22 -06:00
|
|
|
sendMsg(t, true, 0)
|
|
|
|
checkPropagation(t)
|
2016-10-29 07:11:37 -05:00
|
|
|
stopServers()
|
|
|
|
}
|
|
|
|
|
2016-12-01 13:09:22 -06:00
|
|
|
func initialize(t *testing.T) {
|
2016-10-29 07:11:37 -05:00
|
|
|
var err error
|
|
|
|
|
|
|
|
for i := 0; i < NumNodes; i++ {
|
|
|
|
var node TestNode
|
2017-06-13 04:49:07 -05:00
|
|
|
node.shh = New(&DefaultConfig)
|
2017-04-09 16:49:22 -05:00
|
|
|
node.shh.SetMinimumPoW(0.00000001)
|
2016-12-19 17:58:01 -06:00
|
|
|
node.shh.Start(nil)
|
2016-12-01 13:09:22 -06:00
|
|
|
topics := make([]TopicType, 0)
|
|
|
|
topics = append(topics, sharedTopic)
|
2017-04-09 16:49:22 -05:00
|
|
|
f := Filter{KeySym: sharedKey}
|
|
|
|
f.Topics = [][]byte{topics[0][:]}
|
|
|
|
node.filerId, err = node.shh.Subscribe(&f)
|
2017-02-23 02:41:47 -06:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed to install the filter: %s.", err)
|
|
|
|
}
|
2016-10-29 07:11:37 -05:00
|
|
|
node.id, err = crypto.HexToECDSA(keys[i])
|
|
|
|
if err != nil {
|
2016-12-01 13:09:22 -06:00
|
|
|
t.Fatalf("failed convert the key: %s.", keys[i])
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
name := common.MakeName("whisper-go", "2.0")
|
|
|
|
node.server = &p2p.Server{
|
|
|
|
Config: p2p.Config{
|
2018-06-14 03:54:00 -05:00
|
|
|
PrivateKey: node.id,
|
|
|
|
MaxPeers: NumNodes/2 + 1,
|
|
|
|
Name: name,
|
|
|
|
Protocols: node.shh.Protocols(),
|
|
|
|
ListenAddr: "127.0.0.1:0",
|
|
|
|
NAT: nat.Any(),
|
2016-10-29 07:11:37 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
err = node.server.Start()
|
|
|
|
if err != nil {
|
2018-11-20 03:08:02 -06:00
|
|
|
t.Fatalf("failed to start server %d. err: %v", i, err)
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
|
2018-06-14 03:54:00 -05:00
|
|
|
for j := 0; j < i; j++ {
|
|
|
|
peerNodeId := nodes[j].id
|
|
|
|
address, _ := net.ResolveTCPAddr("tcp", nodes[j].server.ListenAddr)
|
|
|
|
peerPort := uint16(address.Port)
|
all: new p2p node representation (#17643)
Package p2p/enode provides a generalized representation of p2p nodes
which can contain arbitrary information in key/value pairs. It is also
the new home for the node database. The "v4" identity scheme is also
moved here from p2p/enr to remove the dependency on Ethereum crypto from
that package.
Record signature handling is changed significantly. The identity scheme
registry is removed and acceptable schemes must be passed to any method
that needs identity. This means records must now be validated explicitly
after decoding.
The enode API is designed to make signature handling easy and safe: most
APIs around the codebase work with enode.Node, which is a wrapper around
a valid record. Going from enr.Record to enode.Node requires a valid
signature.
* p2p/discover: port to p2p/enode
This ports the discovery code to the new node representation in
p2p/enode. The wire protocol is unchanged, this can be considered a
refactoring change. The Kademlia table can now deal with nodes using an
arbitrary identity scheme. This requires a few incompatible API changes:
- Table.Lookup is not available anymore. It used to take a public key
as argument because v4 protocol requires one. Its replacement is
LookupRandom.
- Table.Resolve takes *enode.Node instead of NodeID. This is also for
v4 protocol compatibility because nodes cannot be looked up by ID
alone.
- Types Node and NodeID are gone. Further commits in the series will be
fixes all over the the codebase to deal with those removals.
* p2p: port to p2p/enode and discovery changes
This adapts package p2p to the changes in p2p/discover. All uses of
discover.Node and discover.NodeID are replaced by their equivalents from
p2p/enode.
New API is added to retrieve the enode.Node instance of a peer. The
behavior of Server.Self with discovery disabled is improved. It now
tries much harder to report a working IP address, falling back to
127.0.0.1 if no suitable address can be determined through other means.
These changes were needed for tests of other packages later in the
series.
* p2p/simulations, p2p/testing: port to p2p/enode
No surprises here, mostly replacements of discover.Node, discover.NodeID
with their new equivalents. The 'interesting' API changes are:
- testing.ProtocolSession tracks complete nodes, not just their IDs.
- adapters.NodeConfig has a new method to create a complete node.
These changes were needed to make swarm tests work.
Note that the NodeID change makes the code incompatible with old
simulation snapshots.
* whisper/whisperv5, whisper/whisperv6: port to p2p/enode
This port was easy because whisper uses []byte for node IDs and
URL strings in the API.
* eth: port to p2p/enode
Again, easy to port because eth uses strings for node IDs and doesn't
care about node information in any way.
* les: port to p2p/enode
Apart from replacing discover.NodeID with enode.ID, most changes are in
the server pool code. It now deals with complete nodes instead
of (Pubkey, IP, Port) triples. The database format is unchanged for now,
but we should probably change it to use the node database later.
* node: port to p2p/enode
This change simply replaces discover.Node and discover.NodeID with their
new equivalents.
* swarm/network: port to p2p/enode
Swarm has its own node address representation, BzzAddr, containing both
an overlay address (the hash of a secp256k1 public key) and an underlay
address (enode:// URL).
There are no changes to the BzzAddr format in this commit, but certain
operations such as creating a BzzAddr from a node ID are now impossible
because node IDs aren't public keys anymore.
Most swarm-related changes in the series remove uses of
NewAddrFromNodeID, replacing it with NewAddr which takes a complete node
as argument. ToOverlayAddr is removed because we can just use the node
ID directly.
2018-09-24 17:59:00 -05:00
|
|
|
peer := enode.NewV4(&peerNodeId.PublicKey, address.IP, int(peerPort), int(peerPort))
|
2018-06-14 03:54:00 -05:00
|
|
|
node.server.AddPeer(peer)
|
|
|
|
}
|
|
|
|
|
2016-10-29 07:11:37 -05:00
|
|
|
nodes[i] = &node
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func stopServers() {
|
|
|
|
for i := 0; i < NumNodes; i++ {
|
|
|
|
n := nodes[i]
|
|
|
|
if n != nil {
|
2017-04-09 16:49:22 -05:00
|
|
|
n.shh.Unsubscribe(n.filerId)
|
2016-12-19 17:58:01 -06:00
|
|
|
n.shh.Stop()
|
2016-10-29 07:11:37 -05:00
|
|
|
n.server.Stop()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-01 13:09:22 -06:00
|
|
|
func checkPropagation(t *testing.T) {
|
|
|
|
if t.Failed() {
|
2016-10-29 07:11:37 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const cycle = 100
|
|
|
|
const iterations = 100
|
|
|
|
|
|
|
|
for j := 0; j < iterations; j++ {
|
|
|
|
time.Sleep(cycle * time.Millisecond)
|
|
|
|
|
|
|
|
for i := 0; i < NumNodes; i++ {
|
|
|
|
f := nodes[i].shh.GetFilter(nodes[i].filerId)
|
|
|
|
if f == nil {
|
2017-02-23 02:41:47 -06:00
|
|
|
t.Fatalf("failed to get filterId %s from node %d.", nodes[i].filerId, i)
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
mail := f.Retrieve()
|
2016-12-01 13:09:22 -06:00
|
|
|
if !validateMail(t, i, mail) {
|
2016-10-29 07:11:37 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if isTestComplete() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-01 13:09:22 -06:00
|
|
|
t.Fatalf("Test was not complete: timeout %d seconds.", iterations*cycle/1000)
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
|
2016-12-01 13:09:22 -06:00
|
|
|
func validateMail(t *testing.T, index int, mail []*ReceivedMessage) bool {
|
2016-10-29 07:11:37 -05:00
|
|
|
var cnt int
|
|
|
|
for _, m := range mail {
|
2017-01-06 09:44:20 -06:00
|
|
|
if bytes.Equal(m.Payload, expectedMessage) {
|
2016-10-29 07:11:37 -05:00
|
|
|
cnt++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if cnt == 0 {
|
|
|
|
// no messages received yet: nothing is wrong
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if cnt > 1 {
|
2016-12-01 13:09:22 -06:00
|
|
|
t.Fatalf("node %d received %d.", index, cnt)
|
2016-10-29 07:11:37 -05:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if cnt > 0 {
|
|
|
|
result.mutex.Lock()
|
|
|
|
defer result.mutex.Unlock()
|
|
|
|
result.counter[index] += cnt
|
|
|
|
if result.counter[index] > 1 {
|
2016-12-01 13:09:22 -06:00
|
|
|
t.Fatalf("node %d accumulated %d.", index, result.counter[index])
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func isTestComplete() bool {
|
|
|
|
result.mutex.RLock()
|
|
|
|
defer result.mutex.RUnlock()
|
|
|
|
|
|
|
|
for i := 0; i < NumNodes; i++ {
|
|
|
|
if result.counter[i] < 1 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < NumNodes; i++ {
|
|
|
|
envelopes := nodes[i].shh.Envelopes()
|
|
|
|
if len(envelopes) < 2 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2016-12-01 13:09:22 -06:00
|
|
|
func sendMsg(t *testing.T, expected bool, id int) {
|
|
|
|
if t.Failed() {
|
2016-10-29 07:11:37 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-04-09 16:49:22 -05:00
|
|
|
opt := MessageParams{KeySym: sharedKey, Topic: sharedTopic, Payload: expectedMessage, PoW: 0.00000001, WorkTime: 1}
|
2016-10-29 07:11:37 -05:00
|
|
|
if !expected {
|
|
|
|
opt.KeySym[0]++
|
|
|
|
opt.Topic[0]++
|
|
|
|
opt.Payload = opt.Payload[1:]
|
|
|
|
}
|
|
|
|
|
2017-04-26 14:05:48 -05:00
|
|
|
msg, err := NewSentMessage(&opt)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed to create new message with seed %d: %s.", seed, err)
|
|
|
|
}
|
2016-10-29 07:11:37 -05:00
|
|
|
envelope, err := msg.Wrap(&opt)
|
|
|
|
if err != nil {
|
2017-04-09 16:49:22 -05:00
|
|
|
t.Fatalf("failed to seal message: %s", err)
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
err = nodes[id].shh.Send(envelope)
|
|
|
|
if err != nil {
|
2017-04-09 16:49:22 -05:00
|
|
|
t.Fatalf("failed to send message: %s", err)
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-01 13:09:22 -06:00
|
|
|
func TestPeerBasic(t *testing.T) {
|
2016-10-29 07:11:37 -05:00
|
|
|
InitSingleTest()
|
|
|
|
|
|
|
|
params, err := generateMessageParams()
|
|
|
|
if err != nil {
|
2016-12-01 13:09:22 -06:00
|
|
|
t.Fatalf("failed generateMessageParams with seed %d.", seed)
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
params.PoW = 0.001
|
2017-04-26 14:05:48 -05:00
|
|
|
msg, err := NewSentMessage(params)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed to create new message with seed %d: %s.", seed, err)
|
|
|
|
}
|
2016-10-29 07:11:37 -05:00
|
|
|
env, err := msg.Wrap(params)
|
|
|
|
if err != nil {
|
2016-12-01 13:09:22 -06:00
|
|
|
t.Fatalf("failed Wrap with seed %d.", seed)
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
p := newPeer(nil, nil, nil)
|
|
|
|
p.mark(env)
|
|
|
|
if !p.marked(env) {
|
2016-12-01 13:09:22 -06:00
|
|
|
t.Fatalf("failed mark with seed %d.", seed)
|
2016-10-29 07:11:37 -05:00
|
|
|
}
|
|
|
|
}
|