-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Johannes Ernst <git@j12t.org>
- Loading branch information
Showing
3 changed files
with
201 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,76 @@ | ||
# https://github.com/fediverse-devnet/feditest-tests-fediverse/issues/150 | ||
# | ||
# Can this be done meaningfully with two Actors instead of three | ||
# | ||
# Three nodes | ||
# A follows B | ||
# C creates Note X | ||
# B accesses X | ||
# B announces X | ||
# A receives the announcement | ||
""" | ||
Tests that a note by actor A can be announced by an actor B on a different Fediverse Node | ||
and the announce is seen by actor C that is following B. | ||
To not complicate constellation setup and stay with two Nodes, we have actors A and C on the same Node. | ||
""" | ||
|
||
from datetime import datetime | ||
|
||
from feditest import AssertionFailure, InteropLevel, SpecLevel, assert_that, step, test | ||
from feditest.protocols.fediverse import FediverseNode | ||
|
||
@test | ||
class AnnounceTest: | ||
def __init__(self, | ||
node1: FediverseNode, | ||
node2: FediverseNode | ||
) -> None: | ||
self.node1 = node1 | ||
self.node1_poster_actor_uri = None | ||
self.node1_follower_actor_uri = None | ||
|
||
self.node2 = node2 | ||
self.node2_announcer_actor_uri = None | ||
|
||
self.note_uri = None | ||
self.note_content = f'Testing announce {datetime.now()}' | ||
|
||
|
||
@step | ||
def provision_actors(self): | ||
self.node1_poster_actor_uri = self.node1.obtain_actor_document_uri('poster') | ||
assert self.node1_poster_actor_uri | ||
print( f'XXX poster: { self.node1_poster_actor_uri }') | ||
|
||
self.node2_announcer_actor_uri = self.node2.obtain_actor_document_uri('announcer') | ||
assert self.node2_announcer_actor_uri | ||
print( f'XXX announcer: { self.node2_announcer_actor_uri }') | ||
|
||
self.node1_follower_actor_uri = self.node1.obtain_actor_document_uri('follower') | ||
assert self.node1_follower_actor_uri | ||
print( f'XXX follower: { self.node1_follower_actor_uri }') | ||
|
||
|
||
@step | ||
def follow(self): | ||
self.node1.make_follow(self.node1_follower_actor_uri, self.node2_announcer_actor_uri) | ||
self.node2.wait_until_actor_is_followed_by_actor(self.node2_announcer_actor_uri, self.node1_follower_actor_uri) | ||
self.node1.wait_until_actor_is_following_actor(self.node1_follower_actor_uri, self.node2_announcer_actor_uri) | ||
|
||
|
||
@step | ||
def poster_creates_note(self): | ||
self.note_uri = self.node1.make_create_note(self.node1_poster_actor_uri, self.note_content) | ||
assert self.note_uri # We expect that this works: tests the node1 Node implementation | ||
|
||
|
||
@step | ||
def booster_boosts(self): | ||
# This may throw an exception if node2 could not find the note | ||
self.node2.make_announce(self.node2_announcer_actor_uri, self.note_uri) | ||
|
||
|
||
@step | ||
def wait_until_boost_received_by_follower(self): | ||
try: | ||
received_content = self.node1.wait_until_actor_has_received_note(self.node1_follower_actor_uri, self.note_uri) | ||
|
||
except TimeoutError as e: | ||
raise AssertionFailure(SpecLevel.MUST, InteropLevel.PROBLEM, e) | ||
|
||
if self.note_content not in received_content: | ||
raise AssertionFailure(SpecLevel.MUST, InteropLevel.PROBLEM, f'Received anounce does not contain payload: "{ received_content }".') | ||
|
||
if self.note_content != received_content: | ||
raise AssertionFailure(SpecLevel.IMPLIED, InteropLevel.DEGRADED, f'Received announce modified from original: "{ received_content }".') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
""" | ||
Tests that a note by actor A can be Replied by an actor B on a different Fediverse Node | ||
and both see the Reply. | ||
""" | ||
|
||
from datetime import datetime | ||
|
||
from feditest import AssertionFailure, InteropLevel, SpecLevel, assert_that, step, test | ||
from feditest.protocols.fediverse import FediverseNode | ||
|
||
@test | ||
class ReplyTest: | ||
def __init__(self, | ||
leader_node: FediverseNode, | ||
follower_node: FediverseNode | ||
) -> None: | ||
self.leader_node = leader_node | ||
self.leader_actor_uri = None | ||
|
||
self.follower_node = follower_node | ||
self.follower_actor_uri = None | ||
|
||
self.leader_note_uri = None | ||
self.follower_reply_uri = None | ||
self.reply_content = f'Testing follower_replies_to_note {datetime.now()}' | ||
|
||
|
||
@step | ||
def provision_actors(self): | ||
self.leader_actor_uri = self.leader_node.obtain_actor_document_uri() | ||
assert self.leader_actor_uri | ||
|
||
self.follower_actor_uri = self.follower_node.obtain_actor_document_uri() | ||
assert self.follower_actor_uri | ||
|
||
|
||
@step | ||
def leader_creates_note(self): | ||
self.leader_note_uri = self.leader_node.make_create_note(self.leader_actor_uri, f"Testing leader_creates_note {datetime.now()}") | ||
assert self.leader_note_uri # We expect that this works: tests the leader_node Node implementation | ||
|
||
|
||
@step | ||
def follower_replies_to_note(self): | ||
# This may throw an exception if the follower_node could not find the leader_note | ||
self.follower_reply_uri = self.follower_node.make_reply_note(self.follower_actor_uri, self.leader_note_uri, self.reply_content) | ||
assert self.follower_reply_uri # We expect that this works: tests the follower_node Node implementation | ||
|
||
|
||
@step | ||
def wait_until_reply_received_by_follower(self): | ||
received_content = self.follower_node.wait_until_actor_has_received_note(self.follower_actor_uri, self.follower_reply_uri) | ||
assert self.reply_content in received_content # We expect that this works: tests the follower_node Node implementation | ||
|
||
|
||
@step | ||
def wait_until_reply_received_by_leader(self): | ||
try: | ||
received_content = self.leader_node.wait_until_actor_has_received_note(self.leader_actor_uri, self.follower_reply_uri) | ||
|
||
except TimeoutError as e: | ||
raise AssertionFailure(SpecLevel.MUST, InteropLevel.PROBLEM, e) | ||
|
||
if self.reply_content not in received_content: | ||
raise AssertionFailure(SpecLevel.MUST, InteropLevel.PROBLEM, f'Received reply does not contain payload: "{ received_content }".') | ||
|
||
if self.reply_content != received_content: | ||
raise AssertionFailure(SpecLevel.IMPLIED, InteropLevel.DEGRADED, f'Received reply modified from original: "{ received_content }".') |