2023-06-14 14:15:46 +00:00
|
|
|
package protocol
|
|
|
|
|
|
|
|
import (
|
2023-08-04 10:28:46 +00:00
|
|
|
"math/big"
|
2023-06-14 14:15:46 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
|
2023-08-08 15:02:56 +00:00
|
|
|
gethcommon "github.com/ethereum/go-ethereum/common"
|
|
|
|
hexutil "github.com/ethereum/go-ethereum/common/hexutil"
|
|
|
|
|
2023-06-14 14:15:46 +00:00
|
|
|
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth"
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
|
|
|
"github.com/status-im/status-go/protocol/common"
|
2023-08-08 13:16:29 +00:00
|
|
|
"github.com/status-im/status-go/protocol/communities"
|
2023-07-07 13:03:37 +00:00
|
|
|
"github.com/status-im/status-go/protocol/communities/token"
|
2023-06-14 14:15:46 +00:00
|
|
|
"github.com/status-im/status-go/protocol/protobuf"
|
2023-08-08 13:16:29 +00:00
|
|
|
"github.com/status-im/status-go/protocol/requests"
|
2023-06-14 14:15:46 +00:00
|
|
|
"github.com/status-im/status-go/protocol/tt"
|
2023-08-04 10:28:46 +00:00
|
|
|
"github.com/status-im/status-go/services/wallet/bigint"
|
2023-06-14 14:15:46 +00:00
|
|
|
"github.com/status-im/status-go/waku"
|
|
|
|
)
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func TestAdminCommunityEventsSuite(t *testing.T) {
|
|
|
|
suite.Run(t, new(AdminCommunityEventsSuite))
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
type AdminCommunityEventsSuite struct {
|
2023-06-14 14:15:46 +00:00
|
|
|
suite.Suite
|
|
|
|
owner *Messenger
|
|
|
|
admin *Messenger
|
|
|
|
alice *Messenger
|
|
|
|
// If one wants to send messages between different instances of Messenger,
|
|
|
|
// a single Waku service should be shared.
|
2023-08-22 17:48:42 +00:00
|
|
|
shh types.Waku
|
|
|
|
logger *zap.Logger
|
|
|
|
mockedBalances map[uint64]map[gethcommon.Address]map[gethcommon.Address]*hexutil.Big // chainID, account, token, balance
|
|
|
|
collectiblesServiceMock *CollectiblesServiceMock
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) GetControlNode() *Messenger {
|
|
|
|
return s.owner
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) GetEventSender() *Messenger {
|
|
|
|
return s.admin
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) GetMember() *Messenger {
|
|
|
|
return s.alice
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) GetSuite() *suite.Suite {
|
|
|
|
return &s.Suite
|
|
|
|
}
|
|
|
|
|
2023-08-22 17:48:42 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) GetCollectiblesServiceMock() *CollectiblesServiceMock {
|
|
|
|
return s.collectiblesServiceMock
|
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) SetupTest() {
|
2023-06-14 14:15:46 +00:00
|
|
|
s.logger = tt.MustCreateTestLogger()
|
2023-08-22 17:48:42 +00:00
|
|
|
s.collectiblesServiceMock = &CollectiblesServiceMock{}
|
2023-06-14 14:15:46 +00:00
|
|
|
|
|
|
|
config := waku.DefaultConfig
|
|
|
|
config.MinimumAcceptedPoW = 0
|
|
|
|
shh := waku.New(&config, s.logger)
|
|
|
|
s.shh = gethbridge.NewGethWakuWrapper(shh)
|
|
|
|
s.Require().NoError(shh.Start())
|
|
|
|
|
2023-08-08 15:02:56 +00:00
|
|
|
s.owner = s.newMessenger("", []string{})
|
2023-09-20 08:37:46 +00:00
|
|
|
s.admin = s.newMessenger(accountPassword, []string{eventsSenderAccountAddress})
|
|
|
|
s.alice = s.newMessenger(accountPassword, []string{aliceAccountAddress})
|
2023-06-14 14:15:46 +00:00
|
|
|
_, err := s.owner.Start()
|
|
|
|
s.Require().NoError(err)
|
|
|
|
_, err = s.admin.Start()
|
|
|
|
s.Require().NoError(err)
|
|
|
|
_, err = s.alice.Start()
|
|
|
|
s.Require().NoError(err)
|
2023-08-08 15:02:56 +00:00
|
|
|
|
|
|
|
s.mockedBalances = createMockedWalletBalance(&s.Suite)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TearDownTest() {
|
2023-06-14 14:15:46 +00:00
|
|
|
s.Require().NoError(s.owner.Shutdown())
|
|
|
|
s.Require().NoError(s.admin.Shutdown())
|
|
|
|
s.Require().NoError(s.alice.Shutdown())
|
|
|
|
_ = s.logger.Sync()
|
|
|
|
}
|
|
|
|
|
2023-08-08 15:02:56 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) newMessenger(password string, walletAddresses []string) *Messenger {
|
2023-08-22 17:48:42 +00:00
|
|
|
return newMessenger(&s.Suite, s.shh, s.logger, password, walletAddresses, &s.mockedBalances, s.collectiblesServiceMock)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminEditCommunityDescription() {
|
2023-06-14 14:15:46 +00:00
|
|
|
// TODO admin test: update to include edit tags, logo, banner, request to join required setting, pin setting, etc...
|
2023-07-26 12:16:50 +00:00
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
editCommunityDescription(s, community)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminCreateEditDeleteChannels() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testCreateEditDeleteChannels(s, community)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminCreateEditDeleteBecomeMemberPermission() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
2023-08-08 15:02:56 +00:00
|
|
|
testCreateEditDeleteBecomeMemberPermission(s, community, protobuf.CommunityTokenPermission_BECOME_MEMBER)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminCannotCreateBecomeAdminPermission() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
2023-08-08 15:02:56 +00:00
|
|
|
testEventSenderCannotCreatePrivilegedCommunityPermission(s, community, protobuf.CommunityTokenPermission_BECOME_ADMIN)
|
|
|
|
}
|
2023-06-14 14:15:46 +00:00
|
|
|
|
2023-08-08 15:02:56 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminCannotCreateBecomeTokenMasterPermission() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testEventSenderCannotCreatePrivilegedCommunityPermission(s, community, protobuf.CommunityTokenPermission_BECOME_TOKEN_MASTER)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminCannotEditBecomeAdminPermission() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
2023-08-08 15:02:56 +00:00
|
|
|
testEventSenderCannotEditPrivilegedCommunityPermission(
|
|
|
|
s, community, protobuf.CommunityTokenPermission_BECOME_ADMIN, protobuf.CommunityTokenPermission_BECOME_ADMIN)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminCannotEditBecomeTokenMasterPermission() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testEventSenderCannotEditPrivilegedCommunityPermission(
|
|
|
|
s, community, protobuf.CommunityTokenPermission_BECOME_TOKEN_MASTER, protobuf.CommunityTokenPermission_BECOME_ADMIN)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminCannotDeleteBecomeAdminPermission() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
2023-08-08 15:02:56 +00:00
|
|
|
testEventSenderCannotDeletePrivilegedCommunityPermission(
|
|
|
|
s, community, protobuf.CommunityTokenPermission_BECOME_ADMIN, protobuf.CommunityTokenPermission_BECOME_ADMIN)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminCannotDeleteBecomeTokenMasterPermission() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testEventSenderCannotDeletePrivilegedCommunityPermission(
|
|
|
|
s, community, protobuf.CommunityTokenPermission_BECOME_TOKEN_MASTER, protobuf.CommunityTokenPermission_BECOME_ADMIN)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.
Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.
This commit changes this behaviour such that:
1. EventSenders can make a decision (accept, reject), but merely forward
their decision to the control node, which ultimately has to confirm
it
2. EventSenders are no longer removing or adding members to and from
communities
3. When an eventsender signaled a decision, the membership request will
enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
override that decision
This implementation is covered with a bunch of tests:
- Ensure that decision made by event sender is shared with other event
senders
- `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
confirmed decision by event senders
- `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
- `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
event senders
- `testEventSenderCannotOverrideRequestToJoinState()`
These test cases live in three test suites for different event sender
types respectively
- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`
In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).
Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.
This commit does not yet handle the case of event senders attempting to
kick and ban members.
Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-02 12:04:47 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders() {
|
2023-09-20 08:37:46 +00:00
|
|
|
additionalAdmin := s.newMessenger("qwerty", []string{eventsSenderAccountAddress})
|
refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.
Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.
This commit changes this behaviour such that:
1. EventSenders can make a decision (accept, reject), but merely forward
their decision to the control node, which ultimately has to confirm
it
2. EventSenders are no longer removing or adding members to and from
communities
3. When an eventsender signaled a decision, the membership request will
enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
override that decision
This implementation is covered with a bunch of tests:
- Ensure that decision made by event sender is shared with other event
senders
- `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
confirmed decision by event senders
- `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
- `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
event senders
- `testEventSenderCannotOverrideRequestToJoinState()`
These test cases live in three test suites for different event sender
types respectively
- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`
In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).
Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.
This commit does not yet handle the case of event senders attempting to
kick and ban members.
Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-02 12:04:47 +00:00
|
|
|
community := setUpOnRequestCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN, []*Messenger{additionalAdmin})
|
|
|
|
// set up additional user that will send request to join
|
2023-08-08 15:02:56 +00:00
|
|
|
user := s.newMessenger("", []string{})
|
refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.
Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.
This commit changes this behaviour such that:
1. EventSenders can make a decision (accept, reject), but merely forward
their decision to the control node, which ultimately has to confirm
it
2. EventSenders are no longer removing or adding members to and from
communities
3. When an eventsender signaled a decision, the membership request will
enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
override that decision
This implementation is covered with a bunch of tests:
- Ensure that decision made by event sender is shared with other event
senders
- `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
confirmed decision by event senders
- `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
- `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
event senders
- `testEventSenderCannotOverrideRequestToJoinState()`
These test cases live in three test suites for different event sender
types respectively
- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`
In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).
Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.
This commit does not yet handle the case of event senders attempting to
kick and ban members.
Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-02 12:04:47 +00:00
|
|
|
testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders(s, community, user, additionalAdmin)
|
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminAcceptMemberRequestToJoin() {
|
refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.
Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.
This commit changes this behaviour such that:
1. EventSenders can make a decision (accept, reject), but merely forward
their decision to the control node, which ultimately has to confirm
it
2. EventSenders are no longer removing or adding members to and from
communities
3. When an eventsender signaled a decision, the membership request will
enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
override that decision
This implementation is covered with a bunch of tests:
- Ensure that decision made by event sender is shared with other event
senders
- `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
confirmed decision by event senders
- `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
- `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
event senders
- `testEventSenderCannotOverrideRequestToJoinState()`
These test cases live in three test suites for different event sender
types respectively
- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`
In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).
Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.
This commit does not yet handle the case of event senders attempting to
kick and ban members.
Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-02 12:04:47 +00:00
|
|
|
community := setUpOnRequestCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN, []*Messenger{})
|
2023-06-14 14:15:46 +00:00
|
|
|
|
|
|
|
// set up additional user that will send request to join
|
2023-08-08 15:02:56 +00:00
|
|
|
user := s.newMessenger("", []string{})
|
2023-07-26 12:16:50 +00:00
|
|
|
testAcceptMemberRequestToJoin(s, community, user)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.
Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.
This commit changes this behaviour such that:
1. EventSenders can make a decision (accept, reject), but merely forward
their decision to the control node, which ultimately has to confirm
it
2. EventSenders are no longer removing or adding members to and from
communities
3. When an eventsender signaled a decision, the membership request will
enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
override that decision
This implementation is covered with a bunch of tests:
- Ensure that decision made by event sender is shared with other event
senders
- `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
confirmed decision by event senders
- `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
- `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
event senders
- `testEventSenderCannotOverrideRequestToJoinState()`
These test cases live in three test suites for different event sender
types respectively
- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`
In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).
Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.
This commit does not yet handle the case of event senders attempting to
kick and ban members.
Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-02 12:04:47 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminRejectMemberRequestToJoinResponseSharedWithOtherEventSenders() {
|
2023-09-20 08:37:46 +00:00
|
|
|
additionalAdmin := s.newMessenger("qwerty", []string{eventsSenderAccountAddress})
|
refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.
Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.
This commit changes this behaviour such that:
1. EventSenders can make a decision (accept, reject), but merely forward
their decision to the control node, which ultimately has to confirm
it
2. EventSenders are no longer removing or adding members to and from
communities
3. When an eventsender signaled a decision, the membership request will
enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
override that decision
This implementation is covered with a bunch of tests:
- Ensure that decision made by event sender is shared with other event
senders
- `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
confirmed decision by event senders
- `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
- `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
event senders
- `testEventSenderCannotOverrideRequestToJoinState()`
These test cases live in three test suites for different event sender
types respectively
- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`
In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).
Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.
This commit does not yet handle the case of event senders attempting to
kick and ban members.
Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-02 12:04:47 +00:00
|
|
|
community := setUpOnRequestCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN, []*Messenger{additionalAdmin})
|
|
|
|
// set up additional user that will send request to join
|
2023-08-08 15:02:56 +00:00
|
|
|
user := s.newMessenger("", []string{})
|
refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.
Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.
This commit changes this behaviour such that:
1. EventSenders can make a decision (accept, reject), but merely forward
their decision to the control node, which ultimately has to confirm
it
2. EventSenders are no longer removing or adding members to and from
communities
3. When an eventsender signaled a decision, the membership request will
enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
override that decision
This implementation is covered with a bunch of tests:
- Ensure that decision made by event sender is shared with other event
senders
- `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
confirmed decision by event senders
- `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
- `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
event senders
- `testEventSenderCannotOverrideRequestToJoinState()`
These test cases live in three test suites for different event sender
types respectively
- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`
In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).
Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.
This commit does not yet handle the case of event senders attempting to
kick and ban members.
Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-02 12:04:47 +00:00
|
|
|
testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders(s, community, user, additionalAdmin)
|
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminRejectMemberRequestToJoin() {
|
refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.
Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.
This commit changes this behaviour such that:
1. EventSenders can make a decision (accept, reject), but merely forward
their decision to the control node, which ultimately has to confirm
it
2. EventSenders are no longer removing or adding members to and from
communities
3. When an eventsender signaled a decision, the membership request will
enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
override that decision
This implementation is covered with a bunch of tests:
- Ensure that decision made by event sender is shared with other event
senders
- `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
confirmed decision by event senders
- `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
- `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
event senders
- `testEventSenderCannotOverrideRequestToJoinState()`
These test cases live in three test suites for different event sender
types respectively
- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`
In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).
Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.
This commit does not yet handle the case of event senders attempting to
kick and ban members.
Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-02 12:04:47 +00:00
|
|
|
community := setUpOnRequestCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN, []*Messenger{})
|
2023-06-14 14:15:46 +00:00
|
|
|
|
|
|
|
// set up additional user that will send request to join
|
2023-08-08 15:02:56 +00:00
|
|
|
user := s.newMessenger("", []string{})
|
2023-07-26 12:16:50 +00:00
|
|
|
testRejectMemberRequestToJoin(s, community, user)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.
Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.
This commit changes this behaviour such that:
1. EventSenders can make a decision (accept, reject), but merely forward
their decision to the control node, which ultimately has to confirm
it
2. EventSenders are no longer removing or adding members to and from
communities
3. When an eventsender signaled a decision, the membership request will
enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
override that decision
This implementation is covered with a bunch of tests:
- Ensure that decision made by event sender is shared with other event
senders
- `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
confirmed decision by event senders
- `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
- `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
event senders
- `testEventSenderCannotOverrideRequestToJoinState()`
These test cases live in three test suites for different event sender
types respectively
- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`
In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).
Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.
This commit does not yet handle the case of event senders attempting to
kick and ban members.
Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-02 12:04:47 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminControlNodeHandlesMultipleEventSenderRequestToJoinDecisions() {
|
2023-09-20 08:37:46 +00:00
|
|
|
additionalAdmin := s.newMessenger("qwerty", []string{eventsSenderAccountAddress})
|
refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.
Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.
This commit changes this behaviour such that:
1. EventSenders can make a decision (accept, reject), but merely forward
their decision to the control node, which ultimately has to confirm
it
2. EventSenders are no longer removing or adding members to and from
communities
3. When an eventsender signaled a decision, the membership request will
enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
override that decision
This implementation is covered with a bunch of tests:
- Ensure that decision made by event sender is shared with other event
senders
- `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
confirmed decision by event senders
- `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
- `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
event senders
- `testEventSenderCannotOverrideRequestToJoinState()`
These test cases live in three test suites for different event sender
types respectively
- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`
In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).
Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.
This commit does not yet handle the case of event senders attempting to
kick and ban members.
Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-02 12:04:47 +00:00
|
|
|
community := setUpOnRequestCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN, []*Messenger{additionalAdmin})
|
|
|
|
|
|
|
|
// set up additional user that will send request to join
|
2023-08-08 15:02:56 +00:00
|
|
|
user := s.newMessenger("", []string{})
|
refactor: EventSenders forward RequestToJoin decision to control node
This is a bigger change in how community membership requests are handled
among admins, token masters, owners, and control nodes.
Prior to this commit, all privileged users, also known as
`EventSenders`, were able to accept and reject community membership
requests and those changes would be applied by all users.
This commit changes this behaviour such that:
1. EventSenders can make a decision (accept, reject), but merely forward
their decision to the control node, which ultimately has to confirm
it
2. EventSenders are no longer removing or adding members to and from
communities
3. When an eventsender signaled a decision, the membership request will
enter a pending state (acceptedPending or rejectedPending)
4. Once a decision was made by one eventsender, no other eventsender can
override that decision
This implementation is covered with a bunch of tests:
- Ensure that decision made by event sender is shared with other event
senders
- `testAcceptMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- `testRejectMemberRequestToJoinResponseSharedWithOtherEventSenders()`
- Ensure memebrship request stays pending, until control node has
confirmed decision by event senders
- `testAcceptMemberRequestToJoinNotConfirmedByControlNode()`
- `testRejectMemberRequestToJoinNotConfirmedByControlNode()`
- Ensure that decision made by event sender cannot be overriden by other
event senders
- `testEventSenderCannotOverrideRequestToJoinState()`
These test cases live in three test suites for different event sender
types respectively
- `OwnerWithoutCommunityKeyCommunityEventsSuite`
- `TokenMasterCommunityEventsSuite`
- `AdminCommunityEventsSuite`
In addition to the changes mentioned above, there's also a smaller
changes that ensures membership requests to *not* attached revealed wallet
addresses when the requests are sent to event senders (in addition to
control nodes).
Requests send to a control node will still include revealed addresses as
the control node needs them to verify token permissions.
This commit does not yet handle the case of event senders attempting to
kick and ban members.
Similar to accepting and rejecting membership requests, kicking and
banning need a new pending state. However, we don't track such state in
local databases yet so those two cases will be handled in future commit
to not have this commit grow larger.
2023-08-02 12:04:47 +00:00
|
|
|
testControlNodeHandlesMultipleEventSenderRequestToJoinDecisions(s, community, user, additionalAdmin)
|
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminCreateEditDeleteCategories() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testCreateEditDeleteCategories(s, community)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminReorderChannelsAndCategories() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testReorderChannelsAndCategories(s, community)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminKickAdmin() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testEventSenderKickTheSameRole(s, community)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestOwnerKickControlNode() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testEventSenderKickControlNode(s, community)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminKickMember() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
kickMember(s, community.ID(), common.PubkeyToHex(&s.alice.identity.PublicKey))
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminBanAdmin() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testOwnerBanTheSameRole(s, community)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminBanControlNode() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testOwnerBanControlNode(s, community)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminBanUnbanMember() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testBanUnbanMember(s, community)
|
2023-07-18 15:06:12 +00:00
|
|
|
}
|
2023-06-14 14:15:46 +00:00
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminDeleteAnyMessageInTheCommunity() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testDeleteAnyMessageInTheCommunity(s, community)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
|
|
|
|
2023-07-26 12:16:50 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminPinMessage() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testEventSenderPinMessage(s, community)
|
2023-07-18 15:06:12 +00:00
|
|
|
}
|
|
|
|
|
2023-08-04 10:28:46 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminAddCommunityToken() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
|
2023-07-07 13:03:37 +00:00
|
|
|
tokenERC721 := &token.CommunityToken{
|
2023-08-04 10:28:46 +00:00
|
|
|
CommunityID: community.IDString(),
|
|
|
|
TokenType: protobuf.CommunityTokenType_ERC721,
|
|
|
|
Address: "0x123",
|
|
|
|
Name: "StatusToken",
|
|
|
|
Symbol: "STT",
|
|
|
|
Description: "desc",
|
|
|
|
Supply: &bigint.BigInt{Int: big.NewInt(123)},
|
|
|
|
InfiniteSupply: false,
|
|
|
|
Transferable: true,
|
|
|
|
RemoteSelfDestruct: true,
|
|
|
|
ChainID: 1,
|
2023-07-07 13:03:37 +00:00
|
|
|
DeployState: token.Deployed,
|
2023-08-04 10:28:46 +00:00
|
|
|
Base64Image: "ABCD",
|
|
|
|
}
|
2023-06-14 14:15:46 +00:00
|
|
|
|
2023-08-04 10:28:46 +00:00
|
|
|
_, err := s.admin.SaveCommunityToken(tokenERC721, nil)
|
|
|
|
s.Require().NoError(err)
|
|
|
|
|
|
|
|
err = s.admin.AddCommunityToken(tokenERC721.CommunityID, tokenERC721.ChainID, tokenERC721.Address)
|
|
|
|
s.Require().Error(err)
|
2023-06-14 14:15:46 +00:00
|
|
|
}
|
2023-07-18 15:06:12 +00:00
|
|
|
|
2023-08-22 17:48:42 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminAddTokenMasterAndOwnerToken() {
|
2023-08-15 17:42:40 +00:00
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testEventSenderAddTokenMasterAndOwnerToken(s, community)
|
|
|
|
}
|
|
|
|
|
2023-08-22 17:48:42 +00:00
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminReceiveOwnerTokenFromControlNode() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
2023-07-05 17:35:22 +00:00
|
|
|
|
|
|
|
testAddAndSyncOwnerTokenFromControlNode(s, community, token.OwnerLevel)
|
|
|
|
|
2023-08-22 17:48:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminReceiveTokenMasterTokenFromControlNode() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testAddAndSyncTokenFromControlNode(s, community, token.MasterLevel)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminReceiveCommunityTokenFromControlNode() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testAddAndSyncTokenFromControlNode(s, community, token.CommunityLevel)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) TestMemberReceiveOwnerEventsWhenControlNodeOffline() {
|
2023-07-26 12:16:50 +00:00
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
testMemberReceiveEventsWhenControlNodeOffline(s, community)
|
2023-07-18 15:06:12 +00:00
|
|
|
}
|
2023-08-08 13:16:29 +00:00
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminResendRejectedEvents() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
|
|
|
|
// admin modifies community description
|
|
|
|
adminEditRequest := &requests.EditCommunity{
|
|
|
|
CommunityID: community.ID(),
|
|
|
|
CreateCommunity: requests.CreateCommunity{
|
|
|
|
Name: "admin name",
|
|
|
|
Description: "admin description",
|
|
|
|
Color: "#FFFFFF",
|
2023-10-25 13:03:26 +00:00
|
|
|
Membership: protobuf.CommunityPermissions_MANUAL_ACCEPT,
|
2023-08-08 13:16:29 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
_, err := s.admin.EditCommunity(adminEditRequest)
|
|
|
|
s.Require().NoError(err)
|
|
|
|
|
|
|
|
// in the meantime, control node updates community description as well
|
|
|
|
ownerEditRequest := &requests.EditCommunity{
|
|
|
|
CommunityID: community.ID(),
|
|
|
|
CreateCommunity: requests.CreateCommunity{
|
|
|
|
Name: "control node name",
|
|
|
|
Description: "control node description",
|
|
|
|
Color: "#FFFFFF",
|
2023-10-25 13:03:26 +00:00
|
|
|
Membership: protobuf.CommunityPermissions_MANUAL_ACCEPT,
|
2023-08-08 13:16:29 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
_, err = s.owner.EditCommunity(ownerEditRequest)
|
|
|
|
s.Require().NoError(err)
|
|
|
|
|
|
|
|
waitOnAdminEventsRejection := waitOnCommunitiesEvent(s.owner, func(s *communities.Subscription) bool {
|
|
|
|
return s.CommunityEventsMessageInvalidClock != nil
|
|
|
|
})
|
|
|
|
|
|
|
|
// control node receives admin event and rejects it
|
|
|
|
_, err = WaitOnMessengerResponse(s.owner, func(response *MessengerResponse) bool {
|
|
|
|
select {
|
|
|
|
case err := <-waitOnAdminEventsRejection:
|
|
|
|
s.Require().NoError(err)
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}, "")
|
|
|
|
s.Require().NoError(err)
|
|
|
|
|
|
|
|
community, err = s.owner.communitiesManager.GetByID(community.ID())
|
|
|
|
s.Require().NoError(err)
|
|
|
|
s.Require().Equal(ownerEditRequest.Description, community.DescriptionText())
|
|
|
|
|
|
|
|
// admin receives rejected events and re-applies them
|
|
|
|
// there is no signal whatsoever, we just wait for admin to process all incoming messages
|
|
|
|
_, _ = WaitOnMessengerResponse(s.admin, func(response *MessengerResponse) bool {
|
|
|
|
return false
|
|
|
|
}, "")
|
|
|
|
|
|
|
|
// control node receives re-applied admin event and accepts it
|
|
|
|
response, err := WaitOnMessengerResponse(s.owner, func(response *MessengerResponse) bool {
|
|
|
|
return len(response.Communities()) > 0
|
|
|
|
}, "no communities in response")
|
|
|
|
s.Require().NoError(err)
|
|
|
|
s.Require().Equal(adminEditRequest.Description, response.Communities()[0].DescriptionText())
|
|
|
|
|
|
|
|
// admin receives updated community description
|
|
|
|
response, err = WaitOnMessengerResponse(s.admin, func(response *MessengerResponse) bool {
|
|
|
|
return len(response.Communities()) > 0
|
|
|
|
}, "no communities in response")
|
|
|
|
s.Require().NoError(err)
|
|
|
|
s.Require().Equal(adminEditRequest.Description, response.Communities()[0].DescriptionText())
|
|
|
|
}
|
2023-09-20 08:37:46 +00:00
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) TestJoinedAdminReceiveRequestsToJoinWithoutRevealedAccounts() {
|
|
|
|
community := setUpOnRequestCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN, []*Messenger{})
|
|
|
|
|
|
|
|
// set up additional user (bob) that will send request to join
|
|
|
|
bob := s.newMessenger(accountPassword, []string{bobAccountAddress})
|
|
|
|
|
|
|
|
// set up additional user that will join to the community as TokenMaster
|
|
|
|
newPrivilegedUser := s.newMessenger(accountPassword, []string{eventsSenderAccountAddress})
|
|
|
|
|
|
|
|
testJoinedPrivilegedMemberReceiveRequestsToJoin(s, community, bob, newPrivilegedUser, protobuf.CommunityTokenPermission_BECOME_ADMIN)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) TestReceiveRequestsToJoinWithRevealedAccountsAfterGettingAdminRole() {
|
|
|
|
// set up additional user (bob) that will send request to join
|
|
|
|
bob := s.newMessenger(accountPassword, []string{bobAccountAddress})
|
|
|
|
testMemberReceiveRequestsToJoinAfterGettingNewRole(s, bob, protobuf.CommunityTokenPermission_BECOME_ADMIN)
|
|
|
|
}
|
2023-09-22 17:57:27 +00:00
|
|
|
|
|
|
|
func (s *AdminCommunityEventsSuite) TestAdminDoesNotHaveRejectedEventsLoop() {
|
|
|
|
community := setUpCommunityAndRoles(s, protobuf.CommunityMember_ROLE_ADMIN)
|
|
|
|
|
|
|
|
// admin modifies community description
|
|
|
|
adminEditRequest := &requests.EditCommunity{
|
|
|
|
CommunityID: community.ID(),
|
|
|
|
CreateCommunity: requests.CreateCommunity{
|
|
|
|
Name: "admin name",
|
|
|
|
Description: "admin description",
|
|
|
|
Color: "#FFFFFF",
|
2023-10-25 13:03:26 +00:00
|
|
|
Membership: protobuf.CommunityPermissions_MANUAL_ACCEPT,
|
2023-09-22 17:57:27 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
_, err := s.admin.EditCommunity(adminEditRequest)
|
|
|
|
s.Require().NoError(err)
|
|
|
|
|
|
|
|
community, err = s.owner.communitiesManager.GetByID(community.ID())
|
|
|
|
s.Require().NoError(err)
|
|
|
|
|
|
|
|
// Update community clock without publishing new CommunityDescription
|
2023-10-04 19:02:17 +00:00
|
|
|
_, err = community.DeclineRequestToJoin(nil)
|
2023-09-22 17:57:27 +00:00
|
|
|
s.Require().NoError(err)
|
|
|
|
|
|
|
|
err = s.owner.communitiesManager.SaveCommunity(community)
|
|
|
|
s.Require().NoError(err)
|
|
|
|
|
|
|
|
waitOnAdminEventsRejection := waitOnCommunitiesEvent(s.owner, func(s *communities.Subscription) bool {
|
|
|
|
return s.CommunityEventsMessageInvalidClock != nil
|
|
|
|
})
|
|
|
|
|
|
|
|
// control node receives admin event and rejects it
|
|
|
|
_, err = WaitOnMessengerResponse(s.owner, func(response *MessengerResponse) bool {
|
|
|
|
select {
|
|
|
|
case err := <-waitOnAdminEventsRejection:
|
|
|
|
s.Require().NoError(err)
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}, "")
|
|
|
|
s.Require().NoError(err)
|
|
|
|
|
|
|
|
community, err = s.owner.communitiesManager.GetByID(community.ID())
|
|
|
|
s.Require().NoError(err)
|
|
|
|
s.Require().NotEqual(adminEditRequest.Description, community.DescriptionText())
|
|
|
|
|
|
|
|
// admin receives rejected events and re-applies them
|
|
|
|
// there is no signal whatsoever, we just wait for admin to process all incoming messages
|
|
|
|
_, _ = WaitOnMessengerResponse(s.admin, func(response *MessengerResponse) bool {
|
|
|
|
return false
|
|
|
|
}, "")
|
|
|
|
|
|
|
|
// control node does not receives admin event
|
|
|
|
_, err = WaitOnMessengerResponse(s.owner, func(response *MessengerResponse) bool {
|
|
|
|
return len(response.Communities()) > 0
|
|
|
|
}, "no communities in response")
|
|
|
|
s.Require().Error(err)
|
|
|
|
}
|