Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
54aec358
Commit
54aec358
authored
6 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Fix None exception in state res v2
parent
1b21e771
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/state/v2.py
+4
-0
4 additions, 0 deletions
synapse/state/v2.py
tests/state/test_v2.py
+98
-2
98 additions, 2 deletions
tests/state/test_v2.py
with
102 additions
and
2 deletions
synapse/state/v2.py
+
4
−
0
View file @
54aec358
...
@@ -53,6 +53,10 @@ def resolve_events_with_store(state_sets, event_map, state_res_store):
...
@@ -53,6 +53,10 @@ def resolve_events_with_store(state_sets, event_map, state_res_store):
logger
.
debug
(
"
Computing conflicted state
"
)
logger
.
debug
(
"
Computing conflicted state
"
)
# We use event_map as a cache, so if its None we need to initialize it
if
event_map
is
None
:
event_map
=
{}
# First split up the un/conflicted state
# First split up the un/conflicted state
unconflicted_state
,
conflicted_state
=
_seperate
(
state_sets
)
unconflicted_state
,
conflicted_state
=
_seperate
(
state_sets
)
...
...
This diff is collapsed.
Click to expand it.
tests/state/test_v2.py
+
98
−
2
View file @
54aec358
...
@@ -544,8 +544,7 @@ class StateTestCase(unittest.TestCase):
...
@@ -544,8 +544,7 @@ class StateTestCase(unittest.TestCase):
state_res_store
=
TestStateResolutionStore
(
event_map
),
state_res_store
=
TestStateResolutionStore
(
event_map
),
)
)
self
.
assertTrue
(
state_d
.
called
)
state_before
=
self
.
successResultOf
(
state_d
)
state_before
=
state_d
.
result
state_after
=
dict
(
state_before
)
state_after
=
dict
(
state_before
)
if
fake_event
.
state_key
is
not
None
:
if
fake_event
.
state_key
is
not
None
:
...
@@ -599,6 +598,103 @@ class LexicographicalTestCase(unittest.TestCase):
...
@@ -599,6 +598,103 @@ class LexicographicalTestCase(unittest.TestCase):
self
.
assertEqual
([
"
o
"
,
"
l
"
,
"
n
"
,
"
m
"
,
"
p
"
],
res
)
self
.
assertEqual
([
"
o
"
,
"
l
"
,
"
n
"
,
"
m
"
,
"
p
"
],
res
)
class
SimpleParamStateTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
# We build up a simple DAG.
event_map
=
{}
create_event
=
FakeEvent
(
id
=
"
CREATE
"
,
sender
=
ALICE
,
type
=
EventTypes
.
Create
,
state_key
=
""
,
content
=
{
"
creator
"
:
ALICE
},
).
to_event
([],
[])
event_map
[
create_event
.
event_id
]
=
create_event
alice_member
=
FakeEvent
(
id
=
"
IMA
"
,
sender
=
ALICE
,
type
=
EventTypes
.
Member
,
state_key
=
ALICE
,
content
=
MEMBERSHIP_CONTENT_JOIN
,
).
to_event
([
create_event
.
event_id
],
[
create_event
.
event_id
])
event_map
[
alice_member
.
event_id
]
=
alice_member
join_rules
=
FakeEvent
(
id
=
"
IJR
"
,
sender
=
ALICE
,
type
=
EventTypes
.
JoinRules
,
state_key
=
""
,
content
=
{
"
join_rule
"
:
JoinRules
.
PUBLIC
},
).
to_event
(
auth_events
=
[
create_event
.
event_id
,
alice_member
.
event_id
],
prev_events
=
[
alice_member
.
event_id
],
)
event_map
[
join_rules
.
event_id
]
=
join_rules
# Bob and Charlie join at the same time, so there is a fork
bob_member
=
FakeEvent
(
id
=
"
IMB
"
,
sender
=
BOB
,
type
=
EventTypes
.
Member
,
state_key
=
BOB
,
content
=
MEMBERSHIP_CONTENT_JOIN
,
).
to_event
(
auth_events
=
[
create_event
.
event_id
,
join_rules
.
event_id
],
prev_events
=
[
join_rules
.
event_id
],
)
event_map
[
bob_member
.
event_id
]
=
bob_member
charlie_member
=
FakeEvent
(
id
=
"
IMC
"
,
sender
=
CHARLIE
,
type
=
EventTypes
.
Member
,
state_key
=
CHARLIE
,
content
=
MEMBERSHIP_CONTENT_JOIN
,
).
to_event
(
auth_events
=
[
create_event
.
event_id
,
join_rules
.
event_id
],
prev_events
=
[
join_rules
.
event_id
],
)
event_map
[
charlie_member
.
event_id
]
=
charlie_member
self
.
event_map
=
event_map
self
.
create_event
=
create_event
self
.
alice_member
=
alice_member
self
.
join_rules
=
join_rules
self
.
bob_member
=
bob_member
self
.
charlie_member
=
charlie_member
self
.
state_at_bob
=
{
(
e
.
type
,
e
.
state_key
):
e
.
event_id
for
e
in
[
create_event
,
alice_member
,
join_rules
,
bob_member
]
}
self
.
state_at_charlie
=
{
(
e
.
type
,
e
.
state_key
):
e
.
event_id
for
e
in
[
create_event
,
alice_member
,
join_rules
,
charlie_member
]
}
self
.
expected_combined_state
=
{
(
e
.
type
,
e
.
state_key
):
e
.
event_id
for
e
in
[
create_event
,
alice_member
,
join_rules
,
bob_member
,
charlie_member
]
}
def
test_event_map_none
(
self
):
# Test that we correctly handle passing `None` as the event_map
state_d
=
resolve_events_with_store
(
[
self
.
state_at_bob
,
self
.
state_at_charlie
],
event_map
=
None
,
state_res_store
=
TestStateResolutionStore
(
self
.
event_map
),
)
state
=
self
.
successResultOf
(
state_d
)
self
.
assert_dict
(
self
.
expected_combined_state
,
state
)
def
pairwise
(
iterable
):
def
pairwise
(
iterable
):
"
s -> (s0,s1), (s1,s2), (s2, s3), ...
"
"
s -> (s0,s1), (s1,s2), (s2, s3), ...
"
a
,
b
=
itertools
.
tee
(
iterable
)
a
,
b
=
itertools
.
tee
(
iterable
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment