viff

changeset 615:743ac108951a

Test sending multiple times with the same program counter.
author Martin Geisler <mg@daimi.au.dk>
date Fri, 28 Mar 2008 23:38:07 +0100
parents b550d4457d60
children c5d4e1fe7c42
files viff/test/test_basic_runtime.py
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/viff/test/test_basic_runtime.py	Fri Mar 28 17:20:22 2008 +0100
     1.2 +++ b/viff/test/test_basic_runtime.py	Fri Mar 28 23:38:07 2008 +0100
     1.3 @@ -133,3 +133,29 @@
     1.4          return gatherResults([d1, d2])
     1.5      test_multiple_callbacks.skip = ("TODO: Scheduling callbacks fails to "
     1.6                                      "increment program counter!")
     1.7 +
     1.8 +    @protocol
     1.9 +    def test_multi_send(self, runtime):
    1.10 +        """Test sending multiple times from a Runtime method."""
    1.11 +
    1.12 +        # First send a couple of times to everybody.
    1.13 +        for peer_id in range(1, self.num_players+1):
    1.14 +            if peer_id != runtime.id:
    1.15 +                pc = tuple(runtime.program_counter)
    1.16 +                runtime.protocols[peer_id].sendData(pc, "test", 100)
    1.17 +                runtime.protocols[peer_id].sendData(pc, "test", 200)
    1.18 +                runtime.protocols[peer_id].sendData(pc, "test", 300)
    1.19 +
    1.20 +        # Then receive the data.
    1.21 +        deferreds = []
    1.22 +        for peer_id in range(1, self.num_players+1):
    1.23 +            if peer_id != runtime.id:
    1.24 +                d100 = Deferred().addCallback(self.assertEquals, 100)
    1.25 +                d200 = Deferred().addCallback(self.assertEquals, 200)
    1.26 +                d300 = Deferred().addCallback(self.assertEquals, 300)
    1.27 +                runtime._expect_data(peer_id, "test", d100)
    1.28 +                runtime._expect_data(peer_id, "test", d200)
    1.29 +                runtime._expect_data(peer_id, "test", d300)
    1.30 +                deferreds.extend([d100, d200, d300])
    1.31 +
    1.32 +        return gatherResults(deferreds)