|
|
|
@ -51,14 +51,14 @@ var ( |
|
|
|
|
testGetReceiptsRequest = syncpb.MakeGetReceiptsRequest(testGetReceipts) |
|
|
|
|
testGetReceiptsRequestMsg = syncpb.MakeMessageFromRequest(testGetReceiptsRequest) |
|
|
|
|
|
|
|
|
|
testGetNodeData = []common.Hash{ |
|
|
|
|
testGetNodes = []common.Hash{ |
|
|
|
|
numberToHash(1), |
|
|
|
|
numberToHash(2), |
|
|
|
|
numberToHash(3), |
|
|
|
|
numberToHash(4), |
|
|
|
|
numberToHash(5), |
|
|
|
|
} |
|
|
|
|
testGetNodeDataRequest = syncpb.MakeGetNodeDataRequest(testGetNodeData) |
|
|
|
|
testGetNodeDataRequest = syncpb.MakeGetNodeDataRequest(testGetNodes) |
|
|
|
|
testGetNodeDataRequestMsg = syncpb.MakeMessageFromRequest(testGetNodeDataRequest) |
|
|
|
|
|
|
|
|
|
maxBytes = uint64(500) |
|
|
|
@ -296,6 +296,27 @@ func TestSyncStream_HandleGetTrieNodes(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestSyncStream_HandleGetNodeData(t *testing.T) { |
|
|
|
|
st, remoteSt := makeTestSyncStream() |
|
|
|
|
|
|
|
|
|
go st.run() |
|
|
|
|
defer close(st.closeC) |
|
|
|
|
|
|
|
|
|
req := testGetNodeDataRequestMsg |
|
|
|
|
b, _ := protobuf.Marshal(req) |
|
|
|
|
err := remoteSt.WriteBytes(b) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatal(err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
time.Sleep(200 * time.Millisecond) |
|
|
|
|
receivedBytes, _ := remoteSt.ReadBytes() |
|
|
|
|
|
|
|
|
|
if err := checkGetNodeDataResult(receivedBytes, testGetBlockByHashes); err != nil { |
|
|
|
|
t.Fatal(err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func makeTestSyncStream() (*syncStream, *testRemoteBaseStream) { |
|
|
|
|
localRaw, remoteRaw := makePairP2PStreams() |
|
|
|
|
remote := newTestRemoteBaseStream(remoteRaw) |
|
|
|
|