Hello,
I have to�� made this challenge as last on of the OOP book
Servers answering requests
When a server node consumes a
packet, it converts the payload to uppercase,
then sends that back to the sender of the request.
This is yet another subclass which
redefines the consume: method, but this
time the node is stateless, so we have no initialization or
accessor methods to
write:
KANetworkNode
subclass: #KANetworkServer
instanceVariableNames: ''
classVariableNames: ''
category: 'NetworkSimulator-Nodes'
KANetworkServer >> consume: aPacket
| response |
response := aPacket payload asUppercase.
self send: (KANetworkPacket
from: self address
to: aPacket sourceAddress
payload: response)
Define a test for the behavior of
server nodes.
I tried but I miss something
so far as I have this :
testSendToServer
������ | packet ping pong link |
������ packet := KANetworkPacket from: #ping to: #pong payload: #ball.
������ ping := net nodeAt: #ping.
������ pong := net nodeAt: #pong.
������ link := net linkFrom: #ping to: #pong.
������ ping send: packet.
������ pong consume: packet.
but whatever I tried I cannot think of a test that works.
I tried
assert:�� ping payload equals: #BALL
assert: ping arrievedpackages equals; 1
but they all fail
It looks like ping does not recieve the package back.
What do I do wrong or what can I test better ?
my code so far : https://github.com/RoelofWobben/network
and the problem is the testToServerTest that I cannot make work
Regards,
Roelof
��