Revert "Comment out flaky tests (#4741)"

This reverts commit 582927868d.
This commit is contained in:
Patryk Osmaczko 2024-02-19 19:00:44 +01:00 committed by osmaczko
parent cc708ce0ce
commit 1fca1e1743
7 changed files with 2657 additions and 2668 deletions

View File

@ -3453,111 +3453,111 @@ func (s *MessengerCommunitiesSuite) TestStartCommunityRekeyLoop() {
}
}
// func (s *MessengerCommunitiesSuite) TestCommunityRekeyAfterBan() {
// s.owner.communitiesManager.RekeyInterval = 500 * time.Minute
func (s *MessengerCommunitiesSuite) TestCommunityRekeyAfterBan() {
s.owner.communitiesManager.RekeyInterval = 500 * time.Minute
// _, err := s.owner.Start()
// s.Require().NoError(err)
_, err := s.owner.Start()
s.Require().NoError(err)
// // Create a new community
// response, err := s.owner.CreateCommunity(
// &requests.CreateCommunity{
// Membership: protobuf.CommunityPermissions_AUTO_ACCEPT,
// Name: "status",
// Color: "#57a7e5",
// Description: "status community description",
// },
// true,
// )
// s.Require().NoError(err)
// s.Require().NotNil(response)
// s.Require().Len(response.Communities(), 1)
// s.Require().Len(response.Communities()[0].Members(), 1)
// Create a new community
response, err := s.owner.CreateCommunity(
&requests.CreateCommunity{
Membership: protobuf.CommunityPermissions_AUTO_ACCEPT,
Name: "status",
Color: "#57a7e5",
Description: "status community description",
},
true,
)
s.Require().NoError(err)
s.Require().NotNil(response)
s.Require().Len(response.Communities(), 1)
s.Require().Len(response.Communities()[0].Members(), 1)
// // Check community is present in the DB and has default values we care about
// c, err := s.owner.GetCommunityByID(response.Communities()[0].ID())
// s.Require().NoError(err)
// s.Require().False(c.Encrypted())
// // TODO some check that there are no keys for the community. Alt for s.Require().Zero(c.RekeyedAt().Unix())
// Check community is present in the DB and has default values we care about
c, err := s.owner.GetCommunityByID(response.Communities()[0].ID())
s.Require().NoError(err)
s.Require().False(c.Encrypted())
// TODO some check that there are no keys for the community. Alt for s.Require().Zero(c.RekeyedAt().Unix())
// _, err = s.owner.CreateCommunityTokenPermission(&requests.CreateCommunityTokenPermission{
// CommunityID: c.ID(),
// Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
// TokenCriteria: []*protobuf.TokenCriteria{{
// ContractAddresses: map[uint64]string{3: "0x933"},
// Type: protobuf.CommunityTokenType_ERC20,
// Symbol: "STT",
// Name: "Status Test Token",
// Amount: "10",
// Decimals: 18,
// }},
// })
// s.Require().NoError(err)
_, err = s.owner.CreateCommunityTokenPermission(&requests.CreateCommunityTokenPermission{
CommunityID: c.ID(),
Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
TokenCriteria: []*protobuf.TokenCriteria{{
ContractAddresses: map[uint64]string{3: "0x933"},
Type: protobuf.CommunityTokenType_ERC20,
Symbol: "STT",
Name: "Status Test Token",
Amount: "10",
Decimals: 18,
}},
})
s.Require().NoError(err)
// c, err = s.owner.GetCommunityByID(c.ID())
// s.Require().NoError(err)
// s.Require().True(c.Encrypted())
c, err = s.owner.GetCommunityByID(c.ID())
s.Require().NoError(err)
s.Require().True(c.Encrypted())
// s.advertiseCommunityTo(c, s.owner, s.bob)
// s.advertiseCommunityTo(c, s.owner, s.alice)
s.advertiseCommunityTo(c, s.owner, s.bob)
s.advertiseCommunityTo(c, s.owner, s.alice)
// s.owner.communitiesManager.PermissionChecker = &testPermissionChecker{}
s.owner.communitiesManager.PermissionChecker = &testPermissionChecker{}
// s.joinCommunity(c, s.owner, s.bob)
// s.joinCommunity(c, s.owner, s.alice)
s.joinCommunity(c, s.owner, s.bob)
s.joinCommunity(c, s.owner, s.alice)
// // Check the Alice and Bob are members of the community
// c, err = s.owner.GetCommunityByID(c.ID())
// s.Require().NoError(err)
// s.Require().True(c.HasMember(&s.alice.identity.PublicKey))
// s.Require().True(c.HasMember(&s.bob.identity.PublicKey))
// Check the Alice and Bob are members of the community
c, err = s.owner.GetCommunityByID(c.ID())
s.Require().NoError(err)
s.Require().True(c.HasMember(&s.alice.identity.PublicKey))
s.Require().True(c.HasMember(&s.bob.identity.PublicKey))
// // Make sure at least one key makes it to alice
// response, err = WaitOnMessengerResponse(s.alice,
// func(r *MessengerResponse) bool {
// keys, err := s.alice.encryptor.GetKeysForGroup(response.Communities()[0].ID())
// if err != nil || len(keys) != 1 {
// return false
// }
// return true
// Make sure at least one key makes it to alice
response, err = WaitOnMessengerResponse(s.alice,
func(r *MessengerResponse) bool {
keys, err := s.alice.encryptor.GetKeysForGroup(response.Communities()[0].ID())
if err != nil || len(keys) != 1 {
return false
}
return true
// },
// "alice does not have enough keys",
// )
// s.Require().NoError(err)
},
"alice does not have enough keys",
)
s.Require().NoError(err)
// response, err = s.owner.BanUserFromCommunity(context.Background(), &requests.BanUserFromCommunity{
// CommunityID: c.ID(),
// User: common.PubkeyToHexBytes(&s.bob.identity.PublicKey),
// })
// s.Require().NoError(err)
// s.Require().Len(response.Communities(), 1)
response, err = s.owner.BanUserFromCommunity(context.Background(), &requests.BanUserFromCommunity{
CommunityID: c.ID(),
User: common.PubkeyToHexBytes(&s.bob.identity.PublicKey),
})
s.Require().NoError(err)
s.Require().Len(response.Communities(), 1)
// s.Require().False(response.Communities()[0].HasMember(&s.bob.identity.PublicKey))
s.Require().False(response.Communities()[0].HasMember(&s.bob.identity.PublicKey))
// // Check bob has been banned
// response, err = WaitOnMessengerResponse(s.alice,
// func(r *MessengerResponse) bool {
// return len(r.Communities()) == 1 && !r.Communities()[0].HasMember(&s.bob.identity.PublicKey)
// Check bob has been banned
response, err = WaitOnMessengerResponse(s.alice,
func(r *MessengerResponse) bool {
return len(r.Communities()) == 1 && !r.Communities()[0].HasMember(&s.bob.identity.PublicKey)
// },
// "alice didn't receive updated description",
// )
// s.Require().NoError(err)
},
"alice didn't receive updated description",
)
s.Require().NoError(err)
// response, err = WaitOnMessengerResponse(s.alice,
// func(r *MessengerResponse) bool {
// keys, err := s.alice.encryptor.GetKeysForGroup(response.Communities()[0].ID())
// if err != nil || len(keys) < 2 {
// return false
// }
// return true
response, err = WaitOnMessengerResponse(s.alice,
func(r *MessengerResponse) bool {
keys, err := s.alice.encryptor.GetKeysForGroup(response.Communities()[0].ID())
if err != nil || len(keys) < 2 {
return false
}
return true
// },
// "alice hasn't received updated key",
// )
// s.Require().NoError(err)
// }
},
"alice hasn't received updated key",
)
s.Require().NoError(err)
}
func (s *MessengerCommunitiesSuite) TestCommunityRekeyAfterBanDisableCompatibility() {
common.RekeyCompatibility = false

View File

@ -239,123 +239,123 @@ func (s *MessengerCommunitiesTokenPermissionsSuite) waitOnKeyDistribution(condit
return testCommunitiesKeyDistributor.waitOnKeyDistribution(condition)
}
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestCreateTokenPermission() {
// community, _ := s.createCommunity()
func (s *MessengerCommunitiesTokenPermissionsSuite) TestCreateTokenPermission() {
community, _ := s.createCommunity()
// createTokenPermission := &requests.CreateCommunityTokenPermission{
// CommunityID: community.ID(),
// Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
// TokenCriteria: []*protobuf.TokenCriteria{
// &protobuf.TokenCriteria{
// Type: protobuf.CommunityTokenType_ERC20,
// ContractAddresses: map[uint64]string{uint64(testChainID1): "0x123"},
// Symbol: "TEST",
// Amount: "100",
// Decimals: uint64(18),
// },
// },
// }
createTokenPermission := &requests.CreateCommunityTokenPermission{
CommunityID: community.ID(),
Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
TokenCriteria: []*protobuf.TokenCriteria{
&protobuf.TokenCriteria{
Type: protobuf.CommunityTokenType_ERC20,
ContractAddresses: map[uint64]string{uint64(testChainID1): "0x123"},
Symbol: "TEST",
Amount: "100",
Decimals: uint64(18),
},
},
}
// response, err := s.owner.CreateCommunityTokenPermission(createTokenPermission)
// s.Require().NoError(err)
// s.Require().NotNil(response)
// s.Require().Len(response.Communities(), 1)
response, err := s.owner.CreateCommunityTokenPermission(createTokenPermission)
s.Require().NoError(err)
s.Require().NotNil(response)
s.Require().Len(response.Communities(), 1)
// tokenPermissions := response.Communities()[0].TokenPermissions()
// for _, tokenPermission := range tokenPermissions {
// for _, tc := range tokenPermission.TokenCriteria {
// s.Require().Equal(tc.Type, protobuf.CommunityTokenType_ERC20)
// s.Require().Equal(tc.Symbol, "TEST")
// s.Require().Equal(tc.Amount, "100")
// s.Require().Equal(tc.Decimals, uint64(18))
// }
// }
// }
tokenPermissions := response.Communities()[0].TokenPermissions()
for _, tokenPermission := range tokenPermissions {
for _, tc := range tokenPermission.TokenCriteria {
s.Require().Equal(tc.Type, protobuf.CommunityTokenType_ERC20)
s.Require().Equal(tc.Symbol, "TEST")
s.Require().Equal(tc.Amount, "100")
s.Require().Equal(tc.Decimals, uint64(18))
}
}
}
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestEditTokenPermission() {
// community, _ := s.createCommunity()
func (s *MessengerCommunitiesTokenPermissionsSuite) TestEditTokenPermission() {
community, _ := s.createCommunity()
// tokenPermission := &requests.CreateCommunityTokenPermission{
// CommunityID: community.ID(),
// Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
// TokenCriteria: []*protobuf.TokenCriteria{
// &protobuf.TokenCriteria{
// Type: protobuf.CommunityTokenType_ERC20,
// ContractAddresses: map[uint64]string{testChainID1: "0x123"},
// Symbol: "TEST",
// Amount: "100",
// Decimals: uint64(18),
// },
// },
// }
tokenPermission := &requests.CreateCommunityTokenPermission{
CommunityID: community.ID(),
Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
TokenCriteria: []*protobuf.TokenCriteria{
&protobuf.TokenCriteria{
Type: protobuf.CommunityTokenType_ERC20,
ContractAddresses: map[uint64]string{testChainID1: "0x123"},
Symbol: "TEST",
Amount: "100",
Decimals: uint64(18),
},
},
}
// response, err := s.owner.CreateCommunityTokenPermission(tokenPermission)
// s.Require().NoError(err)
// s.Require().NotNil(response)
// s.Require().Len(response.Communities(), 1)
response, err := s.owner.CreateCommunityTokenPermission(tokenPermission)
s.Require().NoError(err)
s.Require().NotNil(response)
s.Require().Len(response.Communities(), 1)
// tokenPermissions := response.Communities()[0].TokenPermissions()
tokenPermissions := response.Communities()[0].TokenPermissions()
// var tokenPermissionID string
// for id := range tokenPermissions {
// tokenPermissionID = id
// }
var tokenPermissionID string
for id := range tokenPermissions {
tokenPermissionID = id
}
// tokenPermission.TokenCriteria[0].Symbol = "TESTUpdated"
// tokenPermission.TokenCriteria[0].Amount = "200"
// tokenPermission.TokenCriteria[0].Decimals = uint64(20)
tokenPermission.TokenCriteria[0].Symbol = "TESTUpdated"
tokenPermission.TokenCriteria[0].Amount = "200"
tokenPermission.TokenCriteria[0].Decimals = uint64(20)
// editTokenPermission := &requests.EditCommunityTokenPermission{
// PermissionID: tokenPermissionID,
// CreateCommunityTokenPermission: *tokenPermission,
// }
editTokenPermission := &requests.EditCommunityTokenPermission{
PermissionID: tokenPermissionID,
CreateCommunityTokenPermission: *tokenPermission,
}
// response2, err := s.owner.EditCommunityTokenPermission(editTokenPermission)
// s.Require().NoError(err)
// // wait for `checkMemberPermissions` to finish
// time.Sleep(1 * time.Second)
// s.Require().NotNil(response2)
// s.Require().Len(response2.Communities(), 1)
response2, err := s.owner.EditCommunityTokenPermission(editTokenPermission)
s.Require().NoError(err)
// wait for `checkMemberPermissions` to finish
time.Sleep(1 * time.Second)
s.Require().NotNil(response2)
s.Require().Len(response2.Communities(), 1)
// tokenPermissions = response2.Communities()[0].TokenPermissions()
// for _, tokenPermission := range tokenPermissions {
// for _, tc := range tokenPermission.TokenCriteria {
// s.Require().Equal(tc.Type, protobuf.CommunityTokenType_ERC20)
// s.Require().Equal(tc.Symbol, "TESTUpdated")
// s.Require().Equal(tc.Amount, "200")
// s.Require().Equal(tc.Decimals, uint64(20))
// }
// }
// }
tokenPermissions = response2.Communities()[0].TokenPermissions()
for _, tokenPermission := range tokenPermissions {
for _, tc := range tokenPermission.TokenCriteria {
s.Require().Equal(tc.Type, protobuf.CommunityTokenType_ERC20)
s.Require().Equal(tc.Symbol, "TESTUpdated")
s.Require().Equal(tc.Amount, "200")
s.Require().Equal(tc.Decimals, uint64(20))
}
}
}
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestCommunityTokensMetadata() {
// community, _ := s.createCommunity()
func (s *MessengerCommunitiesTokenPermissionsSuite) TestCommunityTokensMetadata() {
community, _ := s.createCommunity()
// tokensMetadata := community.CommunityTokensMetadata()
// s.Require().Len(tokensMetadata, 0)
tokensMetadata := community.CommunityTokensMetadata()
s.Require().Len(tokensMetadata, 0)
// newToken := &protobuf.CommunityTokenMetadata{
// ContractAddresses: map[uint64]string{testChainID1: "0xasd"},
// Description: "desc1",
// Image: "IMG1",
// TokenType: protobuf.CommunityTokenType_ERC721,
// Symbol: "SMB",
// Decimals: 3,
// }
newToken := &protobuf.CommunityTokenMetadata{
ContractAddresses: map[uint64]string{testChainID1: "0xasd"},
Description: "desc1",
Image: "IMG1",
TokenType: protobuf.CommunityTokenType_ERC721,
Symbol: "SMB",
Decimals: 3,
}
// _, err := community.AddCommunityTokensMetadata(newToken)
// s.Require().NoError(err)
// tokensMetadata = community.CommunityTokensMetadata()
// s.Require().Len(tokensMetadata, 1)
_, err := community.AddCommunityTokensMetadata(newToken)
s.Require().NoError(err)
tokensMetadata = community.CommunityTokensMetadata()
s.Require().Len(tokensMetadata, 1)
// s.Require().Equal(tokensMetadata[0].ContractAddresses, newToken.ContractAddresses)
// s.Require().Equal(tokensMetadata[0].Description, newToken.Description)
// s.Require().Equal(tokensMetadata[0].Image, newToken.Image)
// s.Require().Equal(tokensMetadata[0].TokenType, newToken.TokenType)
// s.Require().Equal(tokensMetadata[0].Symbol, newToken.Symbol)
// s.Require().Equal(tokensMetadata[0].Name, newToken.Name)
// s.Require().Equal(tokensMetadata[0].Decimals, newToken.Decimals)
// }
s.Require().Equal(tokensMetadata[0].ContractAddresses, newToken.ContractAddresses)
s.Require().Equal(tokensMetadata[0].Description, newToken.Description)
s.Require().Equal(tokensMetadata[0].Image, newToken.Image)
s.Require().Equal(tokensMetadata[0].TokenType, newToken.TokenType)
s.Require().Equal(tokensMetadata[0].Symbol, newToken.Symbol)
s.Require().Equal(tokensMetadata[0].Name, newToken.Name)
s.Require().Equal(tokensMetadata[0].Decimals, newToken.Decimals)
}
func (s *MessengerCommunitiesTokenPermissionsSuite) TestRequestAccessWithENSTokenPermission() {
community, _ := s.createCommunity()
@ -420,205 +420,205 @@ func (s *MessengerCommunitiesTokenPermissionsSuite) TestRequestAccessWithENSToke
}
}
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersSharedAddress() {
// community, _ := s.createCommunity()
// s.advertiseCommunityTo(community, s.alice)
// s.advertiseCommunityTo(community, s.bob)
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersSharedAddress() {
community, _ := s.createCommunity()
s.advertiseCommunityTo(community, s.alice)
s.advertiseCommunityTo(community, s.bob)
// s.joinCommunity(community, s.alice, alicePassword, []string{})
// s.joinCommunity(community, s.bob, bobPassword, []string{})
s.joinCommunity(community, s.alice, alicePassword, []string{})
s.joinCommunity(community, s.bob, bobPassword, []string{})
// community, err := s.owner.GetCommunityByID(community.ID())
// s.Require().NoError(err)
community, err := s.owner.GetCommunityByID(community.ID())
s.Require().NoError(err)
// s.Require().Equal(3, community.MembersCount())
s.Require().Equal(3, community.MembersCount())
// // Check owner's DB for revealed accounts
// for pubKey := range community.Members() {
// if pubKey != common.PubkeyToHex(&s.owner.identity.PublicKey) {
// revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), pubKey)
// s.Require().NoError(err)
// switch pubKey {
// case common.PubkeyToHex(&s.alice.identity.PublicKey):
// s.Require().Len(revealedAccounts, 2)
// s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
// s.Require().Equal(revealedAccounts[1].Address, aliceAddress2)
// s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
// case common.PubkeyToHex(&s.bob.identity.PublicKey):
// s.Require().Len(revealedAccounts, 1)
// s.Require().Equal(revealedAccounts[0].Address, bobAddress)
// s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
// default:
// s.Require().Fail("pubKey does not match expected keys")
// }
// }
// }
// Check owner's DB for revealed accounts
for pubKey := range community.Members() {
if pubKey != common.PubkeyToHex(&s.owner.identity.PublicKey) {
revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), pubKey)
s.Require().NoError(err)
switch pubKey {
case common.PubkeyToHex(&s.alice.identity.PublicKey):
s.Require().Len(revealedAccounts, 2)
s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
s.Require().Equal(revealedAccounts[1].Address, aliceAddress2)
s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
case common.PubkeyToHex(&s.bob.identity.PublicKey):
s.Require().Len(revealedAccounts, 1)
s.Require().Equal(revealedAccounts[0].Address, bobAddress)
s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
default:
s.Require().Fail("pubKey does not match expected keys")
}
}
}
// // Check Bob's DB for revealed accounts
// revealedAccountsInBobsDB, err := s.bob.communitiesManager.GetRevealedAddresses(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
// s.Require().NoError(err)
// s.Require().Len(revealedAccountsInBobsDB, 1)
// s.Require().Equal(revealedAccountsInBobsDB[0].Address, bobAddress)
// s.Require().Equal(true, revealedAccountsInBobsDB[0].IsAirdropAddress)
// Check Bob's DB for revealed accounts
revealedAccountsInBobsDB, err := s.bob.communitiesManager.GetRevealedAddresses(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
s.Require().NoError(err)
s.Require().Len(revealedAccountsInBobsDB, 1)
s.Require().Equal(revealedAccountsInBobsDB[0].Address, bobAddress)
s.Require().Equal(true, revealedAccountsInBobsDB[0].IsAirdropAddress)
// // Check Alices's DB for revealed accounts
// revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), common.PubkeyToHex(&s.alice.identity.PublicKey))
// s.Require().NoError(err)
// s.Require().Len(revealedAccountsInAlicesDB, 2)
// s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress1)
// s.Require().Equal(revealedAccountsInAlicesDB[1].Address, aliceAddress2)
// s.Require().Equal(true, revealedAccountsInAlicesDB[0].IsAirdropAddress)
// }
// Check Alices's DB for revealed accounts
revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), common.PubkeyToHex(&s.alice.identity.PublicKey))
s.Require().NoError(err)
s.Require().Len(revealedAccountsInAlicesDB, 2)
s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress1)
s.Require().Equal(revealedAccountsInAlicesDB[1].Address, aliceAddress2)
s.Require().Equal(true, revealedAccountsInAlicesDB[0].IsAirdropAddress)
}
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersSelectedSharedAddress() {
// community, _ := s.createCommunity()
// s.advertiseCommunityTo(community, s.alice)
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersSelectedSharedAddress() {
community, _ := s.createCommunity()
s.advertiseCommunityTo(community, s.alice)
// s.joinCommunity(community, s.alice, alicePassword, []string{aliceAddress2})
s.joinCommunity(community, s.alice, alicePassword, []string{aliceAddress2})
// community, err := s.owner.GetCommunityByID(community.ID())
// s.Require().NoError(err)
community, err := s.owner.GetCommunityByID(community.ID())
s.Require().NoError(err)
// s.Require().Equal(2, community.MembersCount())
s.Require().Equal(2, community.MembersCount())
// alicePubkey := common.PubkeyToHex(&s.alice.identity.PublicKey)
alicePubkey := common.PubkeyToHex(&s.alice.identity.PublicKey)
// // Check owner's DB for revealed accounts
// revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
// s.Require().NoError(err)
// s.Require().Len(revealedAccounts, 1)
// s.Require().Equal(revealedAccounts[0].Address, aliceAddress2)
// s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
// Check owner's DB for revealed accounts
revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
s.Require().NoError(err)
s.Require().Len(revealedAccounts, 1)
s.Require().Equal(revealedAccounts[0].Address, aliceAddress2)
s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
// // Check Alice's DB for revealed accounts
// revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
// s.Require().NoError(err)
// s.Require().Len(revealedAccountsInAlicesDB, 1)
// s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress2)
// s.Require().Equal(true, revealedAccountsInAlicesDB[0].IsAirdropAddress)
// }
// Check Alice's DB for revealed accounts
revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
s.Require().NoError(err)
s.Require().Len(revealedAccountsInAlicesDB, 1)
s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress2)
s.Require().Equal(true, revealedAccountsInAlicesDB[0].IsAirdropAddress)
}
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersMultipleSelectedSharedAddresses() {
// community, _ := s.createCommunity()
// s.advertiseCommunityTo(community, s.alice)
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersMultipleSelectedSharedAddresses() {
community, _ := s.createCommunity()
s.advertiseCommunityTo(community, s.alice)
// s.joinCommunityWithAirdropAddress(community, s.alice, alicePassword, []string{aliceAddress1, aliceAddress2}, aliceAddress2)
s.joinCommunityWithAirdropAddress(community, s.alice, alicePassword, []string{aliceAddress1, aliceAddress2}, aliceAddress2)
// community, err := s.owner.GetCommunityByID(community.ID())
// s.Require().NoError(err)
community, err := s.owner.GetCommunityByID(community.ID())
s.Require().NoError(err)
// s.Require().Equal(2, community.MembersCount())
s.Require().Equal(2, community.MembersCount())
// alicePubkey := common.PubkeyToHex(&s.alice.identity.PublicKey)
alicePubkey := common.PubkeyToHex(&s.alice.identity.PublicKey)
// // Check owner's DB for revealed accounts
// revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
// s.Require().NoError(err)
// s.Require().Len(revealedAccounts, 2)
// s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
// s.Require().Equal(revealedAccounts[1].Address, aliceAddress2)
// s.Require().Equal(true, revealedAccounts[1].IsAirdropAddress)
// Check owner's DB for revealed accounts
revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
s.Require().NoError(err)
s.Require().Len(revealedAccounts, 2)
s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
s.Require().Equal(revealedAccounts[1].Address, aliceAddress2)
s.Require().Equal(true, revealedAccounts[1].IsAirdropAddress)
// // Check Alice's DB for revealed accounts
// revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
// s.Require().NoError(err)
// s.Require().Len(revealedAccountsInAlicesDB, 2)
// s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress1)
// s.Require().Equal(revealedAccountsInAlicesDB[1].Address, aliceAddress2)
// s.Require().Equal(true, revealedAccountsInAlicesDB[1].IsAirdropAddress)
// }
// Check Alice's DB for revealed accounts
revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
s.Require().NoError(err)
s.Require().Len(revealedAccountsInAlicesDB, 2)
s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress1)
s.Require().Equal(revealedAccountsInAlicesDB[1].Address, aliceAddress2)
s.Require().Equal(true, revealedAccountsInAlicesDB[1].IsAirdropAddress)
}
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestEditSharedAddresses() {
// community, _ := s.createCommunity()
// s.advertiseCommunityTo(community, s.alice)
func (s *MessengerCommunitiesTokenPermissionsSuite) TestEditSharedAddresses() {
community, _ := s.createCommunity()
s.advertiseCommunityTo(community, s.alice)
// s.joinCommunity(community, s.alice, alicePassword, []string{aliceAddress2})
s.joinCommunity(community, s.alice, alicePassword, []string{aliceAddress2})
// community, err := s.owner.GetCommunityByID(community.ID())
// s.Require().NoError(err)
// s.Require().Equal(2, community.MembersCount())
community, err := s.owner.GetCommunityByID(community.ID())
s.Require().NoError(err)
s.Require().Equal(2, community.MembersCount())
// alicePubkey := common.PubkeyToHex(&s.alice.identity.PublicKey)
alicePubkey := common.PubkeyToHex(&s.alice.identity.PublicKey)
// revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
// s.Require().NoError(err)
revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
s.Require().NoError(err)
// s.Require().Len(revealedAccounts, 1)
// s.Require().Equal(revealedAccounts[0].Address, aliceAddress2)
// s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
s.Require().Len(revealedAccounts, 1)
s.Require().Equal(revealedAccounts[0].Address, aliceAddress2)
s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
// alicesRevealedAccounts, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
// s.Require().NoError(err)
// s.Require().Len(alicesRevealedAccounts, 1)
// s.Require().Equal(alicesRevealedAccounts[0].Address, aliceAddress2)
// s.Require().Equal(true, alicesRevealedAccounts[0].IsAirdropAddress)
alicesRevealedAccounts, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
s.Require().NoError(err)
s.Require().Len(alicesRevealedAccounts, 1)
s.Require().Equal(alicesRevealedAccounts[0].Address, aliceAddress2)
s.Require().Equal(true, alicesRevealedAccounts[0].IsAirdropAddress)
// request := &requests.EditSharedAddresses{CommunityID: community.ID(), AddressesToReveal: []string{aliceAddress1}, AirdropAddress: aliceAddress1}
request := &requests.EditSharedAddresses{CommunityID: community.ID(), AddressesToReveal: []string{aliceAddress1}, AirdropAddress: aliceAddress1}
// signingParams, err := s.alice.GenerateJoiningCommunityRequestsForSigning(common.PubkeyToHex(&s.alice.identity.PublicKey), community.ID(), request.AddressesToReveal)
// s.Require().NoError(err)
signingParams, err := s.alice.GenerateJoiningCommunityRequestsForSigning(common.PubkeyToHex(&s.alice.identity.PublicKey), community.ID(), request.AddressesToReveal)
s.Require().NoError(err)
// passwdHash := types.EncodeHex(crypto.Keccak256([]byte(alicePassword)))
// for i := range signingParams {
// signingParams[i].Password = passwdHash
// }
// signatures, err := s.alice.SignData(signingParams)
// s.Require().NoError(err)
passwdHash := types.EncodeHex(crypto.Keccak256([]byte(alicePassword)))
for i := range signingParams {
signingParams[i].Password = passwdHash
}
signatures, err := s.alice.SignData(signingParams)
s.Require().NoError(err)
// updateAddresses := len(request.AddressesToReveal) == 0
// if updateAddresses {
// request.AddressesToReveal = make([]string, len(signingParams))
// }
// for i := range signingParams {
// request.AddressesToReveal[i] = signingParams[i].Address
// request.Signatures = append(request.Signatures, types.FromHex(signatures[i]))
// }
// if updateAddresses {
// request.AirdropAddress = request.AddressesToReveal[0]
// }
updateAddresses := len(request.AddressesToReveal) == 0
if updateAddresses {
request.AddressesToReveal = make([]string, len(signingParams))
}
for i := range signingParams {
request.AddressesToReveal[i] = signingParams[i].Address
request.Signatures = append(request.Signatures, types.FromHex(signatures[i]))
}
if updateAddresses {
request.AirdropAddress = request.AddressesToReveal[0]
}
// response, err := s.alice.EditSharedAddressesForCommunity(request)
// s.Require().NoError(err)
// s.Require().NotNil(response)
response, err := s.alice.EditSharedAddressesForCommunity(request)
s.Require().NoError(err)
s.Require().NotNil(response)
// // Retrieve address change
// err = tt.RetryWithBackOff(func() error {
// response, err := s.owner.RetrieveAll()
// if err != nil {
// return err
// }
// if len(response.Communities()) == 0 {
// return errors.New("no communities in response (address change reception)")
// }
// return nil
// })
// s.Require().NoError(err)
// revealedAccounts, err = s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
// s.Require().NoError(err)
// Retrieve address change
err = tt.RetryWithBackOff(func() error {
response, err := s.owner.RetrieveAll()
if err != nil {
return err
}
if len(response.Communities()) == 0 {
return errors.New("no communities in response (address change reception)")
}
return nil
})
s.Require().NoError(err)
revealedAccounts, err = s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
s.Require().NoError(err)
// s.Require().Len(revealedAccounts, 1)
// s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
// s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
s.Require().Len(revealedAccounts, 1)
s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
// // Retrieve community description change
// err = tt.RetryWithBackOff(func() error {
// response, err := s.alice.RetrieveAll()
// if err != nil {
// return err
// }
// if len(response.Communities()) == 0 {
// return errors.New("no communities in response (address change reception)")
// }
// return nil
// })
// s.Require().NoError(err)
// Retrieve community description change
err = tt.RetryWithBackOff(func() error {
response, err := s.alice.RetrieveAll()
if err != nil {
return err
}
if len(response.Communities()) == 0 {
return errors.New("no communities in response (address change reception)")
}
return nil
})
s.Require().NoError(err)
// alicesRevealedAccounts, err = s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
// s.Require().NoError(err)
// s.Require().Len(alicesRevealedAccounts, 1)
// s.Require().Equal(alicesRevealedAccounts[0].Address, aliceAddress1)
// s.Require().Equal(true, alicesRevealedAccounts[0].IsAirdropAddress)
// }
alicesRevealedAccounts, err = s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
s.Require().NoError(err)
s.Require().Len(alicesRevealedAccounts, 1)
s.Require().Equal(alicesRevealedAccounts[0].Address, aliceAddress1)
s.Require().Equal(true, alicesRevealedAccounts[0].IsAirdropAddress)
}
// NOTE(cammellos): Disabling for now as flaky, for some reason does not pass on CI, but passes locally
/*
@ -819,183 +819,183 @@ func (s *MessengerCommunitiesTokenPermissionsSuite) TestBecomeMemberPermissions(
s.Require().NoError(err)
}*/
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityWithAdminPermission() {
// community, _ := s.createCommunity()
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityWithAdminPermission() {
community, _ := s.createCommunity()
// // setup become admin permission
// permissionRequest := requests.CreateCommunityTokenPermission{
// CommunityID: community.ID(),
// Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
// TokenCriteria: []*protobuf.TokenCriteria{
// &protobuf.TokenCriteria{
// Type: protobuf.CommunityTokenType_ERC20,
// ContractAddresses: map[uint64]string{testChainID1: "0x123"},
// Symbol: "TEST",
// Amount: "100",
// Decimals: uint64(18),
// },
// },
// }
// setup become admin permission
permissionRequest := requests.CreateCommunityTokenPermission{
CommunityID: community.ID(),
Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
TokenCriteria: []*protobuf.TokenCriteria{
&protobuf.TokenCriteria{
Type: protobuf.CommunityTokenType_ERC20,
ContractAddresses: map[uint64]string{testChainID1: "0x123"},
Symbol: "TEST",
Amount: "100",
Decimals: uint64(18),
},
},
}
// response, err := s.owner.CreateCommunityTokenPermission(&permissionRequest)
// s.Require().NoError(err)
// s.Require().Len(response.Communities(), 1)
response, err := s.owner.CreateCommunityTokenPermission(&permissionRequest)
s.Require().NoError(err)
s.Require().Len(response.Communities(), 1)
// s.advertiseCommunityTo(community, s.bob)
s.advertiseCommunityTo(community, s.bob)
// // Bob should still be able to join even if there is a permission to be an admin
// s.joinCommunity(community, s.bob, bobPassword, []string{})
// Bob should still be able to join even if there is a permission to be an admin
s.joinCommunity(community, s.bob, bobPassword, []string{})
// // Verify that we have Bob's revealed account
// revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
// s.Require().NoError(err)
// s.Require().Len(revealedAccounts, 1)
// s.Require().Equal(bobAddress, revealedAccounts[0].Address)
// }
// Verify that we have Bob's revealed account
revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
s.Require().NoError(err)
s.Require().Len(revealedAccounts, 1)
s.Require().Equal(bobAddress, revealedAccounts[0].Address)
}
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityAsMemberWithMemberAndAdminPermission() {
// community, _ := s.createCommunity()
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityAsMemberWithMemberAndAdminPermission() {
community, _ := s.createCommunity()
// waitOnCommunityPermissionCreated := waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
// return sub.Community.HasTokenPermissions()
// })
waitOnCommunityPermissionCreated := waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
return sub.Community.HasTokenPermissions()
})
// // setup become member permission
// permissionRequestMember := requests.CreateCommunityTokenPermission{
// CommunityID: community.ID(),
// Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
// TokenCriteria: []*protobuf.TokenCriteria{
// &protobuf.TokenCriteria{
// Type: protobuf.CommunityTokenType_ERC20,
// ContractAddresses: map[uint64]string{testChainID1: "0x123"},
// Symbol: "TEST",
// Amount: "100",
// Decimals: uint64(18),
// },
// },
// }
// response, err := s.owner.CreateCommunityTokenPermission(&permissionRequestMember)
// s.Require().NoError(err)
// s.Require().Len(response.Communities(), 1)
// setup become member permission
permissionRequestMember := requests.CreateCommunityTokenPermission{
CommunityID: community.ID(),
Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
TokenCriteria: []*protobuf.TokenCriteria{
&protobuf.TokenCriteria{
Type: protobuf.CommunityTokenType_ERC20,
ContractAddresses: map[uint64]string{testChainID1: "0x123"},
Symbol: "TEST",
Amount: "100",
Decimals: uint64(18),
},
},
}
response, err := s.owner.CreateCommunityTokenPermission(&permissionRequestMember)
s.Require().NoError(err)
s.Require().Len(response.Communities(), 1)
// err = <-waitOnCommunityPermissionCreated
// s.Require().NoError(err)
err = <-waitOnCommunityPermissionCreated
s.Require().NoError(err)
// // setup become admin permission
// permissionRequestAdmin := requests.CreateCommunityTokenPermission{
// CommunityID: community.ID(),
// Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
// TokenCriteria: []*protobuf.TokenCriteria{
// &protobuf.TokenCriteria{
// Type: protobuf.CommunityTokenType_ERC20,
// ContractAddresses: map[uint64]string{testChainID1: "0x124"},
// Symbol: "TESTADMIN",
// Amount: "100",
// Decimals: uint64(18),
// },
// },
// }
// response, err = s.owner.CreateCommunityTokenPermission(&permissionRequestAdmin)
// s.Require().NoError(err)
// s.Require().Len(response.Communities(), 1)
// setup become admin permission
permissionRequestAdmin := requests.CreateCommunityTokenPermission{
CommunityID: community.ID(),
Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
TokenCriteria: []*protobuf.TokenCriteria{
&protobuf.TokenCriteria{
Type: protobuf.CommunityTokenType_ERC20,
ContractAddresses: map[uint64]string{testChainID1: "0x124"},
Symbol: "TESTADMIN",
Amount: "100",
Decimals: uint64(18),
},
},
}
response, err = s.owner.CreateCommunityTokenPermission(&permissionRequestAdmin)
s.Require().NoError(err)
s.Require().Len(response.Communities(), 1)
// waitOnCommunityPermissionCreated = waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
// return len(sub.Community.TokenPermissions()) == 2
// })
waitOnCommunityPermissionCreated = waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
return len(sub.Community.TokenPermissions()) == 2
})
// err = <-waitOnCommunityPermissionCreated
// s.Require().NoError(err)
err = <-waitOnCommunityPermissionCreated
s.Require().NoError(err)
// // make bob satisfy the member criteria
// s.makeAddressSatisfyTheCriteria(testChainID1, bobAddress, permissionRequestMember.TokenCriteria[0])
// make bob satisfy the member criteria
s.makeAddressSatisfyTheCriteria(testChainID1, bobAddress, permissionRequestMember.TokenCriteria[0])
// s.advertiseCommunityTo(response.Communities()[0], s.bob)
s.advertiseCommunityTo(response.Communities()[0], s.bob)
// // Bob should still be able to join even though he doesn't satisfy the admin requirement
// // because he satisfies the member one
// s.joinCommunity(community, s.bob, bobPassword, []string{})
// Bob should still be able to join even though he doesn't satisfy the admin requirement
// because he satisfies the member one
s.joinCommunity(community, s.bob, bobPassword, []string{})
// // Verify that we have Bob's revealed account
// revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
// s.Require().NoError(err)
// s.Require().Len(revealedAccounts, 1)
// s.Require().Equal(bobAddress, revealedAccounts[0].Address)
// }
// Verify that we have Bob's revealed account
revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
s.Require().NoError(err)
s.Require().Len(revealedAccounts, 1)
s.Require().Equal(bobAddress, revealedAccounts[0].Address)
}
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityAsAdminWithMemberAndAdminPermission() {
// community, _ := s.createCommunity()
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityAsAdminWithMemberAndAdminPermission() {
community, _ := s.createCommunity()
// // setup become member permission
// permissionRequestMember := requests.CreateCommunityTokenPermission{
// CommunityID: community.ID(),
// Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
// TokenCriteria: []*protobuf.TokenCriteria{
// &protobuf.TokenCriteria{
// Type: protobuf.CommunityTokenType_ERC20,
// ContractAddresses: map[uint64]string{testChainID1: "0x123"},
// Symbol: "TEST",
// Amount: "100",
// Decimals: uint64(18),
// },
// },
// }
// response, err := s.owner.CreateCommunityTokenPermission(&permissionRequestMember)
// s.Require().NoError(err)
// s.Require().Len(response.Communities(), 1)
// setup become member permission
permissionRequestMember := requests.CreateCommunityTokenPermission{
CommunityID: community.ID(),
Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
TokenCriteria: []*protobuf.TokenCriteria{
&protobuf.TokenCriteria{
Type: protobuf.CommunityTokenType_ERC20,
ContractAddresses: map[uint64]string{testChainID1: "0x123"},
Symbol: "TEST",
Amount: "100",
Decimals: uint64(18),
},
},
}
response, err := s.owner.CreateCommunityTokenPermission(&permissionRequestMember)
s.Require().NoError(err)
s.Require().Len(response.Communities(), 1)
// waitOnCommunityPermissionCreated := waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
// return sub.Community.HasTokenPermissions()
// })
waitOnCommunityPermissionCreated := waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
return sub.Community.HasTokenPermissions()
})
// err = <-waitOnCommunityPermissionCreated
// s.Require().NoError(err)
err = <-waitOnCommunityPermissionCreated
s.Require().NoError(err)
// // setup become admin permission
// permissionRequestAdmin := requests.CreateCommunityTokenPermission{
// CommunityID: community.ID(),
// Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
// TokenCriteria: []*protobuf.TokenCriteria{
// &protobuf.TokenCriteria{
// Type: protobuf.CommunityTokenType_ERC20,
// ContractAddresses: map[uint64]string{testChainID1: "0x124"},
// Symbol: "TESTADMIN",
// Amount: "100",
// Decimals: uint64(18),
// },
// },
// }
// response, err = s.owner.CreateCommunityTokenPermission(&permissionRequestAdmin)
// s.Require().NoError(err)
// s.Require().Len(response.Communities(), 1)
// s.Require().Len(response.Communities()[0].TokenPermissionsByType(protobuf.CommunityTokenPermission_BECOME_ADMIN), 1)
// s.Require().Len(response.Communities()[0].TokenPermissions(), 2)
// setup become admin permission
permissionRequestAdmin := requests.CreateCommunityTokenPermission{
CommunityID: community.ID(),
Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
TokenCriteria: []*protobuf.TokenCriteria{
&protobuf.TokenCriteria{
Type: protobuf.CommunityTokenType_ERC20,
ContractAddresses: map[uint64]string{testChainID1: "0x124"},
Symbol: "TESTADMIN",
Amount: "100",
Decimals: uint64(18),
},
},
}
response, err = s.owner.CreateCommunityTokenPermission(&permissionRequestAdmin)
s.Require().NoError(err)
s.Require().Len(response.Communities(), 1)
s.Require().Len(response.Communities()[0].TokenPermissionsByType(protobuf.CommunityTokenPermission_BECOME_ADMIN), 1)
s.Require().Len(response.Communities()[0].TokenPermissions(), 2)
// waitOnCommunityPermissionCreated = waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
// return len(sub.Community.TokenPermissions()) == 2
// })
waitOnCommunityPermissionCreated = waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
return len(sub.Community.TokenPermissions()) == 2
})
// err = <-waitOnCommunityPermissionCreated
// s.Require().NoError(err)
err = <-waitOnCommunityPermissionCreated
s.Require().NoError(err)
// community, err = s.owner.communitiesManager.GetByID(community.ID())
// s.Require().NoError(err)
// s.Require().Len(community.TokenPermissions(), 2)
community, err = s.owner.communitiesManager.GetByID(community.ID())
s.Require().NoError(err)
s.Require().Len(community.TokenPermissions(), 2)
// s.advertiseCommunityTo(community, s.bob)
s.advertiseCommunityTo(community, s.bob)
// // make bob satisfy the admin criteria
// s.makeAddressSatisfyTheCriteria(testChainID1, bobAddress, permissionRequestAdmin.TokenCriteria[0])
// make bob satisfy the admin criteria
s.makeAddressSatisfyTheCriteria(testChainID1, bobAddress, permissionRequestAdmin.TokenCriteria[0])
// // Bob should still be able to join even though he doesn't satisfy the member requirement
// // because he satisfies the admin one
// s.joinCommunity(community, s.bob, bobPassword, []string{})
// Bob should still be able to join even though he doesn't satisfy the member requirement
// because he satisfies the admin one
s.joinCommunity(community, s.bob, bobPassword, []string{})
// // Verify that we have Bob's revealed account
// revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
// s.Require().NoError(err)
// s.Require().Len(revealedAccounts, 1)
// s.Require().Equal(bobAddress, revealedAccounts[0].Address)
// }
// Verify that we have Bob's revealed account
revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
s.Require().NoError(err)
s.Require().Len(revealedAccounts, 1)
s.Require().Equal(bobAddress, revealedAccounts[0].Address)
}
func (s *MessengerCommunitiesTokenPermissionsSuite) TestViewChannelPermissions() {
community, chat := s.createCommunity()
@ -1228,7 +1228,6 @@ func (s *MessengerCommunitiesTokenPermissionsSuite) TestReevaluateMemberTokenMas
s.testReevaluateMemberPrivilegedRoleInOpenCommunity(protobuf.CommunityTokenPermission_BECOME_TOKEN_MASTER)
}
/*
func (s *MessengerCommunitiesTokenPermissionsSuite) testReevaluateMemberPrivilegedRoleInClosedCommunity(permissionType protobuf.CommunityTokenPermission_Type) {
community, _ := s.createCommunity()
@ -1361,12 +1360,11 @@ func (s *MessengerCommunitiesTokenPermissionsSuite) testReevaluateMemberPrivileg
s.Require().False(checkRoleBasedOnThePermissionType(permissionType, &s.alice.identity.PublicKey, community))
}
*/
/*
func (s *MessengerCommunitiesTokenPermissionsSuite) TestReevaluateMemberAdminRoleInClosedCommunity() {
s.testReevaluateMemberPrivilegedRoleInClosedCommunity(protobuf.CommunityTokenPermission_BECOME_ADMIN)
}
*/
/*
func (s *MessengerCommunitiesTokenPermissionsSuite) TestReevaluateMemberTokenMasterRoleInClosedCommunity() {
s.testReevaluateMemberPrivilegedRoleInClosedCommunity(protobuf.CommunityTokenPermission_BECOME_TOKEN_MASTER)

View File

@ -2,17 +2,16 @@ package protocol
import (
"context"
// "crypto/ecdsa"
"crypto/ecdsa"
"testing"
// "github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/suite"
"go.uber.org/zap"
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"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/common/shard"
"github.com/status-im/status-go/protocol/communities"
"github.com/status-im/status-go/protocol/protobuf"
@ -147,7 +146,6 @@ func (s *MessengerCommunitiesShardingSuite) TestPostToCommunityChat() {
}
}
/*
func (s *MessengerCommunitiesShardingSuite) TestIgnoreOutdatedShardKey() {
community, _ := createCommunity(&s.Suite, s.owner)
@ -222,4 +220,3 @@ func (s *MessengerCommunitiesShardingSuite) TestIgnoreOutdatedShardKey() {
s.Require().NoError(err)
}
}
*/

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,8 @@
package protocol
import (
//"context"
//"errors"
"context"
"errors"
"testing"
"time"
@ -12,12 +11,10 @@ import (
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"
//"github.com/status-im/status-go/protocol/communities"
// "github.com/status-im/status-go/protocol/protobuf"
//"github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/communities"
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/tt"
)
@ -100,95 +97,95 @@ func (s *MessengerOfflineSuite) newMessenger(waku types.Waku, logger *zap.Logger
})
}
// func (s *MessengerOfflineSuite) advertiseCommunityTo(community *communities.Community, owner *Messenger, user *Messenger) {
// advertiseCommunityTo(&s.Suite, community, owner, user)
// }
func (s *MessengerOfflineSuite) advertiseCommunityTo(community *communities.Community, owner *Messenger, user *Messenger) {
advertiseCommunityTo(&s.Suite, community, owner, user)
}
// func (s *MessengerOfflineSuite) joinCommunity(community *communities.Community, owner *Messenger, user *Messenger) {
// request := &requests.RequestToJoinCommunity{CommunityID: community.ID()}
// joinCommunity(&s.Suite, community, owner, user, request, "")
// }
func (s *MessengerOfflineSuite) joinCommunity(community *communities.Community, owner *Messenger, user *Messenger) {
request := &requests.RequestToJoinCommunity{CommunityID: community.ID()}
joinCommunity(&s.Suite, community, owner, user, request, "")
}
// func (s *MessengerOfflineSuite) TestCommunityOfflineEdit() {
// community, chat := createCommunity(&s.Suite, s.owner)
func (s *MessengerOfflineSuite) TestCommunityOfflineEdit() {
community, chat := createCommunity(&s.Suite, s.owner)
// chatID := chat.ID
// inputMessage := common.NewMessage()
// inputMessage.ChatId = chatID
// inputMessage.ContentType = protobuf.ChatMessage_TEXT_PLAIN
// inputMessage.Text = "some text"
chatID := chat.ID
inputMessage := common.NewMessage()
inputMessage.ChatId = chatID
inputMessage.ContentType = protobuf.ChatMessage_TEXT_PLAIN
inputMessage.Text = "some text"
// ctx := context.Background()
ctx := context.Background()
// s.advertiseCommunityTo(community, s.owner, s.alice)
// s.joinCommunity(community, s.owner, s.alice)
s.advertiseCommunityTo(community, s.owner, s.alice)
s.joinCommunity(community, s.owner, s.alice)
// _, err := s.alice.SendChatMessage(ctx, inputMessage)
// s.Require().NoError(err)
// s.checkMessageDelivery(ctx, inputMessage)
_, err := s.alice.SendChatMessage(ctx, inputMessage)
s.Require().NoError(err)
s.checkMessageDelivery(ctx, inputMessage)
// // Simulate going offline
// wakuv2 := gethbridge.GetGethWakuV2From(s.aliceWaku)
// wakuv2.SkipPublishToTopic(true)
// Simulate going offline
wakuv2 := gethbridge.GetGethWakuV2From(s.aliceWaku)
wakuv2.SkipPublishToTopic(true)
// resp, err := s.alice.SendChatMessage(ctx, inputMessage)
// messageID := types.Hex2Bytes(resp.Messages()[0].ID)
// s.Require().NoError(err)
resp, err := s.alice.SendChatMessage(ctx, inputMessage)
messageID := types.Hex2Bytes(resp.Messages()[0].ID)
s.Require().NoError(err)
// // Check that message is re-sent once back online
// wakuv2.SkipPublishToTopic(false)
// time.Sleep(5 * time.Second)
// Check that message is re-sent once back online
wakuv2.SkipPublishToTopic(false)
time.Sleep(5 * time.Second)
// s.checkMessageDelivery(ctx, inputMessage)
s.checkMessageDelivery(ctx, inputMessage)
// editedText := "some text edited"
// editedMessage := &requests.EditMessage{
// ID: messageID,
// Text: editedText,
// }
editedText := "some text edited"
editedMessage := &requests.EditMessage{
ID: messageID,
Text: editedText,
}
// wakuv2.SkipPublishToTopic(true)
// sendResponse, err := s.alice.EditMessage(ctx, editedMessage)
// s.Require().NotNil(sendResponse)
// s.Require().NoError(err)
wakuv2.SkipPublishToTopic(true)
sendResponse, err := s.alice.EditMessage(ctx, editedMessage)
s.Require().NotNil(sendResponse)
s.Require().NoError(err)
// // Check that message is re-sent once back online
// wakuv2.SkipPublishToTopic(false)
// time.Sleep(5 * time.Second)
// inputMessage.Text = editedText
// Check that message is re-sent once back online
wakuv2.SkipPublishToTopic(false)
time.Sleep(5 * time.Second)
inputMessage.Text = editedText
// s.checkMessageDelivery(ctx, inputMessage)
// }
s.checkMessageDelivery(ctx, inputMessage)
}
// func (s *MessengerOfflineSuite) checkMessageDelivery(ctx context.Context, inputMessage *common.Message) {
// var response *MessengerResponse
// // Pull message and make sure org is received
// err := tt.RetryWithBackOff(func() error {
// var err error
// response, err = s.owner.RetrieveAll()
// if err != nil {
// return err
// }
// if len(response.messages) == 0 {
// return errors.New("message not received")
// }
// return nil
// })
func (s *MessengerOfflineSuite) checkMessageDelivery(ctx context.Context, inputMessage *common.Message) {
var response *MessengerResponse
// Pull message and make sure org is received
err := tt.RetryWithBackOff(func() error {
var err error
response, err = s.owner.RetrieveAll()
if err != nil {
return err
}
if len(response.messages) == 0 {
return errors.New("message not received")
}
return nil
})
// s.Require().NoError(err)
// s.Require().Len(response.Messages(), 1)
// s.Require().Equal(inputMessage.Text, response.Messages()[0].Text)
s.Require().NoError(err)
s.Require().Len(response.Messages(), 1)
s.Require().Equal(inputMessage.Text, response.Messages()[0].Text)
// // check if response contains the chat we're interested in
// // we use this instead of checking just the length of the chat because
// // a CommunityDescription message might be received in the meantime due to syncing
// // hence response.Chats() might contain the general chat, and the new chat;
// // or only the new chat if the CommunityDescription message has not arrived
// found := false
// for _, chat := range response.Chats() {
// if chat.ID == inputMessage.ChatId {
// found = true
// }
// }
// s.Require().True(found)
// }
// check if response contains the chat we're interested in
// we use this instead of checking just the length of the chat because
// a CommunityDescription message might be received in the meantime due to syncing
// hence response.Chats() might contain the general chat, and the new chat;
// or only the new chat if the CommunityDescription message has not arrived
found := false
for _, chat := range response.Chats() {
if chat.ID == inputMessage.ChatId {
found = true
}
}
s.Require().True(found)
}

View File

@ -71,46 +71,46 @@ func (s *TestMessengerProfileShowcase) mutualContact(theirMessenger *Messenger)
s.Require().True(resp.Contacts[0].mutual())
}
// func (s *TestMessengerProfileShowcase) verifiedContact(theirMessenger *Messenger) {
// theirPk := types.EncodeHex(crypto.FromECDSAPub(&theirMessenger.identity.PublicKey))
// challenge := "Want to see what I'm hiding in my profile showcase?"
func (s *TestMessengerProfileShowcase) verifiedContact(theirMessenger *Messenger) {
theirPk := types.EncodeHex(crypto.FromECDSAPub(&theirMessenger.identity.PublicKey))
challenge := "Want to see what I'm hiding in my profile showcase?"
// _, err := s.m.SendContactVerificationRequest(context.Background(), theirPk, challenge)
// s.Require().NoError(err)
_, err := s.m.SendContactVerificationRequest(context.Background(), theirPk, challenge)
s.Require().NoError(err)
// // Wait for the message to reach its destination
// resp, err := WaitOnMessengerResponse(
// theirMessenger,
// func(r *MessengerResponse) bool {
// return len(r.VerificationRequests()) == 1 && len(r.ActivityCenterNotifications()) == 1
// },
// "no messages",
// )
// s.Require().NoError(err)
// s.Require().Len(resp.VerificationRequests(), 1)
// verificationRequestID := resp.VerificationRequests()[0].ID
// Wait for the message to reach its destination
resp, err := WaitOnMessengerResponse(
theirMessenger,
func(r *MessengerResponse) bool {
return len(r.VerificationRequests()) == 1 && len(r.ActivityCenterNotifications()) == 1
},
"no messages",
)
s.Require().NoError(err)
s.Require().Len(resp.VerificationRequests(), 1)
verificationRequestID := resp.VerificationRequests()[0].ID
// _, err = theirMessenger.AcceptContactVerificationRequest(context.Background(), verificationRequestID, "For sure!")
// s.Require().NoError(err)
_, err = theirMessenger.AcceptContactVerificationRequest(context.Background(), verificationRequestID, "For sure!")
s.Require().NoError(err)
// s.Require().NoError(err)
s.Require().NoError(err)
// // Wait for the message to reach its destination
// _, err = WaitOnMessengerResponse(
// s.m,
// func(r *MessengerResponse) bool {
// return len(r.VerificationRequests()) == 1
// },
// "no messages",
// )
// s.Require().NoError(err)
// Wait for the message to reach its destination
_, err = WaitOnMessengerResponse(
s.m,
func(r *MessengerResponse) bool {
return len(r.VerificationRequests()) == 1
},
"no messages",
)
s.Require().NoError(err)
// resp, err = s.m.VerifiedTrusted(context.Background(), &requests.VerifiedTrusted{ID: types.FromHex(verificationRequestID)})
// s.Require().NoError(err)
resp, err = s.m.VerifiedTrusted(context.Background(), &requests.VerifiedTrusted{ID: types.FromHex(verificationRequestID)})
s.Require().NoError(err)
// s.Require().Len(resp.Messages(), 1)
// s.Require().Equal(common.ContactVerificationStateTrusted, resp.Messages()[0].ContactVerificationState)
// }
s.Require().Len(resp.Messages(), 1)
s.Require().Equal(common.ContactVerificationStateTrusted, resp.Messages()[0].ContactVerificationState)
}
func (s *TestMessengerProfileShowcase) TestSaveAndGetProfileShowcasePreferences() {
request := DummyProfileShowcasePreferences()
@ -287,134 +287,134 @@ func (s *TestMessengerProfileShowcase) TestEncryptAndDecryptProfileShowcaseEntri
}
}
// func (s *TestMessengerProfileShowcase) TestShareShowcasePreferences() {
// // Set Display name to pass shouldPublishChatIdentity check
// profileKp := accounts.GetProfileKeypairForTest(true, false, false)
// profileKp.KeyUID = s.m.account.KeyUID
// profileKp.Accounts[0].KeyUID = s.m.account.KeyUID
func (s *TestMessengerProfileShowcase) TestShareShowcasePreferences() {
// Set Display name to pass shouldPublishChatIdentity check
profileKp := accounts.GetProfileKeypairForTest(true, false, false)
profileKp.KeyUID = s.m.account.KeyUID
profileKp.Accounts[0].KeyUID = s.m.account.KeyUID
// err := s.m.settings.SaveOrUpdateKeypair(profileKp)
// s.Require().NoError(err)
err := s.m.settings.SaveOrUpdateKeypair(profileKp)
s.Require().NoError(err)
// err = s.m.SetDisplayName("bobby")
// s.Require().NoError(err)
err = s.m.SetDisplayName("bobby")
s.Require().NoError(err)
// // Add mutual contact
// mutualContact := s.newMessenger()
// _, err = mutualContact.Start()
// s.Require().NoError(err)
// defer TearDownMessenger(&s.Suite, mutualContact)
// Add mutual contact
mutualContact := s.newMessenger()
_, err = mutualContact.Start()
s.Require().NoError(err)
defer TearDownMessenger(&s.Suite, mutualContact)
// s.mutualContact(mutualContact)
s.mutualContact(mutualContact)
// // Add identity verified contact
// verifiedContact := s.newMessenger()
// _, err = verifiedContact.Start()
// s.Require().NoError(err)
// defer TearDownMessenger(&s.Suite, verifiedContact)
// Add identity verified contact
verifiedContact := s.newMessenger()
_, err = verifiedContact.Start()
s.Require().NoError(err)
defer TearDownMessenger(&s.Suite, verifiedContact)
// s.mutualContact(verifiedContact)
// s.verifiedContact(verifiedContact)
s.mutualContact(verifiedContact)
s.verifiedContact(verifiedContact)
// // Save preferences to dispatch changes
// request := DummyProfileShowcasePreferences()
// err = s.m.SetProfileShowcasePreferences(request, false)
// s.Require().NoError(err)
// Save preferences to dispatch changes
request := DummyProfileShowcasePreferences()
err = s.m.SetProfileShowcasePreferences(request, false)
s.Require().NoError(err)
// contactID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey))
// // Get summarised profile data for mutual contact
// resp, err := WaitOnMessengerResponse(
// mutualContact,
// func(r *MessengerResponse) bool {
// return len(r.updatedProfileShowcases) > 0 && r.updatedProfileShowcases[contactID] != nil
// },
// "no messages",
// )
// s.Require().NoError(err)
// s.Require().Len(resp.updatedProfileShowcases, 1)
contactID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey))
// Get summarised profile data for mutual contact
resp, err := WaitOnMessengerResponse(
mutualContact,
func(r *MessengerResponse) bool {
return len(r.updatedProfileShowcases) > 0 && r.updatedProfileShowcases[contactID] != nil
},
"no messages",
)
s.Require().NoError(err)
s.Require().Len(resp.updatedProfileShowcases, 1)
// profileShowcase := resp.updatedProfileShowcases[contactID]
profileShowcase := resp.updatedProfileShowcases[contactID]
// s.Require().Len(profileShowcase.Accounts, 2)
// s.Require().Equal(profileShowcase.Accounts[0].Address, request.Accounts[0].Address)
// s.Require().Equal(profileShowcase.Accounts[0].Name, request.Accounts[0].Name)
// s.Require().Equal(profileShowcase.Accounts[0].ColorID, request.Accounts[0].ColorID)
// s.Require().Equal(profileShowcase.Accounts[0].Emoji, request.Accounts[0].Emoji)
// s.Require().Equal(profileShowcase.Accounts[0].Order, request.Accounts[0].Order)
// s.Require().Equal(profileShowcase.Accounts[1].Address, request.Accounts[1].Address)
// s.Require().Equal(profileShowcase.Accounts[1].Name, request.Accounts[1].Name)
// s.Require().Equal(profileShowcase.Accounts[1].ColorID, request.Accounts[1].ColorID)
// s.Require().Equal(profileShowcase.Accounts[1].Emoji, request.Accounts[1].Emoji)
// s.Require().Equal(profileShowcase.Accounts[1].Order, request.Accounts[1].Order)
s.Require().Len(profileShowcase.Accounts, 2)
s.Require().Equal(profileShowcase.Accounts[0].Address, request.Accounts[0].Address)
s.Require().Equal(profileShowcase.Accounts[0].Name, request.Accounts[0].Name)
s.Require().Equal(profileShowcase.Accounts[0].ColorID, request.Accounts[0].ColorID)
s.Require().Equal(profileShowcase.Accounts[0].Emoji, request.Accounts[0].Emoji)
s.Require().Equal(profileShowcase.Accounts[0].Order, request.Accounts[0].Order)
s.Require().Equal(profileShowcase.Accounts[1].Address, request.Accounts[1].Address)
s.Require().Equal(profileShowcase.Accounts[1].Name, request.Accounts[1].Name)
s.Require().Equal(profileShowcase.Accounts[1].ColorID, request.Accounts[1].ColorID)
s.Require().Equal(profileShowcase.Accounts[1].Emoji, request.Accounts[1].Emoji)
s.Require().Equal(profileShowcase.Accounts[1].Order, request.Accounts[1].Order)
// s.Require().Len(profileShowcase.Collectibles, 1)
// s.Require().Equal(profileShowcase.Collectibles[0].TokenID, request.Collectibles[0].TokenID)
// s.Require().Equal(profileShowcase.Collectibles[0].ChainID, request.Collectibles[0].ChainID)
// s.Require().Equal(profileShowcase.Collectibles[0].ContractAddress, request.Collectibles[0].ContractAddress)
// s.Require().Equal(profileShowcase.Collectibles[0].AccountAddress, request.Collectibles[0].AccountAddress)
// s.Require().Equal(profileShowcase.Collectibles[0].CommunityID, request.Collectibles[0].CommunityID)
// s.Require().Equal(profileShowcase.Collectibles[0].Order, request.Collectibles[0].Order)
s.Require().Len(profileShowcase.Collectibles, 1)
s.Require().Equal(profileShowcase.Collectibles[0].TokenID, request.Collectibles[0].TokenID)
s.Require().Equal(profileShowcase.Collectibles[0].ChainID, request.Collectibles[0].ChainID)
s.Require().Equal(profileShowcase.Collectibles[0].ContractAddress, request.Collectibles[0].ContractAddress)
s.Require().Equal(profileShowcase.Collectibles[0].AccountAddress, request.Collectibles[0].AccountAddress)
s.Require().Equal(profileShowcase.Collectibles[0].CommunityID, request.Collectibles[0].CommunityID)
s.Require().Equal(profileShowcase.Collectibles[0].Order, request.Collectibles[0].Order)
// s.Require().Len(profileShowcase.VerifiedTokens, 1)
// s.Require().Equal(profileShowcase.VerifiedTokens[0].Symbol, request.VerifiedTokens[0].Symbol)
// s.Require().Equal(profileShowcase.VerifiedTokens[0].Order, request.VerifiedTokens[0].Order)
s.Require().Len(profileShowcase.VerifiedTokens, 1)
s.Require().Equal(profileShowcase.VerifiedTokens[0].Symbol, request.VerifiedTokens[0].Symbol)
s.Require().Equal(profileShowcase.VerifiedTokens[0].Order, request.VerifiedTokens[0].Order)
// s.Require().Len(profileShowcase.UnverifiedTokens, 2)
// s.Require().Equal(profileShowcase.UnverifiedTokens[0].ContractAddress, request.UnverifiedTokens[0].ContractAddress)
// s.Require().Equal(profileShowcase.UnverifiedTokens[0].ChainID, request.UnverifiedTokens[0].ChainID)
// s.Require().Equal(profileShowcase.UnverifiedTokens[0].Order, request.UnverifiedTokens[0].Order)
// s.Require().Equal(profileShowcase.UnverifiedTokens[1].ContractAddress, request.UnverifiedTokens[1].ContractAddress)
// s.Require().Equal(profileShowcase.UnverifiedTokens[1].ChainID, request.UnverifiedTokens[1].ChainID)
// s.Require().Equal(profileShowcase.UnverifiedTokens[1].Order, request.UnverifiedTokens[1].Order)
s.Require().Len(profileShowcase.UnverifiedTokens, 2)
s.Require().Equal(profileShowcase.UnverifiedTokens[0].ContractAddress, request.UnverifiedTokens[0].ContractAddress)
s.Require().Equal(profileShowcase.UnverifiedTokens[0].ChainID, request.UnverifiedTokens[0].ChainID)
s.Require().Equal(profileShowcase.UnverifiedTokens[0].Order, request.UnverifiedTokens[0].Order)
s.Require().Equal(profileShowcase.UnverifiedTokens[1].ContractAddress, request.UnverifiedTokens[1].ContractAddress)
s.Require().Equal(profileShowcase.UnverifiedTokens[1].ChainID, request.UnverifiedTokens[1].ChainID)
s.Require().Equal(profileShowcase.UnverifiedTokens[1].Order, request.UnverifiedTokens[1].Order)
// // Get summarised profile data for verified contact
// resp, err = WaitOnMessengerResponse(
// verifiedContact,
// func(r *MessengerResponse) bool {
// return len(r.updatedProfileShowcases) > 0
// },
// "no messages",
// )
// s.Require().NoError(err)
// s.Require().Len(resp.updatedProfileShowcases, 1)
// Get summarised profile data for verified contact
resp, err = WaitOnMessengerResponse(
verifiedContact,
func(r *MessengerResponse) bool {
return len(r.updatedProfileShowcases) > 0
},
"no messages",
)
s.Require().NoError(err)
s.Require().Len(resp.updatedProfileShowcases, 1)
// // Here let's try synchronous
// profileShowcase, err = verifiedContact.GetProfileShowcaseForContact(contactID)
// s.Require().NoError(err)
// Here let's try synchronous
profileShowcase, err = verifiedContact.GetProfileShowcaseForContact(contactID)
s.Require().NoError(err)
// s.Require().Len(profileShowcase.Accounts, 2)
// s.Require().Equal(profileShowcase.Accounts[0].Address, request.Accounts[0].Address)
// s.Require().Equal(profileShowcase.Accounts[0].Name, request.Accounts[0].Name)
// s.Require().Equal(profileShowcase.Accounts[0].ColorID, request.Accounts[0].ColorID)
// s.Require().Equal(profileShowcase.Accounts[0].Emoji, request.Accounts[0].Emoji)
// s.Require().Equal(profileShowcase.Accounts[0].Order, request.Accounts[0].Order)
// s.Require().Equal(profileShowcase.Accounts[1].Address, request.Accounts[1].Address)
// s.Require().Equal(profileShowcase.Accounts[1].Name, request.Accounts[1].Name)
// s.Require().Equal(profileShowcase.Accounts[1].ColorID, request.Accounts[1].ColorID)
// s.Require().Equal(profileShowcase.Accounts[1].Emoji, request.Accounts[1].Emoji)
// s.Require().Equal(profileShowcase.Accounts[1].Order, request.Accounts[1].Order)
s.Require().Len(profileShowcase.Accounts, 2)
s.Require().Equal(profileShowcase.Accounts[0].Address, request.Accounts[0].Address)
s.Require().Equal(profileShowcase.Accounts[0].Name, request.Accounts[0].Name)
s.Require().Equal(profileShowcase.Accounts[0].ColorID, request.Accounts[0].ColorID)
s.Require().Equal(profileShowcase.Accounts[0].Emoji, request.Accounts[0].Emoji)
s.Require().Equal(profileShowcase.Accounts[0].Order, request.Accounts[0].Order)
s.Require().Equal(profileShowcase.Accounts[1].Address, request.Accounts[1].Address)
s.Require().Equal(profileShowcase.Accounts[1].Name, request.Accounts[1].Name)
s.Require().Equal(profileShowcase.Accounts[1].ColorID, request.Accounts[1].ColorID)
s.Require().Equal(profileShowcase.Accounts[1].Emoji, request.Accounts[1].Emoji)
s.Require().Equal(profileShowcase.Accounts[1].Order, request.Accounts[1].Order)
// s.Require().Len(profileShowcase.Collectibles, 1)
// s.Require().Equal(profileShowcase.Collectibles[0].ContractAddress, request.Collectibles[0].ContractAddress)
// s.Require().Equal(profileShowcase.Collectibles[0].ChainID, request.Collectibles[0].ChainID)
// s.Require().Equal(profileShowcase.Collectibles[0].TokenID, request.Collectibles[0].TokenID)
// s.Require().Equal(profileShowcase.Collectibles[0].CommunityID, request.Collectibles[0].CommunityID)
// s.Require().Equal(profileShowcase.Collectibles[0].Order, request.Collectibles[0].Order)
s.Require().Len(profileShowcase.Collectibles, 1)
s.Require().Equal(profileShowcase.Collectibles[0].ContractAddress, request.Collectibles[0].ContractAddress)
s.Require().Equal(profileShowcase.Collectibles[0].ChainID, request.Collectibles[0].ChainID)
s.Require().Equal(profileShowcase.Collectibles[0].TokenID, request.Collectibles[0].TokenID)
s.Require().Equal(profileShowcase.Collectibles[0].CommunityID, request.Collectibles[0].CommunityID)
s.Require().Equal(profileShowcase.Collectibles[0].Order, request.Collectibles[0].Order)
// s.Require().Len(profileShowcase.VerifiedTokens, 2)
// s.Require().Equal(profileShowcase.VerifiedTokens[0].Symbol, request.VerifiedTokens[0].Symbol)
// s.Require().Equal(profileShowcase.VerifiedTokens[0].Order, request.VerifiedTokens[0].Order)
// s.Require().Equal(profileShowcase.VerifiedTokens[1].Symbol, request.VerifiedTokens[1].Symbol)
// s.Require().Equal(profileShowcase.VerifiedTokens[1].Order, request.VerifiedTokens[1].Order)
s.Require().Len(profileShowcase.VerifiedTokens, 2)
s.Require().Equal(profileShowcase.VerifiedTokens[0].Symbol, request.VerifiedTokens[0].Symbol)
s.Require().Equal(profileShowcase.VerifiedTokens[0].Order, request.VerifiedTokens[0].Order)
s.Require().Equal(profileShowcase.VerifiedTokens[1].Symbol, request.VerifiedTokens[1].Symbol)
s.Require().Equal(profileShowcase.VerifiedTokens[1].Order, request.VerifiedTokens[1].Order)
// s.Require().Len(profileShowcase.UnverifiedTokens, 2)
// s.Require().Equal(profileShowcase.UnverifiedTokens[0].ContractAddress, request.UnverifiedTokens[0].ContractAddress)
// s.Require().Equal(profileShowcase.UnverifiedTokens[0].ChainID, request.UnverifiedTokens[0].ChainID)
// s.Require().Equal(profileShowcase.UnverifiedTokens[0].Order, request.UnverifiedTokens[0].Order)
// s.Require().Equal(profileShowcase.UnverifiedTokens[1].ContractAddress, request.UnverifiedTokens[1].ContractAddress)
// s.Require().Equal(profileShowcase.UnverifiedTokens[1].ChainID, request.UnverifiedTokens[1].ChainID)
// s.Require().Equal(profileShowcase.UnverifiedTokens[1].Order, request.UnverifiedTokens[1].Order)
// }
s.Require().Len(profileShowcase.UnverifiedTokens, 2)
s.Require().Equal(profileShowcase.UnverifiedTokens[0].ContractAddress, request.UnverifiedTokens[0].ContractAddress)
s.Require().Equal(profileShowcase.UnverifiedTokens[0].ChainID, request.UnverifiedTokens[0].ChainID)
s.Require().Equal(profileShowcase.UnverifiedTokens[0].Order, request.UnverifiedTokens[0].Order)
s.Require().Equal(profileShowcase.UnverifiedTokens[1].ContractAddress, request.UnverifiedTokens[1].ContractAddress)
s.Require().Equal(profileShowcase.UnverifiedTokens[1].ChainID, request.UnverifiedTokens[1].ChainID)
s.Require().Equal(profileShowcase.UnverifiedTokens[1].Order, request.UnverifiedTokens[1].Order)
}
func (s *TestMessengerProfileShowcase) TestProfileShowcaseProofOfMembershipUnencryptedCommunities() {
alice := s.m

View File

@ -3,9 +3,7 @@ package pairing
import (
"context"
"encoding/json"
//"errors"
"errors"
"fmt"
"os"
"path/filepath"
@ -19,9 +17,7 @@ import (
"github.com/status-im/status-go/common/dbsetup"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/protocol"
//"github.com/status-im/status-go/protocol/encryption/multidevice"
"github.com/status-im/status-go/protocol/encryption/multidevice"
"github.com/status-im/status-go/protocol/tt"
"github.com/google/uuid"
@ -56,8 +52,8 @@ const (
publicChatID = "localpairtest"
profileKeypairMnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon"
seedKeypairMnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
//profileKeypairMnemonic1 = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about about"
//seedKeypairMnemonic1 = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about abandon"
profileKeypairMnemonic1 = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about about"
seedKeypairMnemonic1 = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about abandon"
path0 = "m/44'/60'/0'/0/0"
path1 = "m/44'/60'/0'/0/1"
expectedKDFIterations = 1024
@ -883,8 +879,7 @@ func (s *SyncDeviceSuite) TestTransferringKeystoreFiles() {
}
}
/*
func (s *SyncDeviceSuite) TestTransferringKeystoreFilesAfterStopUisngKeycard() {
func (s *SyncDeviceSuite) TestTransferringKeystoreFilesAfterStopUisngKeycard() {
ctx := context.TODO()
// Prepare server
@ -1179,8 +1174,8 @@ func (s *SyncDeviceSuite) TestTransferringKeystoreFiles() {
for _, acc := range clientKp.Accounts {
require.True(s.T(), containsKeystoreFile(clientKeystorePath, acc.Address.String()[2:]))
}
}
*/
}
func (s *SyncDeviceSuite) TestPreventLoggedInAccountLocalPairingClientAsReceiver() {
clientTmpDir := filepath.Join(s.clientAsSenderTmpdir, "client")
clientBackend := s.prepareBackendWithAccount("", clientTmpDir)