-
Notifications
You must be signed in to change notification settings - Fork 266
test: Token gated communities #7113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Jenkins BuildsClick to see older builds (254)
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7113 +/- ##
===========================================
- Coverage 60.08% 55.39% -4.69%
===========================================
Files 811 814 +3
Lines 113220 126375 +13155
===========================================
+ Hits 68023 70005 +1982
- Misses 38392 48870 +10478
- Partials 6805 7500 +695
Flags with carried forward coverage won't be shown. Click here to find out more. |
- test_admin_token_permissions_with_valid_tokens
- cleanup and add additional logging
- test_owner_edits_visible_before_and_after_minting_owner_token
fbarbu15
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
igor-sirotin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @romanzac! 👍
Looks good to me, just a few polishing suggestions
tests-functional/tests/test_wakuext_community_token_permissions.py
Outdated
Show resolved
Hide resolved
tests-functional/tests/test_wakuext_community_token_permissions.py
Outdated
Show resolved
Hide resolved
tests-functional/tests/test_wakuext_community_token_permissions.py
Outdated
Show resolved
Hide resolved
tests-functional/tests/test_wakuext_community_token_permissions.py
Outdated
Show resolved
Hide resolved
| # Fetch community as member | ||
| self.fetch_community(self.member_with_snt, community_id) | ||
|
|
||
| for i in range(10): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These kind of loops and usage of time.sleep are better to be avoided.
It should be possible for self.member_with_snt to wait for a signal about community permissions change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed at ca15d4b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm retry_call does effectively the same thing as trying in a loop.
Instead, ownder should wait for messages.new signal (using wait_for_signal).
In the signal there should be a non-empty requestsToJoinCommunity. This means that the request is received and we're ready to accept_request_to_join_community.
Here's the property:
status-go/protocol/messenger_response.go
Line 68 in 2c48ce7
| requestsToJoinCommunity map[string]*communities.RequestToJoin |
Note that there are some other stuff, e.g. CommunityChanges, which should be useful for these tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pleasant surprise. Let me see how are these events emitted. I see, Websocket transfer!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks during test_membership_with_valid_tokens run there is an inconsistency between received signal and readiness to accept the member to join. My accept_request_to_join_community was failing after I refactored to receive signal. So I added back the retry_call. You can see failed accept_request_to_join_community few times on Unexpected error: {'code': -32000, 'message': 'sql: no rows in result set'}. Was the signal premature or is there another signal more suitable to wait for or problem with my reasoning about signal and the real state of system?
22025-11-27 12:52:30.130 DEBUG Sending POST request to url http://127.0.0.1:16783/statusgo/CallRPC with data: {"id": 5, "jsonrpc": "2.0", "method": "wakuext_requestToJoinCommunity", "params": [{"addressesToReveal": ["0x1f3f31a66e03492f268b8344c7743a2f5b64d81f"], "airdropAddress": "0x1f3f31a66e03492f268b8344c7743a2f5b64d81f", "communityId": "0x02b480a3cc312f3db6aaabc40191bed2809bce59df5f459f7152bd44ccc5660e5f"}]}
2025-11-27 12:52:30.148 DEBUG http://127.0.0.1:16783 "POST /statusgo/CallRPC HTTP/1.1" 200 None
2025-11-27 12:52:30.148 DEBUG Got response: b'{"jsonrpc":"2.0","id":5,"result":{"requestsToJoinCommunity":[{"id":"0xd97933e60201a7ba5c0480ec966d9f10167a1d98cc8725478c8fe7b5e88715b6","publicKey":"0x04b5deee0773aaeb29987fdbde582fff3fa3511c9f686be8a2f6486e23a8e77f4a159d2ed92abe5a6a875e1bd3b187219f1391291403b85149ae167630665e27e4","clock":1764219150,"chatId":"","communityId":"0x02b480a3cc312f3db6aaabc40191bed2809bce59df5f459f7152bd44ccc5660e5f","state":1,"our":true,"deleted":false,"revealedAccounts":[{"address":"0x1f3f31a66e03492f268b8344c7743a2f5b64d81f","chain_ids":[31337],"isAirdropAddress":true}],"customizationColor":"primary","shareFutureAddresses":false}],"notifications":null,"communities":[{"id":"0x02b480a3cc312f3db6aaabc40191bed2809bce59df5f459f7152bd44ccc5660e5f","memberRole":0,"isControlNode":false,"verified":false,"joined":false,"joinedAt":0,"spectated":false,"requestedAccessAt":0,"name":"my 73280","description":"Majority gun policy TV by.","introMessage":"","outroMessage":"","tags":[],"chats":{"b054a343-d8f2-4d08-8404-766924f905e5":{"id":"b054a343-d8f2-4d08-8404-766924f905e5","name":"general","color":"#ffffff","emoji":"","description":"General channel for the community","members":null,"permissions":{"access":1},"canPost":false,"canView":false,"canPostReactions":false,"viewersCanPostReactions":false,"position":0,"categoryID":"","tokenGated":false,"hideIfPermissionsNotMet":false,"missingEncryptionKey":false}},"categories":{},"images":null,"permissions":{"access":3},"members":{"0x047261d3f4edc03adbf2f2aa3018463bfc830d706e60246a14b93107b91dc5399d03ec5c4882665559f4c225cfa2a23768bd64ac35eda992edadf60cbea5880cdb":{"roles":[1]}},"canRequestAccess":true,"canManageUsers":false,"canDeleteMessageForEveryone":false,"canJoin":false,"color":"#ffffff","requestedToJoinAt":1764219150,"isMember":false,"muted":false,"muteTill":"0001-01-01T00:00:00Z","adminSettings":{"pinMessageAllMembersEnabled":false},"encrypted":false,"pendingAndBannedMembers":{},"tokenPermissions":{"80803281-a306-4165-9cd4-59ba5b879ea9":{"id":"80803281-a306-4165-9cd4-59ba5b879ea9","type":1,"token_criteria":[{"contract_addresses":{"31337":"0x9d4454B023096f34B160D6B654540c56A1F81688"},"type":1,"symbol":"SNT","amount":"1e-18","decimals":18,"amountInWei":"1"}]}},"communityTokensMetadata":null,"activeMembersCount":0,"pubsubTopic":"","lastOpenedAt":0,"clock":1764219150115}],"activityCenterNotifications":[{"id":"0xd97933e60201a7ba5c0480ec966d9f10167a1d98cc8725478c8fe7b5e88715b6","chatId":"","communityId":"0x02b480a3cc312f3db6aaabc40191bed2809bce59df5f459f7152bd44ccc5660e5f","membershipStatus":1,"name":"","newsTitle":"","newsDescription":"","newsContent":"","newsImageUrl":"","newsLink":"","newsLinkLabel":"","author":"","installationId":"","type":7,"lastMessage":null,"message":null,"replyMessage":null,"timestamp":1764219150156,"read":true,"dismissed":false,"deleted":false,"accepted":false,"contactVerificationStatus":0,"tokenData":null,"updatedAt":1764219150156,"albumMessages":null}],"activityCenterState":{"hasSeen":true,"updatedAt":0},"discordOldestMessageTimestamp":0}}'
2025-11-27 12:52:30.148 DEBUG Signal SignalType.MESSAGES_NEW is received in 0 seconds
2025-11-27 12:52:30.148 INFO Received signal: {'type': 'messages.new', 'event': {'notifications': None, 'communities': [{'id': '0x02b480a3cc312f3db6aaabc40191bed2809bce59df5f459f7152bd44ccc5660e5f', 'memberRole': 1, 'isControlNode': True, 'verified': False, 'joined': True, 'joinedAt': 1764219150, 'spectated': False, 'requestedAccessAt': 0, 'name': 'my 73280', 'description': 'Majority gun policy TV by.', 'introMessage': '', 'outroMessage': '', 'tags': [], 'chats': {'b054a343-d8f2-4d08-8404-766924f905e5': {'id': 'b054a343-d8f2-4d08-8404-766924f905e5', 'name': 'general', 'color': '#ffffff', 'emoji': '', 'description': 'General channel for the community', 'members': None, 'permissions': {'access': 1}, 'canPost': True, 'canView': True, 'canPostReactions': True, 'viewersCanPostReactions': False, 'position': 0, 'categoryID': '', 'tokenGated': False, 'hideIfPermissionsNotMet': False, 'missingEncryptionKey': False}}, 'categories': {}, 'images': None, 'permissions': {'access': 3}, 'members': {'0x047261d3f4edc03adbf2f2aa3018463bfc830d706e60246a14b93107b91dc5399d03ec5c4882665559f4c225cfa2a23768bd64ac35eda992edadf60cbea5880cdb': {'roles': [1]}}, 'canRequestAccess': False, 'canManageUsers': True, 'canDeleteMessageForEveryone': True, 'canJoin': False, 'color': '#ffffff', 'isMember': True, 'muted': False, 'muteTill': '0001-01-01T00:00:00Z', 'adminSettings': {'pinMessageAllMembersEnabled': False}, 'encrypted': False, 'pendingAndBannedMembers': {}, 'tokenPermissions': {'80803281-a306-4165-9cd4-59ba5b879ea9': {'id': '80803281-a306-4165-9cd4-59ba5b879ea9', 'type': 1, 'token_criteria': [{'contract_addresses': {'31337': '0x9d4454B023096f34B160D6B654540c56A1F81688'}, 'type': 1, 'symbol': 'SNT', 'amount': '1e-18', 'decimals': 18, 'amountInWei': '1'}]}}, 'communityTokensMetadata': None, 'activeMembersCount': 0, 'pubsubTopic': '', 'lastOpenedAt': 0, 'clock': 1764219150115}], 'discordOldestMessageTimestamp': 0}, 'timestamp': 1764219150}
2025-11-27 12:52:30.149 DEBUG Sending POST request to url http://127.0.0.1:7560/statusgo/CallRPC with data: {"id": 4, "jsonrpc": "2.0", "method": "wakuext_acceptRequestToJoinCommunity", "params": [{"id": "0xd97933e60201a7ba5c0480ec966d9f10167a1d98cc8725478c8fe7b5e88715b6"}]}
2025-11-27 12:52:30.150 DEBUG http://127.0.0.1:7560 "POST /statusgo/CallRPC HTTP/1.1" 200 87
2025-11-27 12:52:30.150 DEBUG Got response: b'{"jsonrpc":"2.0","id":4,"error":{"code":-32000,"message":"sql: no rows in result set"}}'
2025-11-27 12:52:30.150 ERROR Attempt 1/40: Unexpected error: {'code': -32000, 'message': 'sql: no rows in result set'}
2025-11-27 12:52:30.654 DEBUG Sending POST request to url http://127.0.0.1:7560/statusgo/CallRPC with data: {"id": 5, "jsonrpc": "2.0", "method": "wakuext_acceptRequestToJoinCommunity", "params": [{"id": "0xd97933e60201a7ba5c0480ec966d9f10167a1d98cc8725478c8fe7b5e88715b6"}]}
2025-11-27 12:52:30.659 DEBUG http://127.0.0.1:7560 "POST /statusgo/CallRPC HTTP/1.1" 200 87
2025-11-27 12:52:30.660 DEBUG Got response: b'{"jsonrpc":"2.0","id":5,"error":{"code":-32000,"message":"sql: no rows in result set"}}'
2025-11-27 12:52:30.660 ERROR Attempt 2/40: Unexpected error: {'code': -32000, 'message': 'sql: no rows in result set'}
2025-11-27 12:52:31.165 DEBUG Sending POST request to url http://127.0.0.1:7560/statusgo/CallRPC with data: {"id": 6, "jsonrpc": "2.0", "method": "wakuext_acceptRequestToJoinCommunity", "params": [{"id": "0xd97933e60201a7ba5c0480ec966d9f10167a1d98cc8725478c8fe7b5e88715b6"}]}
2025-11-27 12:52:31.189 DEBUG http://127.0.0.1:7560 "POST /statusgo/CallRPC HTTP/1.1" 200 None
2025-11-27 12:52:31.189 DEBUG Got response: b'{"jsonrpc":"2.0","id":6,"result":{"requestsToJoinCommunity":[{"id":"0xd97933e60201a7ba5c0480ec966d9f10167a1d98cc8725478c8fe7b5e88715b6","publicKey":"0x04b5deee0773aaeb29987fdbde582fff3fa3511c9f686be8a2f6486e23a8e77f4a159d2ed92abe5a6a875e1bd3b187219f1391291403b85149ae167630665e27e4","clock":1764219150,"chatId":"","communityId":"0x02b480a3cc312f3db6aaabc40191bed2809bce59df5f459f7152bd44ccc5660e5f","state":3,"our":false,"deleted":false,"customizationColor":"primary","shareFutureAddresses":false}],"notifications":null,"communities":[{"id":"0x02b480a3cc312f3db6aaabc40191bed2809bce59df5f459f7152bd44ccc5660e5f","memberRole":1,"isControlNode":true,"verified":false,"joined":true,"joinedAt":1764219150,"spectated":false,"requestedAccessAt":0,"name":"my 73280","description":"Majority gun policy TV by.","introMessage":"","outroMessage":"","tags":[],"chats":{"b054a343-d8f2-4d08-8404-766924f905e5":{"id":"b054a343-d8f2-4d08-8404-766924f905e5","name":"general","color":"#ffffff","emoji":"","description":"General channel for the community","members":null,"permissions":{"access":1},"canPost":true,"canView":true,"canPostReactions":true,"viewersCanPostReactions":false,"position":0,"categoryID":"","tokenGated":false,"hideIfPermissionsNotMet":false,"missingEncryptionKey":false}},"categories":{},"images":null,"permissions":{"access":3},"members":{"0x047261d3f4edc03adbf2f2aa3018463bfc830d706e60246a14b93107b91dc5399d03ec5c4882665559f4c225cfa2a23768bd64ac35eda992edadf60cbea5880cdb":{"roles":[1]},"0x04b5deee0773aaeb29987fdbde582fff3fa3511c9f686be8a2f6486e23a8e77f4a159d2ed92abe5a6a875e1bd3b187219f1391291403b85149ae167630665e27e4":{"last_update_clock":1764219150}},"canRequestAccess":false,"canManageUsers":true,"canDeleteMessageForEveryone":true,"canJoin":false,"color":"#ffffff","isMember":true,"muted":false,"muteTill":"0001-01-01T00:00:00Z","adminSettings":{"pinMessageAllMembersEnabled":false},"encrypted":false,"pendingAndBannedMembers":{},"tokenPermissions":{"80803281-a306-4165-9cd4-59ba5b879ea9":{"id":"80803281-a306-4165-9cd4-59ba5b879ea9","type":1,"token_criteria":[{"contract_addresses":{"31337":"0x9d4454B023096f34B160D6B654540c56A1F81688"},"type":1,"symbol":"SNT","amount":"1e-18","decimals":18,"amountInWei":"1"}]}},"communityTokensMetadata":null,"activeMembersCount":0,"pubsubTopic":"","lastOpenedAt":0,"clock":1764219151184}],"discordOldestMessageTimestamp":0}}'
2025-11-27 12:52:31.190 DEBUG Sending POST request to url http://127.0.0.1:7560/statusgo/CallRPC with data: {"id": 7, "jsonrpc": "2.0", "method": "wakuext_communities"}
2025-11-27 12:52:31.200 DEBUG http://127.0.0.1:7560 "POST /statusgo/CallRPC HTTP/1.1" 200 1839
2025-11-27 12:52:31.200 DEBUG Got response: b'{"jsonrpc":"2.0","id":7,"result":[{"id":"0x02b480a3cc312f3db6aaabc40191bed2809bce59df5f459f7152bd44ccc5660e5f","memberRole":1,"isControlNode":true,"verified":false,"joined":true,"joinedAt":1764219150,"spectated":false,"requestedAccessAt":0,"name":"my 73280","description":"Majority gun policy TV by.","introMessage":"","outroMessage":"","tags":[],"chats":{"b054a343-d8f2-4d08-8404-766924f905e5":{"id":"b054a343-d8f2-4d08-8404-766924f905e5","name":"general","color":"#ffffff","emoji":"","description":"General channel for the community","members":null,"permissions":{"access":1},"canPost":true,"canView":true,"canPostReactions":true,"viewersCanPostReactions":false,"position":0,"categoryID":"","tokenGated":false,"hideIfPermissionsNotMet":false,"missingEncryptionKey":false}},"categories":{},"images":null,"permissions":{"access":3},"members":{"0x047261d3f4edc03adbf2f2aa3018463bfc830d706e60246a14b93107b91dc5399d03ec5c4882665559f4c225cfa2a23768bd64ac35eda992edadf60cbea5880cdb":{"roles":[1]},"0x04b5deee0773aaeb29987fdbde582fff3fa3511c9f686be8a2f6486e23a8e77f4a159d2ed92abe5a6a875e1bd3b187219f1391291403b85149ae167630665e27e4":{"last_update_clock":1764219150}},"canRequestAccess":false,"canManageUsers":true,"canDeleteMessageForEveryone":true,"canJoin":false,"color":"#ffffff","isMember":true,"muted":false,"muteTill":"0001-01-01T00:00:00Z","adminSettings":{"pinMessageAllMembersEnabled":false},"encrypted":false,"pendingAndBannedMembers":{},"tokenPermissions":{"80803281-a306-4165-9cd4-59ba5b879ea9":{"id":"80803281-a306-4165-9cd4-59ba5b879ea9","type":1,"token_criteria":[{"contract_addresses":{"31337":"0x9d4454B023096f34B160D6B654540c56A1F81688"},"type":1,"symbol":"SNT","amount":"1e-18","decimals":18,"amountInWei":"1"}]}},"communityTokensMetadata":null,"activeMembersCount":0,"pubsubTopic":"","lastOpenedAt":0,"clock":1764219151184}]}'
PASSED [ 66%]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened issue for this one #7161 Singals are beautiful, but demanding on state consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replied in the ticket
tests-functional/tests/test_wakuext_community_token_permissions.py
Outdated
Show resolved
Hide resolved
| assert accept_resp is not None, f"Failed to accept request: {accept_resp}" | ||
|
|
||
| # Explicitly reevaluate community members so token-based roles are applied | ||
| self.owner.wakuext_service.reevaluate_community_members_permissions(community_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be done automatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Evaluation removed at cbfd86f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably where we can wait for new.messages signal and check CommunityChanges
there's this signal that you should wait for here:
| MemberReevaluationStatus = "community.memberReevaluationStatus" |
tests-functional/tests/test_wakuext_community_token_permissions.py
Outdated
Show resolved
Hide resolved
49ce18a to
d1a9df7
Compare
- community.memberReevaluationStatus
Summary
An initial batch of functional tests to cover token-gated communities.
Tests Included
Issues discovered