Revert "Comment out flaky tests (#4741)"
This reverts commit 582927868d
.
This commit is contained in:
parent
cc708ce0ce
commit
1fca1e1743
|
@ -3453,111 +3453,111 @@ func (s *MessengerCommunitiesSuite) TestStartCommunityRekeyLoop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (s *MessengerCommunitiesSuite) TestCommunityRekeyAfterBan() {
|
func (s *MessengerCommunitiesSuite) TestCommunityRekeyAfterBan() {
|
||||||
// s.owner.communitiesManager.RekeyInterval = 500 * time.Minute
|
s.owner.communitiesManager.RekeyInterval = 500 * time.Minute
|
||||||
|
|
||||||
// _, err := s.owner.Start()
|
_, err := s.owner.Start()
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// // Create a new community
|
// Create a new community
|
||||||
// response, err := s.owner.CreateCommunity(
|
response, err := s.owner.CreateCommunity(
|
||||||
// &requests.CreateCommunity{
|
&requests.CreateCommunity{
|
||||||
// Membership: protobuf.CommunityPermissions_AUTO_ACCEPT,
|
Membership: protobuf.CommunityPermissions_AUTO_ACCEPT,
|
||||||
// Name: "status",
|
Name: "status",
|
||||||
// Color: "#57a7e5",
|
Color: "#57a7e5",
|
||||||
// Description: "status community description",
|
Description: "status community description",
|
||||||
// },
|
},
|
||||||
// true,
|
true,
|
||||||
// )
|
)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
// s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
// s.Require().Len(response.Communities()[0].Members(), 1)
|
s.Require().Len(response.Communities()[0].Members(), 1)
|
||||||
|
|
||||||
// // Check community is present in the DB and has default values we care about
|
// Check community is present in the DB and has default values we care about
|
||||||
// c, err := s.owner.GetCommunityByID(response.Communities()[0].ID())
|
c, err := s.owner.GetCommunityByID(response.Communities()[0].ID())
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().False(c.Encrypted())
|
s.Require().False(c.Encrypted())
|
||||||
// // TODO some check that there are no keys for the community. Alt for s.Require().Zero(c.RekeyedAt().Unix())
|
// 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{
|
_, err = s.owner.CreateCommunityTokenPermission(&requests.CreateCommunityTokenPermission{
|
||||||
// CommunityID: c.ID(),
|
CommunityID: c.ID(),
|
||||||
// Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
|
Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
|
||||||
// TokenCriteria: []*protobuf.TokenCriteria{{
|
TokenCriteria: []*protobuf.TokenCriteria{{
|
||||||
// ContractAddresses: map[uint64]string{3: "0x933"},
|
ContractAddresses: map[uint64]string{3: "0x933"},
|
||||||
// Type: protobuf.CommunityTokenType_ERC20,
|
Type: protobuf.CommunityTokenType_ERC20,
|
||||||
// Symbol: "STT",
|
Symbol: "STT",
|
||||||
// Name: "Status Test Token",
|
Name: "Status Test Token",
|
||||||
// Amount: "10",
|
Amount: "10",
|
||||||
// Decimals: 18,
|
Decimals: 18,
|
||||||
// }},
|
}},
|
||||||
// })
|
})
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// c, err = s.owner.GetCommunityByID(c.ID())
|
c, err = s.owner.GetCommunityByID(c.ID())
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().True(c.Encrypted())
|
s.Require().True(c.Encrypted())
|
||||||
|
|
||||||
// s.advertiseCommunityTo(c, s.owner, s.bob)
|
s.advertiseCommunityTo(c, s.owner, s.bob)
|
||||||
// s.advertiseCommunityTo(c, s.owner, s.alice)
|
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.bob)
|
||||||
// s.joinCommunity(c, s.owner, s.alice)
|
s.joinCommunity(c, s.owner, s.alice)
|
||||||
|
|
||||||
// // Check the Alice and Bob are members of the community
|
// Check the Alice and Bob are members of the community
|
||||||
// c, err = s.owner.GetCommunityByID(c.ID())
|
c, err = s.owner.GetCommunityByID(c.ID())
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().True(c.HasMember(&s.alice.identity.PublicKey))
|
s.Require().True(c.HasMember(&s.alice.identity.PublicKey))
|
||||||
// s.Require().True(c.HasMember(&s.bob.identity.PublicKey))
|
s.Require().True(c.HasMember(&s.bob.identity.PublicKey))
|
||||||
|
|
||||||
// // Make sure at least one key makes it to alice
|
// Make sure at least one key makes it to alice
|
||||||
// response, err = WaitOnMessengerResponse(s.alice,
|
response, err = WaitOnMessengerResponse(s.alice,
|
||||||
// func(r *MessengerResponse) bool {
|
func(r *MessengerResponse) bool {
|
||||||
// keys, err := s.alice.encryptor.GetKeysForGroup(response.Communities()[0].ID())
|
keys, err := s.alice.encryptor.GetKeysForGroup(response.Communities()[0].ID())
|
||||||
// if err != nil || len(keys) != 1 {
|
if err != nil || len(keys) != 1 {
|
||||||
// return false
|
return false
|
||||||
// }
|
}
|
||||||
// return true
|
return true
|
||||||
|
|
||||||
// },
|
},
|
||||||
// "alice does not have enough keys",
|
"alice does not have enough keys",
|
||||||
// )
|
)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// response, err = s.owner.BanUserFromCommunity(context.Background(), &requests.BanUserFromCommunity{
|
response, err = s.owner.BanUserFromCommunity(context.Background(), &requests.BanUserFromCommunity{
|
||||||
// CommunityID: c.ID(),
|
CommunityID: c.ID(),
|
||||||
// User: common.PubkeyToHexBytes(&s.bob.identity.PublicKey),
|
User: common.PubkeyToHexBytes(&s.bob.identity.PublicKey),
|
||||||
// })
|
})
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(response.Communities(), 1)
|
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
|
// Check bob has been banned
|
||||||
// response, err = WaitOnMessengerResponse(s.alice,
|
response, err = WaitOnMessengerResponse(s.alice,
|
||||||
// func(r *MessengerResponse) bool {
|
func(r *MessengerResponse) bool {
|
||||||
// return len(r.Communities()) == 1 && !r.Communities()[0].HasMember(&s.bob.identity.PublicKey)
|
return len(r.Communities()) == 1 && !r.Communities()[0].HasMember(&s.bob.identity.PublicKey)
|
||||||
|
|
||||||
// },
|
},
|
||||||
// "alice didn't receive updated description",
|
"alice didn't receive updated description",
|
||||||
// )
|
)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// response, err = WaitOnMessengerResponse(s.alice,
|
response, err = WaitOnMessengerResponse(s.alice,
|
||||||
// func(r *MessengerResponse) bool {
|
func(r *MessengerResponse) bool {
|
||||||
// keys, err := s.alice.encryptor.GetKeysForGroup(response.Communities()[0].ID())
|
keys, err := s.alice.encryptor.GetKeysForGroup(response.Communities()[0].ID())
|
||||||
// if err != nil || len(keys) < 2 {
|
if err != nil || len(keys) < 2 {
|
||||||
// return false
|
return false
|
||||||
// }
|
}
|
||||||
// return true
|
return true
|
||||||
|
|
||||||
// },
|
},
|
||||||
// "alice hasn't received updated key",
|
"alice hasn't received updated key",
|
||||||
// )
|
)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// }
|
}
|
||||||
|
|
||||||
func (s *MessengerCommunitiesSuite) TestCommunityRekeyAfterBanDisableCompatibility() {
|
func (s *MessengerCommunitiesSuite) TestCommunityRekeyAfterBanDisableCompatibility() {
|
||||||
common.RekeyCompatibility = false
|
common.RekeyCompatibility = false
|
||||||
|
|
|
@ -239,123 +239,123 @@ func (s *MessengerCommunitiesTokenPermissionsSuite) waitOnKeyDistribution(condit
|
||||||
return testCommunitiesKeyDistributor.waitOnKeyDistribution(condition)
|
return testCommunitiesKeyDistributor.waitOnKeyDistribution(condition)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestCreateTokenPermission() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestCreateTokenPermission() {
|
||||||
// community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
|
|
||||||
// createTokenPermission := &requests.CreateCommunityTokenPermission{
|
createTokenPermission := &requests.CreateCommunityTokenPermission{
|
||||||
// CommunityID: community.ID(),
|
CommunityID: community.ID(),
|
||||||
// Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
|
Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
|
||||||
// TokenCriteria: []*protobuf.TokenCriteria{
|
TokenCriteria: []*protobuf.TokenCriteria{
|
||||||
// &protobuf.TokenCriteria{
|
&protobuf.TokenCriteria{
|
||||||
// Type: protobuf.CommunityTokenType_ERC20,
|
Type: protobuf.CommunityTokenType_ERC20,
|
||||||
// ContractAddresses: map[uint64]string{uint64(testChainID1): "0x123"},
|
ContractAddresses: map[uint64]string{uint64(testChainID1): "0x123"},
|
||||||
// Symbol: "TEST",
|
Symbol: "TEST",
|
||||||
// Amount: "100",
|
Amount: "100",
|
||||||
// Decimals: uint64(18),
|
Decimals: uint64(18),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
|
|
||||||
// response, err := s.owner.CreateCommunityTokenPermission(createTokenPermission)
|
response, err := s.owner.CreateCommunityTokenPermission(createTokenPermission)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
// s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
|
|
||||||
// tokenPermissions := response.Communities()[0].TokenPermissions()
|
tokenPermissions := response.Communities()[0].TokenPermissions()
|
||||||
// for _, tokenPermission := range tokenPermissions {
|
for _, tokenPermission := range tokenPermissions {
|
||||||
// for _, tc := range tokenPermission.TokenCriteria {
|
for _, tc := range tokenPermission.TokenCriteria {
|
||||||
// s.Require().Equal(tc.Type, protobuf.CommunityTokenType_ERC20)
|
s.Require().Equal(tc.Type, protobuf.CommunityTokenType_ERC20)
|
||||||
// s.Require().Equal(tc.Symbol, "TEST")
|
s.Require().Equal(tc.Symbol, "TEST")
|
||||||
// s.Require().Equal(tc.Amount, "100")
|
s.Require().Equal(tc.Amount, "100")
|
||||||
// s.Require().Equal(tc.Decimals, uint64(18))
|
s.Require().Equal(tc.Decimals, uint64(18))
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestEditTokenPermission() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestEditTokenPermission() {
|
||||||
// community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
|
|
||||||
// tokenPermission := &requests.CreateCommunityTokenPermission{
|
tokenPermission := &requests.CreateCommunityTokenPermission{
|
||||||
// CommunityID: community.ID(),
|
CommunityID: community.ID(),
|
||||||
// Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
|
Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
|
||||||
// TokenCriteria: []*protobuf.TokenCriteria{
|
TokenCriteria: []*protobuf.TokenCriteria{
|
||||||
// &protobuf.TokenCriteria{
|
&protobuf.TokenCriteria{
|
||||||
// Type: protobuf.CommunityTokenType_ERC20,
|
Type: protobuf.CommunityTokenType_ERC20,
|
||||||
// ContractAddresses: map[uint64]string{testChainID1: "0x123"},
|
ContractAddresses: map[uint64]string{testChainID1: "0x123"},
|
||||||
// Symbol: "TEST",
|
Symbol: "TEST",
|
||||||
// Amount: "100",
|
Amount: "100",
|
||||||
// Decimals: uint64(18),
|
Decimals: uint64(18),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
|
|
||||||
// response, err := s.owner.CreateCommunityTokenPermission(tokenPermission)
|
response, err := s.owner.CreateCommunityTokenPermission(tokenPermission)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
// s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
|
|
||||||
// tokenPermissions := response.Communities()[0].TokenPermissions()
|
tokenPermissions := response.Communities()[0].TokenPermissions()
|
||||||
|
|
||||||
// var tokenPermissionID string
|
var tokenPermissionID string
|
||||||
// for id := range tokenPermissions {
|
for id := range tokenPermissions {
|
||||||
// tokenPermissionID = id
|
tokenPermissionID = id
|
||||||
// }
|
}
|
||||||
|
|
||||||
// tokenPermission.TokenCriteria[0].Symbol = "TESTUpdated"
|
tokenPermission.TokenCriteria[0].Symbol = "TESTUpdated"
|
||||||
// tokenPermission.TokenCriteria[0].Amount = "200"
|
tokenPermission.TokenCriteria[0].Amount = "200"
|
||||||
// tokenPermission.TokenCriteria[0].Decimals = uint64(20)
|
tokenPermission.TokenCriteria[0].Decimals = uint64(20)
|
||||||
|
|
||||||
// editTokenPermission := &requests.EditCommunityTokenPermission{
|
editTokenPermission := &requests.EditCommunityTokenPermission{
|
||||||
// PermissionID: tokenPermissionID,
|
PermissionID: tokenPermissionID,
|
||||||
// CreateCommunityTokenPermission: *tokenPermission,
|
CreateCommunityTokenPermission: *tokenPermission,
|
||||||
// }
|
}
|
||||||
|
|
||||||
// response2, err := s.owner.EditCommunityTokenPermission(editTokenPermission)
|
response2, err := s.owner.EditCommunityTokenPermission(editTokenPermission)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// // wait for `checkMemberPermissions` to finish
|
// wait for `checkMemberPermissions` to finish
|
||||||
// time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
// s.Require().NotNil(response2)
|
s.Require().NotNil(response2)
|
||||||
// s.Require().Len(response2.Communities(), 1)
|
s.Require().Len(response2.Communities(), 1)
|
||||||
|
|
||||||
// tokenPermissions = response2.Communities()[0].TokenPermissions()
|
tokenPermissions = response2.Communities()[0].TokenPermissions()
|
||||||
// for _, tokenPermission := range tokenPermissions {
|
for _, tokenPermission := range tokenPermissions {
|
||||||
// for _, tc := range tokenPermission.TokenCriteria {
|
for _, tc := range tokenPermission.TokenCriteria {
|
||||||
// s.Require().Equal(tc.Type, protobuf.CommunityTokenType_ERC20)
|
s.Require().Equal(tc.Type, protobuf.CommunityTokenType_ERC20)
|
||||||
// s.Require().Equal(tc.Symbol, "TESTUpdated")
|
s.Require().Equal(tc.Symbol, "TESTUpdated")
|
||||||
// s.Require().Equal(tc.Amount, "200")
|
s.Require().Equal(tc.Amount, "200")
|
||||||
// s.Require().Equal(tc.Decimals, uint64(20))
|
s.Require().Equal(tc.Decimals, uint64(20))
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestCommunityTokensMetadata() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestCommunityTokensMetadata() {
|
||||||
// community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
|
|
||||||
// tokensMetadata := community.CommunityTokensMetadata()
|
tokensMetadata := community.CommunityTokensMetadata()
|
||||||
// s.Require().Len(tokensMetadata, 0)
|
s.Require().Len(tokensMetadata, 0)
|
||||||
|
|
||||||
// newToken := &protobuf.CommunityTokenMetadata{
|
newToken := &protobuf.CommunityTokenMetadata{
|
||||||
// ContractAddresses: map[uint64]string{testChainID1: "0xasd"},
|
ContractAddresses: map[uint64]string{testChainID1: "0xasd"},
|
||||||
// Description: "desc1",
|
Description: "desc1",
|
||||||
// Image: "IMG1",
|
Image: "IMG1",
|
||||||
// TokenType: protobuf.CommunityTokenType_ERC721,
|
TokenType: protobuf.CommunityTokenType_ERC721,
|
||||||
// Symbol: "SMB",
|
Symbol: "SMB",
|
||||||
// Decimals: 3,
|
Decimals: 3,
|
||||||
// }
|
}
|
||||||
|
|
||||||
// _, err := community.AddCommunityTokensMetadata(newToken)
|
_, err := community.AddCommunityTokensMetadata(newToken)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// tokensMetadata = community.CommunityTokensMetadata()
|
tokensMetadata = community.CommunityTokensMetadata()
|
||||||
// s.Require().Len(tokensMetadata, 1)
|
s.Require().Len(tokensMetadata, 1)
|
||||||
|
|
||||||
// s.Require().Equal(tokensMetadata[0].ContractAddresses, newToken.ContractAddresses)
|
s.Require().Equal(tokensMetadata[0].ContractAddresses, newToken.ContractAddresses)
|
||||||
// s.Require().Equal(tokensMetadata[0].Description, newToken.Description)
|
s.Require().Equal(tokensMetadata[0].Description, newToken.Description)
|
||||||
// s.Require().Equal(tokensMetadata[0].Image, newToken.Image)
|
s.Require().Equal(tokensMetadata[0].Image, newToken.Image)
|
||||||
// s.Require().Equal(tokensMetadata[0].TokenType, newToken.TokenType)
|
s.Require().Equal(tokensMetadata[0].TokenType, newToken.TokenType)
|
||||||
// s.Require().Equal(tokensMetadata[0].Symbol, newToken.Symbol)
|
s.Require().Equal(tokensMetadata[0].Symbol, newToken.Symbol)
|
||||||
// s.Require().Equal(tokensMetadata[0].Name, newToken.Name)
|
s.Require().Equal(tokensMetadata[0].Name, newToken.Name)
|
||||||
// s.Require().Equal(tokensMetadata[0].Decimals, newToken.Decimals)
|
s.Require().Equal(tokensMetadata[0].Decimals, newToken.Decimals)
|
||||||
// }
|
}
|
||||||
|
|
||||||
func (s *MessengerCommunitiesTokenPermissionsSuite) TestRequestAccessWithENSTokenPermission() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestRequestAccessWithENSTokenPermission() {
|
||||||
community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
|
@ -420,205 +420,205 @@ func (s *MessengerCommunitiesTokenPermissionsSuite) TestRequestAccessWithENSToke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersSharedAddress() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersSharedAddress() {
|
||||||
// community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
// s.advertiseCommunityTo(community, s.alice)
|
s.advertiseCommunityTo(community, s.alice)
|
||||||
// s.advertiseCommunityTo(community, s.bob)
|
s.advertiseCommunityTo(community, s.bob)
|
||||||
|
|
||||||
// s.joinCommunity(community, s.alice, alicePassword, []string{})
|
s.joinCommunity(community, s.alice, alicePassword, []string{})
|
||||||
// s.joinCommunity(community, s.bob, bobPassword, []string{})
|
s.joinCommunity(community, s.bob, bobPassword, []string{})
|
||||||
|
|
||||||
// community, err := s.owner.GetCommunityByID(community.ID())
|
community, err := s.owner.GetCommunityByID(community.ID())
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// s.Require().Equal(3, community.MembersCount())
|
s.Require().Equal(3, community.MembersCount())
|
||||||
|
|
||||||
// // Check owner's DB for revealed accounts
|
// Check owner's DB for revealed accounts
|
||||||
// for pubKey := range community.Members() {
|
for pubKey := range community.Members() {
|
||||||
// if pubKey != common.PubkeyToHex(&s.owner.identity.PublicKey) {
|
if pubKey != common.PubkeyToHex(&s.owner.identity.PublicKey) {
|
||||||
// revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), pubKey)
|
revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), pubKey)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// switch pubKey {
|
switch pubKey {
|
||||||
// case common.PubkeyToHex(&s.alice.identity.PublicKey):
|
case common.PubkeyToHex(&s.alice.identity.PublicKey):
|
||||||
// s.Require().Len(revealedAccounts, 2)
|
s.Require().Len(revealedAccounts, 2)
|
||||||
// s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
|
s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
|
||||||
// s.Require().Equal(revealedAccounts[1].Address, aliceAddress2)
|
s.Require().Equal(revealedAccounts[1].Address, aliceAddress2)
|
||||||
// s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
|
s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
|
||||||
// case common.PubkeyToHex(&s.bob.identity.PublicKey):
|
case common.PubkeyToHex(&s.bob.identity.PublicKey):
|
||||||
// s.Require().Len(revealedAccounts, 1)
|
s.Require().Len(revealedAccounts, 1)
|
||||||
// s.Require().Equal(revealedAccounts[0].Address, bobAddress)
|
s.Require().Equal(revealedAccounts[0].Address, bobAddress)
|
||||||
// s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
|
s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
|
||||||
// default:
|
default:
|
||||||
// s.Require().Fail("pubKey does not match expected keys")
|
s.Require().Fail("pubKey does not match expected keys")
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // Check Bob's DB for revealed accounts
|
// Check Bob's DB for revealed accounts
|
||||||
// revealedAccountsInBobsDB, err := s.bob.communitiesManager.GetRevealedAddresses(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
|
revealedAccountsInBobsDB, err := s.bob.communitiesManager.GetRevealedAddresses(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(revealedAccountsInBobsDB, 1)
|
s.Require().Len(revealedAccountsInBobsDB, 1)
|
||||||
// s.Require().Equal(revealedAccountsInBobsDB[0].Address, bobAddress)
|
s.Require().Equal(revealedAccountsInBobsDB[0].Address, bobAddress)
|
||||||
// s.Require().Equal(true, revealedAccountsInBobsDB[0].IsAirdropAddress)
|
s.Require().Equal(true, revealedAccountsInBobsDB[0].IsAirdropAddress)
|
||||||
|
|
||||||
// // Check Alices's DB for revealed accounts
|
// Check Alices's DB for revealed accounts
|
||||||
// revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), common.PubkeyToHex(&s.alice.identity.PublicKey))
|
revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), common.PubkeyToHex(&s.alice.identity.PublicKey))
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(revealedAccountsInAlicesDB, 2)
|
s.Require().Len(revealedAccountsInAlicesDB, 2)
|
||||||
// s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress1)
|
s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress1)
|
||||||
// s.Require().Equal(revealedAccountsInAlicesDB[1].Address, aliceAddress2)
|
s.Require().Equal(revealedAccountsInAlicesDB[1].Address, aliceAddress2)
|
||||||
// s.Require().Equal(true, revealedAccountsInAlicesDB[0].IsAirdropAddress)
|
s.Require().Equal(true, revealedAccountsInAlicesDB[0].IsAirdropAddress)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersSelectedSharedAddress() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersSelectedSharedAddress() {
|
||||||
// community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
// s.advertiseCommunityTo(community, s.alice)
|
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())
|
community, err := s.owner.GetCommunityByID(community.ID())
|
||||||
// s.Require().NoError(err)
|
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
|
// Check owner's DB for revealed accounts
|
||||||
// revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(revealedAccounts, 1)
|
s.Require().Len(revealedAccounts, 1)
|
||||||
// s.Require().Equal(revealedAccounts[0].Address, aliceAddress2)
|
s.Require().Equal(revealedAccounts[0].Address, aliceAddress2)
|
||||||
// s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
|
s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
|
||||||
|
|
||||||
// // Check Alice's DB for revealed accounts
|
// Check Alice's DB for revealed accounts
|
||||||
// revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(revealedAccountsInAlicesDB, 1)
|
s.Require().Len(revealedAccountsInAlicesDB, 1)
|
||||||
// s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress2)
|
s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress2)
|
||||||
// s.Require().Equal(true, revealedAccountsInAlicesDB[0].IsAirdropAddress)
|
s.Require().Equal(true, revealedAccountsInAlicesDB[0].IsAirdropAddress)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersMultipleSelectedSharedAddresses() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinedCommunityMembersMultipleSelectedSharedAddresses() {
|
||||||
// community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
// s.advertiseCommunityTo(community, s.alice)
|
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())
|
community, err := s.owner.GetCommunityByID(community.ID())
|
||||||
// s.Require().NoError(err)
|
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
|
// Check owner's DB for revealed accounts
|
||||||
// revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(revealedAccounts, 2)
|
s.Require().Len(revealedAccounts, 2)
|
||||||
// s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
|
s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
|
||||||
// s.Require().Equal(revealedAccounts[1].Address, aliceAddress2)
|
s.Require().Equal(revealedAccounts[1].Address, aliceAddress2)
|
||||||
// s.Require().Equal(true, revealedAccounts[1].IsAirdropAddress)
|
s.Require().Equal(true, revealedAccounts[1].IsAirdropAddress)
|
||||||
|
|
||||||
// // Check Alice's DB for revealed accounts
|
// Check Alice's DB for revealed accounts
|
||||||
// revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
revealedAccountsInAlicesDB, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(revealedAccountsInAlicesDB, 2)
|
s.Require().Len(revealedAccountsInAlicesDB, 2)
|
||||||
// s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress1)
|
s.Require().Equal(revealedAccountsInAlicesDB[0].Address, aliceAddress1)
|
||||||
// s.Require().Equal(revealedAccountsInAlicesDB[1].Address, aliceAddress2)
|
s.Require().Equal(revealedAccountsInAlicesDB[1].Address, aliceAddress2)
|
||||||
// s.Require().Equal(true, revealedAccountsInAlicesDB[1].IsAirdropAddress)
|
s.Require().Equal(true, revealedAccountsInAlicesDB[1].IsAirdropAddress)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestEditSharedAddresses() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestEditSharedAddresses() {
|
||||||
// community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
// s.advertiseCommunityTo(community, s.alice)
|
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())
|
community, err := s.owner.GetCommunityByID(community.ID())
|
||||||
// s.Require().NoError(err)
|
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)
|
||||||
|
|
||||||
// revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
revealedAccounts, err := s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// s.Require().Len(revealedAccounts, 1)
|
s.Require().Len(revealedAccounts, 1)
|
||||||
// s.Require().Equal(revealedAccounts[0].Address, aliceAddress2)
|
s.Require().Equal(revealedAccounts[0].Address, aliceAddress2)
|
||||||
// s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
|
s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
|
||||||
|
|
||||||
// alicesRevealedAccounts, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
alicesRevealedAccounts, err := s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(alicesRevealedAccounts, 1)
|
s.Require().Len(alicesRevealedAccounts, 1)
|
||||||
// s.Require().Equal(alicesRevealedAccounts[0].Address, aliceAddress2)
|
s.Require().Equal(alicesRevealedAccounts[0].Address, aliceAddress2)
|
||||||
// s.Require().Equal(true, alicesRevealedAccounts[0].IsAirdropAddress)
|
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)
|
signingParams, err := s.alice.GenerateJoiningCommunityRequestsForSigning(common.PubkeyToHex(&s.alice.identity.PublicKey), community.ID(), request.AddressesToReveal)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// passwdHash := types.EncodeHex(crypto.Keccak256([]byte(alicePassword)))
|
passwdHash := types.EncodeHex(crypto.Keccak256([]byte(alicePassword)))
|
||||||
// for i := range signingParams {
|
for i := range signingParams {
|
||||||
// signingParams[i].Password = passwdHash
|
signingParams[i].Password = passwdHash
|
||||||
// }
|
}
|
||||||
// signatures, err := s.alice.SignData(signingParams)
|
signatures, err := s.alice.SignData(signingParams)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// updateAddresses := len(request.AddressesToReveal) == 0
|
updateAddresses := len(request.AddressesToReveal) == 0
|
||||||
// if updateAddresses {
|
if updateAddresses {
|
||||||
// request.AddressesToReveal = make([]string, len(signingParams))
|
request.AddressesToReveal = make([]string, len(signingParams))
|
||||||
// }
|
}
|
||||||
// for i := range signingParams {
|
for i := range signingParams {
|
||||||
// request.AddressesToReveal[i] = signingParams[i].Address
|
request.AddressesToReveal[i] = signingParams[i].Address
|
||||||
// request.Signatures = append(request.Signatures, types.FromHex(signatures[i]))
|
request.Signatures = append(request.Signatures, types.FromHex(signatures[i]))
|
||||||
// }
|
}
|
||||||
// if updateAddresses {
|
if updateAddresses {
|
||||||
// request.AirdropAddress = request.AddressesToReveal[0]
|
request.AirdropAddress = request.AddressesToReveal[0]
|
||||||
// }
|
}
|
||||||
|
|
||||||
// response, err := s.alice.EditSharedAddressesForCommunity(request)
|
response, err := s.alice.EditSharedAddressesForCommunity(request)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
|
|
||||||
// // Retrieve address change
|
// Retrieve address change
|
||||||
// err = tt.RetryWithBackOff(func() error {
|
err = tt.RetryWithBackOff(func() error {
|
||||||
// response, err := s.owner.RetrieveAll()
|
response, err := s.owner.RetrieveAll()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// return err
|
return err
|
||||||
// }
|
}
|
||||||
// if len(response.Communities()) == 0 {
|
if len(response.Communities()) == 0 {
|
||||||
// return errors.New("no communities in response (address change reception)")
|
return errors.New("no communities in response (address change reception)")
|
||||||
// }
|
}
|
||||||
// return nil
|
return nil
|
||||||
// })
|
})
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// revealedAccounts, err = s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
revealedAccounts, err = s.owner.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// s.Require().Len(revealedAccounts, 1)
|
s.Require().Len(revealedAccounts, 1)
|
||||||
// s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
|
s.Require().Equal(revealedAccounts[0].Address, aliceAddress1)
|
||||||
// s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
|
s.Require().Equal(true, revealedAccounts[0].IsAirdropAddress)
|
||||||
|
|
||||||
// // Retrieve community description change
|
// Retrieve community description change
|
||||||
// err = tt.RetryWithBackOff(func() error {
|
err = tt.RetryWithBackOff(func() error {
|
||||||
// response, err := s.alice.RetrieveAll()
|
response, err := s.alice.RetrieveAll()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// return err
|
return err
|
||||||
// }
|
}
|
||||||
// if len(response.Communities()) == 0 {
|
if len(response.Communities()) == 0 {
|
||||||
// return errors.New("no communities in response (address change reception)")
|
return errors.New("no communities in response (address change reception)")
|
||||||
// }
|
}
|
||||||
// return nil
|
return nil
|
||||||
// })
|
})
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// alicesRevealedAccounts, err = s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
alicesRevealedAccounts, err = s.alice.communitiesManager.GetRevealedAddresses(community.ID(), alicePubkey)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(alicesRevealedAccounts, 1)
|
s.Require().Len(alicesRevealedAccounts, 1)
|
||||||
// s.Require().Equal(alicesRevealedAccounts[0].Address, aliceAddress1)
|
s.Require().Equal(alicesRevealedAccounts[0].Address, aliceAddress1)
|
||||||
// s.Require().Equal(true, alicesRevealedAccounts[0].IsAirdropAddress)
|
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
|
// 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)
|
s.Require().NoError(err)
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityWithAdminPermission() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityWithAdminPermission() {
|
||||||
// community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
|
|
||||||
// // setup become admin permission
|
// setup become admin permission
|
||||||
// permissionRequest := requests.CreateCommunityTokenPermission{
|
permissionRequest := requests.CreateCommunityTokenPermission{
|
||||||
// CommunityID: community.ID(),
|
CommunityID: community.ID(),
|
||||||
// Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
|
Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
|
||||||
// TokenCriteria: []*protobuf.TokenCriteria{
|
TokenCriteria: []*protobuf.TokenCriteria{
|
||||||
// &protobuf.TokenCriteria{
|
&protobuf.TokenCriteria{
|
||||||
// Type: protobuf.CommunityTokenType_ERC20,
|
Type: protobuf.CommunityTokenType_ERC20,
|
||||||
// ContractAddresses: map[uint64]string{testChainID1: "0x123"},
|
ContractAddresses: map[uint64]string{testChainID1: "0x123"},
|
||||||
// Symbol: "TEST",
|
Symbol: "TEST",
|
||||||
// Amount: "100",
|
Amount: "100",
|
||||||
// Decimals: uint64(18),
|
Decimals: uint64(18),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
|
|
||||||
// response, err := s.owner.CreateCommunityTokenPermission(&permissionRequest)
|
response, err := s.owner.CreateCommunityTokenPermission(&permissionRequest)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(response.Communities(), 1)
|
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
|
// Bob should still be able to join even if there is a permission to be an admin
|
||||||
// s.joinCommunity(community, s.bob, bobPassword, []string{})
|
s.joinCommunity(community, s.bob, bobPassword, []string{})
|
||||||
|
|
||||||
// // Verify that we have Bob's revealed account
|
// Verify that we have Bob's revealed account
|
||||||
// revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
|
revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(revealedAccounts, 1)
|
s.Require().Len(revealedAccounts, 1)
|
||||||
// s.Require().Equal(bobAddress, revealedAccounts[0].Address)
|
s.Require().Equal(bobAddress, revealedAccounts[0].Address)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityAsMemberWithMemberAndAdminPermission() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityAsMemberWithMemberAndAdminPermission() {
|
||||||
// community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
|
|
||||||
// waitOnCommunityPermissionCreated := waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
|
waitOnCommunityPermissionCreated := waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
|
||||||
// return sub.Community.HasTokenPermissions()
|
return sub.Community.HasTokenPermissions()
|
||||||
// })
|
})
|
||||||
|
|
||||||
// // setup become member permission
|
// setup become member permission
|
||||||
// permissionRequestMember := requests.CreateCommunityTokenPermission{
|
permissionRequestMember := requests.CreateCommunityTokenPermission{
|
||||||
// CommunityID: community.ID(),
|
CommunityID: community.ID(),
|
||||||
// Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
|
Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
|
||||||
// TokenCriteria: []*protobuf.TokenCriteria{
|
TokenCriteria: []*protobuf.TokenCriteria{
|
||||||
// &protobuf.TokenCriteria{
|
&protobuf.TokenCriteria{
|
||||||
// Type: protobuf.CommunityTokenType_ERC20,
|
Type: protobuf.CommunityTokenType_ERC20,
|
||||||
// ContractAddresses: map[uint64]string{testChainID1: "0x123"},
|
ContractAddresses: map[uint64]string{testChainID1: "0x123"},
|
||||||
// Symbol: "TEST",
|
Symbol: "TEST",
|
||||||
// Amount: "100",
|
Amount: "100",
|
||||||
// Decimals: uint64(18),
|
Decimals: uint64(18),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
// response, err := s.owner.CreateCommunityTokenPermission(&permissionRequestMember)
|
response, err := s.owner.CreateCommunityTokenPermission(&permissionRequestMember)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
|
|
||||||
// err = <-waitOnCommunityPermissionCreated
|
err = <-waitOnCommunityPermissionCreated
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// // setup become admin permission
|
// setup become admin permission
|
||||||
// permissionRequestAdmin := requests.CreateCommunityTokenPermission{
|
permissionRequestAdmin := requests.CreateCommunityTokenPermission{
|
||||||
// CommunityID: community.ID(),
|
CommunityID: community.ID(),
|
||||||
// Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
|
Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
|
||||||
// TokenCriteria: []*protobuf.TokenCriteria{
|
TokenCriteria: []*protobuf.TokenCriteria{
|
||||||
// &protobuf.TokenCriteria{
|
&protobuf.TokenCriteria{
|
||||||
// Type: protobuf.CommunityTokenType_ERC20,
|
Type: protobuf.CommunityTokenType_ERC20,
|
||||||
// ContractAddresses: map[uint64]string{testChainID1: "0x124"},
|
ContractAddresses: map[uint64]string{testChainID1: "0x124"},
|
||||||
// Symbol: "TESTADMIN",
|
Symbol: "TESTADMIN",
|
||||||
// Amount: "100",
|
Amount: "100",
|
||||||
// Decimals: uint64(18),
|
Decimals: uint64(18),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
// response, err = s.owner.CreateCommunityTokenPermission(&permissionRequestAdmin)
|
response, err = s.owner.CreateCommunityTokenPermission(&permissionRequestAdmin)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
|
|
||||||
// waitOnCommunityPermissionCreated = waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
|
waitOnCommunityPermissionCreated = waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
|
||||||
// return len(sub.Community.TokenPermissions()) == 2
|
return len(sub.Community.TokenPermissions()) == 2
|
||||||
// })
|
})
|
||||||
|
|
||||||
// err = <-waitOnCommunityPermissionCreated
|
err = <-waitOnCommunityPermissionCreated
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// // make bob satisfy the member criteria
|
// make bob satisfy the member criteria
|
||||||
// s.makeAddressSatisfyTheCriteria(testChainID1, bobAddress, permissionRequestMember.TokenCriteria[0])
|
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
|
// Bob should still be able to join even though he doesn't satisfy the admin requirement
|
||||||
// // because he satisfies the member one
|
// because he satisfies the member one
|
||||||
// s.joinCommunity(community, s.bob, bobPassword, []string{})
|
s.joinCommunity(community, s.bob, bobPassword, []string{})
|
||||||
|
|
||||||
// // Verify that we have Bob's revealed account
|
// Verify that we have Bob's revealed account
|
||||||
// revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
|
revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(revealedAccounts, 1)
|
s.Require().Len(revealedAccounts, 1)
|
||||||
// s.Require().Equal(bobAddress, revealedAccounts[0].Address)
|
s.Require().Equal(bobAddress, revealedAccounts[0].Address)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityAsAdminWithMemberAndAdminPermission() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestJoinCommunityAsAdminWithMemberAndAdminPermission() {
|
||||||
// community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
|
|
||||||
// // setup become member permission
|
// setup become member permission
|
||||||
// permissionRequestMember := requests.CreateCommunityTokenPermission{
|
permissionRequestMember := requests.CreateCommunityTokenPermission{
|
||||||
// CommunityID: community.ID(),
|
CommunityID: community.ID(),
|
||||||
// Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
|
Type: protobuf.CommunityTokenPermission_BECOME_MEMBER,
|
||||||
// TokenCriteria: []*protobuf.TokenCriteria{
|
TokenCriteria: []*protobuf.TokenCriteria{
|
||||||
// &protobuf.TokenCriteria{
|
&protobuf.TokenCriteria{
|
||||||
// Type: protobuf.CommunityTokenType_ERC20,
|
Type: protobuf.CommunityTokenType_ERC20,
|
||||||
// ContractAddresses: map[uint64]string{testChainID1: "0x123"},
|
ContractAddresses: map[uint64]string{testChainID1: "0x123"},
|
||||||
// Symbol: "TEST",
|
Symbol: "TEST",
|
||||||
// Amount: "100",
|
Amount: "100",
|
||||||
// Decimals: uint64(18),
|
Decimals: uint64(18),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
// response, err := s.owner.CreateCommunityTokenPermission(&permissionRequestMember)
|
response, err := s.owner.CreateCommunityTokenPermission(&permissionRequestMember)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
|
|
||||||
// waitOnCommunityPermissionCreated := waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
|
waitOnCommunityPermissionCreated := waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
|
||||||
// return sub.Community.HasTokenPermissions()
|
return sub.Community.HasTokenPermissions()
|
||||||
// })
|
})
|
||||||
|
|
||||||
// err = <-waitOnCommunityPermissionCreated
|
err = <-waitOnCommunityPermissionCreated
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// // setup become admin permission
|
// setup become admin permission
|
||||||
// permissionRequestAdmin := requests.CreateCommunityTokenPermission{
|
permissionRequestAdmin := requests.CreateCommunityTokenPermission{
|
||||||
// CommunityID: community.ID(),
|
CommunityID: community.ID(),
|
||||||
// Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
|
Type: protobuf.CommunityTokenPermission_BECOME_ADMIN,
|
||||||
// TokenCriteria: []*protobuf.TokenCriteria{
|
TokenCriteria: []*protobuf.TokenCriteria{
|
||||||
// &protobuf.TokenCriteria{
|
&protobuf.TokenCriteria{
|
||||||
// Type: protobuf.CommunityTokenType_ERC20,
|
Type: protobuf.CommunityTokenType_ERC20,
|
||||||
// ContractAddresses: map[uint64]string{testChainID1: "0x124"},
|
ContractAddresses: map[uint64]string{testChainID1: "0x124"},
|
||||||
// Symbol: "TESTADMIN",
|
Symbol: "TESTADMIN",
|
||||||
// Amount: "100",
|
Amount: "100",
|
||||||
// Decimals: uint64(18),
|
Decimals: uint64(18),
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// }
|
}
|
||||||
// response, err = s.owner.CreateCommunityTokenPermission(&permissionRequestAdmin)
|
response, err = s.owner.CreateCommunityTokenPermission(&permissionRequestAdmin)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(response.Communities(), 1)
|
s.Require().Len(response.Communities(), 1)
|
||||||
// s.Require().Len(response.Communities()[0].TokenPermissionsByType(protobuf.CommunityTokenPermission_BECOME_ADMIN), 1)
|
s.Require().Len(response.Communities()[0].TokenPermissionsByType(protobuf.CommunityTokenPermission_BECOME_ADMIN), 1)
|
||||||
// s.Require().Len(response.Communities()[0].TokenPermissions(), 2)
|
s.Require().Len(response.Communities()[0].TokenPermissions(), 2)
|
||||||
|
|
||||||
// waitOnCommunityPermissionCreated = waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
|
waitOnCommunityPermissionCreated = waitOnCommunitiesEvent(s.owner, func(sub *communities.Subscription) bool {
|
||||||
// return len(sub.Community.TokenPermissions()) == 2
|
return len(sub.Community.TokenPermissions()) == 2
|
||||||
// })
|
})
|
||||||
|
|
||||||
// err = <-waitOnCommunityPermissionCreated
|
err = <-waitOnCommunityPermissionCreated
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// community, err = s.owner.communitiesManager.GetByID(community.ID())
|
community, err = s.owner.communitiesManager.GetByID(community.ID())
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(community.TokenPermissions(), 2)
|
s.Require().Len(community.TokenPermissions(), 2)
|
||||||
|
|
||||||
// s.advertiseCommunityTo(community, s.bob)
|
s.advertiseCommunityTo(community, s.bob)
|
||||||
|
|
||||||
// // make bob satisfy the admin criteria
|
// make bob satisfy the admin criteria
|
||||||
// s.makeAddressSatisfyTheCriteria(testChainID1, bobAddress, permissionRequestAdmin.TokenCriteria[0])
|
s.makeAddressSatisfyTheCriteria(testChainID1, bobAddress, permissionRequestAdmin.TokenCriteria[0])
|
||||||
|
|
||||||
// // Bob should still be able to join even though he doesn't satisfy the member requirement
|
// Bob should still be able to join even though he doesn't satisfy the member requirement
|
||||||
// // because he satisfies the admin one
|
// because he satisfies the admin one
|
||||||
// s.joinCommunity(community, s.bob, bobPassword, []string{})
|
s.joinCommunity(community, s.bob, bobPassword, []string{})
|
||||||
|
|
||||||
// // Verify that we have Bob's revealed account
|
// Verify that we have Bob's revealed account
|
||||||
// revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
|
revealedAccounts, err := s.owner.GetRevealedAccounts(community.ID(), common.PubkeyToHex(&s.bob.identity.PublicKey))
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(revealedAccounts, 1)
|
s.Require().Len(revealedAccounts, 1)
|
||||||
// s.Require().Equal(bobAddress, revealedAccounts[0].Address)
|
s.Require().Equal(bobAddress, revealedAccounts[0].Address)
|
||||||
// }
|
}
|
||||||
|
|
||||||
func (s *MessengerCommunitiesTokenPermissionsSuite) TestViewChannelPermissions() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestViewChannelPermissions() {
|
||||||
community, chat := s.createCommunity()
|
community, chat := s.createCommunity()
|
||||||
|
@ -1228,7 +1228,6 @@ func (s *MessengerCommunitiesTokenPermissionsSuite) TestReevaluateMemberTokenMas
|
||||||
s.testReevaluateMemberPrivilegedRoleInOpenCommunity(protobuf.CommunityTokenPermission_BECOME_TOKEN_MASTER)
|
s.testReevaluateMemberPrivilegedRoleInOpenCommunity(protobuf.CommunityTokenPermission_BECOME_TOKEN_MASTER)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func (s *MessengerCommunitiesTokenPermissionsSuite) testReevaluateMemberPrivilegedRoleInClosedCommunity(permissionType protobuf.CommunityTokenPermission_Type) {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) testReevaluateMemberPrivilegedRoleInClosedCommunity(permissionType protobuf.CommunityTokenPermission_Type) {
|
||||||
community, _ := s.createCommunity()
|
community, _ := s.createCommunity()
|
||||||
|
|
||||||
|
@ -1361,12 +1360,11 @@ func (s *MessengerCommunitiesTokenPermissionsSuite) testReevaluateMemberPrivileg
|
||||||
|
|
||||||
s.Require().False(checkRoleBasedOnThePermissionType(permissionType, &s.alice.identity.PublicKey, community))
|
s.Require().False(checkRoleBasedOnThePermissionType(permissionType, &s.alice.identity.PublicKey, community))
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/*
|
|
||||||
func (s *MessengerCommunitiesTokenPermissionsSuite) TestReevaluateMemberAdminRoleInClosedCommunity() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestReevaluateMemberAdminRoleInClosedCommunity() {
|
||||||
s.testReevaluateMemberPrivilegedRoleInClosedCommunity(protobuf.CommunityTokenPermission_BECOME_ADMIN)
|
s.testReevaluateMemberPrivilegedRoleInClosedCommunity(protobuf.CommunityTokenPermission_BECOME_ADMIN)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/*
|
/*
|
||||||
func (s *MessengerCommunitiesTokenPermissionsSuite) TestReevaluateMemberTokenMasterRoleInClosedCommunity() {
|
func (s *MessengerCommunitiesTokenPermissionsSuite) TestReevaluateMemberTokenMasterRoleInClosedCommunity() {
|
||||||
s.testReevaluateMemberPrivilegedRoleInClosedCommunity(protobuf.CommunityTokenPermission_BECOME_TOKEN_MASTER)
|
s.testReevaluateMemberPrivilegedRoleInClosedCommunity(protobuf.CommunityTokenPermission_BECOME_TOKEN_MASTER)
|
||||||
|
|
|
@ -2,17 +2,16 @@ package protocol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
// "crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
// "github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
|
||||||
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth"
|
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/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/common/shard"
|
||||||
"github.com/status-im/status-go/protocol/communities"
|
"github.com/status-im/status-go/protocol/communities"
|
||||||
"github.com/status-im/status-go/protocol/protobuf"
|
"github.com/status-im/status-go/protocol/protobuf"
|
||||||
|
@ -147,7 +146,6 @@ func (s *MessengerCommunitiesShardingSuite) TestPostToCommunityChat() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func (s *MessengerCommunitiesShardingSuite) TestIgnoreOutdatedShardKey() {
|
func (s *MessengerCommunitiesShardingSuite) TestIgnoreOutdatedShardKey() {
|
||||||
community, _ := createCommunity(&s.Suite, s.owner)
|
community, _ := createCommunity(&s.Suite, s.owner)
|
||||||
|
|
||||||
|
@ -222,4 +220,3 @@ func (s *MessengerCommunitiesShardingSuite) TestIgnoreOutdatedShardKey() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,8 @@
|
||||||
package protocol
|
package protocol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
//"context"
|
"context"
|
||||||
//"errors"
|
"errors"
|
||||||
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -12,12 +11,10 @@ import (
|
||||||
|
|
||||||
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth"
|
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/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/communities"
|
||||||
//"github.com/status-im/status-go/protocol/communities"
|
"github.com/status-im/status-go/protocol/protobuf"
|
||||||
// "github.com/status-im/status-go/protocol/protobuf"
|
"github.com/status-im/status-go/protocol/requests"
|
||||||
//"github.com/status-im/status-go/protocol/requests"
|
|
||||||
|
|
||||||
"github.com/status-im/status-go/protocol/tt"
|
"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) {
|
func (s *MessengerOfflineSuite) advertiseCommunityTo(community *communities.Community, owner *Messenger, user *Messenger) {
|
||||||
// advertiseCommunityTo(&s.Suite, community, owner, user)
|
advertiseCommunityTo(&s.Suite, community, owner, user)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (s *MessengerOfflineSuite) joinCommunity(community *communities.Community, owner *Messenger, user *Messenger) {
|
func (s *MessengerOfflineSuite) joinCommunity(community *communities.Community, owner *Messenger, user *Messenger) {
|
||||||
// request := &requests.RequestToJoinCommunity{CommunityID: community.ID()}
|
request := &requests.RequestToJoinCommunity{CommunityID: community.ID()}
|
||||||
// joinCommunity(&s.Suite, community, owner, user, request, "")
|
joinCommunity(&s.Suite, community, owner, user, request, "")
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (s *MessengerOfflineSuite) TestCommunityOfflineEdit() {
|
func (s *MessengerOfflineSuite) TestCommunityOfflineEdit() {
|
||||||
// community, chat := createCommunity(&s.Suite, s.owner)
|
community, chat := createCommunity(&s.Suite, s.owner)
|
||||||
|
|
||||||
// chatID := chat.ID
|
chatID := chat.ID
|
||||||
// inputMessage := common.NewMessage()
|
inputMessage := common.NewMessage()
|
||||||
// inputMessage.ChatId = chatID
|
inputMessage.ChatId = chatID
|
||||||
// inputMessage.ContentType = protobuf.ChatMessage_TEXT_PLAIN
|
inputMessage.ContentType = protobuf.ChatMessage_TEXT_PLAIN
|
||||||
// inputMessage.Text = "some text"
|
inputMessage.Text = "some text"
|
||||||
|
|
||||||
// ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// s.advertiseCommunityTo(community, s.owner, s.alice)
|
s.advertiseCommunityTo(community, s.owner, s.alice)
|
||||||
// s.joinCommunity(community, s.owner, s.alice)
|
s.joinCommunity(community, s.owner, s.alice)
|
||||||
|
|
||||||
// _, err := s.alice.SendChatMessage(ctx, inputMessage)
|
_, err := s.alice.SendChatMessage(ctx, inputMessage)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.checkMessageDelivery(ctx, inputMessage)
|
s.checkMessageDelivery(ctx, inputMessage)
|
||||||
|
|
||||||
// // Simulate going offline
|
// Simulate going offline
|
||||||
// wakuv2 := gethbridge.GetGethWakuV2From(s.aliceWaku)
|
wakuv2 := gethbridge.GetGethWakuV2From(s.aliceWaku)
|
||||||
// wakuv2.SkipPublishToTopic(true)
|
wakuv2.SkipPublishToTopic(true)
|
||||||
|
|
||||||
// resp, err := s.alice.SendChatMessage(ctx, inputMessage)
|
resp, err := s.alice.SendChatMessage(ctx, inputMessage)
|
||||||
// messageID := types.Hex2Bytes(resp.Messages()[0].ID)
|
messageID := types.Hex2Bytes(resp.Messages()[0].ID)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// // Check that message is re-sent once back online
|
// Check that message is re-sent once back online
|
||||||
// wakuv2.SkipPublishToTopic(false)
|
wakuv2.SkipPublishToTopic(false)
|
||||||
// time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
|
|
||||||
// s.checkMessageDelivery(ctx, inputMessage)
|
s.checkMessageDelivery(ctx, inputMessage)
|
||||||
|
|
||||||
// editedText := "some text edited"
|
editedText := "some text edited"
|
||||||
// editedMessage := &requests.EditMessage{
|
editedMessage := &requests.EditMessage{
|
||||||
// ID: messageID,
|
ID: messageID,
|
||||||
// Text: editedText,
|
Text: editedText,
|
||||||
// }
|
}
|
||||||
|
|
||||||
// wakuv2.SkipPublishToTopic(true)
|
wakuv2.SkipPublishToTopic(true)
|
||||||
// sendResponse, err := s.alice.EditMessage(ctx, editedMessage)
|
sendResponse, err := s.alice.EditMessage(ctx, editedMessage)
|
||||||
// s.Require().NotNil(sendResponse)
|
s.Require().NotNil(sendResponse)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// // Check that message is re-sent once back online
|
// Check that message is re-sent once back online
|
||||||
// wakuv2.SkipPublishToTopic(false)
|
wakuv2.SkipPublishToTopic(false)
|
||||||
// time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
// inputMessage.Text = editedText
|
inputMessage.Text = editedText
|
||||||
|
|
||||||
// s.checkMessageDelivery(ctx, inputMessage)
|
s.checkMessageDelivery(ctx, inputMessage)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func (s *MessengerOfflineSuite) checkMessageDelivery(ctx context.Context, inputMessage *common.Message) {
|
func (s *MessengerOfflineSuite) checkMessageDelivery(ctx context.Context, inputMessage *common.Message) {
|
||||||
// var response *MessengerResponse
|
var response *MessengerResponse
|
||||||
// // Pull message and make sure org is received
|
// Pull message and make sure org is received
|
||||||
// err := tt.RetryWithBackOff(func() error {
|
err := tt.RetryWithBackOff(func() error {
|
||||||
// var err error
|
var err error
|
||||||
// response, err = s.owner.RetrieveAll()
|
response, err = s.owner.RetrieveAll()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// return err
|
return err
|
||||||
// }
|
}
|
||||||
// if len(response.messages) == 0 {
|
if len(response.messages) == 0 {
|
||||||
// return errors.New("message not received")
|
return errors.New("message not received")
|
||||||
// }
|
}
|
||||||
// return nil
|
return nil
|
||||||
// })
|
})
|
||||||
|
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(response.Messages(), 1)
|
s.Require().Len(response.Messages(), 1)
|
||||||
// s.Require().Equal(inputMessage.Text, response.Messages()[0].Text)
|
s.Require().Equal(inputMessage.Text, response.Messages()[0].Text)
|
||||||
|
|
||||||
// // check if response contains the chat we're interested in
|
// check if response contains the chat we're interested in
|
||||||
// // we use this instead of checking just the length of the chat because
|
// 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
|
// a CommunityDescription message might be received in the meantime due to syncing
|
||||||
// // hence response.Chats() might contain the general chat, and the new chat;
|
// hence response.Chats() might contain the general chat, and the new chat;
|
||||||
// // or only the new chat if the CommunityDescription message has not arrived
|
// or only the new chat if the CommunityDescription message has not arrived
|
||||||
// found := false
|
found := false
|
||||||
// for _, chat := range response.Chats() {
|
for _, chat := range response.Chats() {
|
||||||
// if chat.ID == inputMessage.ChatId {
|
if chat.ID == inputMessage.ChatId {
|
||||||
// found = true
|
found = true
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// s.Require().True(found)
|
s.Require().True(found)
|
||||||
// }
|
}
|
||||||
|
|
|
@ -71,46 +71,46 @@ func (s *TestMessengerProfileShowcase) mutualContact(theirMessenger *Messenger)
|
||||||
s.Require().True(resp.Contacts[0].mutual())
|
s.Require().True(resp.Contacts[0].mutual())
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (s *TestMessengerProfileShowcase) verifiedContact(theirMessenger *Messenger) {
|
func (s *TestMessengerProfileShowcase) verifiedContact(theirMessenger *Messenger) {
|
||||||
// theirPk := types.EncodeHex(crypto.FromECDSAPub(&theirMessenger.identity.PublicKey))
|
theirPk := types.EncodeHex(crypto.FromECDSAPub(&theirMessenger.identity.PublicKey))
|
||||||
// challenge := "Want to see what I'm hiding in my profile showcase?"
|
challenge := "Want to see what I'm hiding in my profile showcase?"
|
||||||
|
|
||||||
// _, err := s.m.SendContactVerificationRequest(context.Background(), theirPk, challenge)
|
_, err := s.m.SendContactVerificationRequest(context.Background(), theirPk, challenge)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// // Wait for the message to reach its destination
|
// Wait for the message to reach its destination
|
||||||
// resp, err := WaitOnMessengerResponse(
|
resp, err := WaitOnMessengerResponse(
|
||||||
// theirMessenger,
|
theirMessenger,
|
||||||
// func(r *MessengerResponse) bool {
|
func(r *MessengerResponse) bool {
|
||||||
// return len(r.VerificationRequests()) == 1 && len(r.ActivityCenterNotifications()) == 1
|
return len(r.VerificationRequests()) == 1 && len(r.ActivityCenterNotifications()) == 1
|
||||||
// },
|
},
|
||||||
// "no messages",
|
"no messages",
|
||||||
// )
|
)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(resp.VerificationRequests(), 1)
|
s.Require().Len(resp.VerificationRequests(), 1)
|
||||||
// verificationRequestID := resp.VerificationRequests()[0].ID
|
verificationRequestID := resp.VerificationRequests()[0].ID
|
||||||
|
|
||||||
// _, err = theirMessenger.AcceptContactVerificationRequest(context.Background(), verificationRequestID, "For sure!")
|
_, err = theirMessenger.AcceptContactVerificationRequest(context.Background(), verificationRequestID, "For sure!")
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// // Wait for the message to reach its destination
|
// Wait for the message to reach its destination
|
||||||
// _, err = WaitOnMessengerResponse(
|
_, err = WaitOnMessengerResponse(
|
||||||
// s.m,
|
s.m,
|
||||||
// func(r *MessengerResponse) bool {
|
func(r *MessengerResponse) bool {
|
||||||
// return len(r.VerificationRequests()) == 1
|
return len(r.VerificationRequests()) == 1
|
||||||
// },
|
},
|
||||||
// "no messages",
|
"no messages",
|
||||||
// )
|
)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// resp, err = s.m.VerifiedTrusted(context.Background(), &requests.VerifiedTrusted{ID: types.FromHex(verificationRequestID)})
|
resp, err = s.m.VerifiedTrusted(context.Background(), &requests.VerifiedTrusted{ID: types.FromHex(verificationRequestID)})
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// s.Require().Len(resp.Messages(), 1)
|
s.Require().Len(resp.Messages(), 1)
|
||||||
// s.Require().Equal(common.ContactVerificationStateTrusted, resp.Messages()[0].ContactVerificationState)
|
s.Require().Equal(common.ContactVerificationStateTrusted, resp.Messages()[0].ContactVerificationState)
|
||||||
// }
|
}
|
||||||
|
|
||||||
func (s *TestMessengerProfileShowcase) TestSaveAndGetProfileShowcasePreferences() {
|
func (s *TestMessengerProfileShowcase) TestSaveAndGetProfileShowcasePreferences() {
|
||||||
request := DummyProfileShowcasePreferences()
|
request := DummyProfileShowcasePreferences()
|
||||||
|
@ -287,134 +287,134 @@ func (s *TestMessengerProfileShowcase) TestEncryptAndDecryptProfileShowcaseEntri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (s *TestMessengerProfileShowcase) TestShareShowcasePreferences() {
|
func (s *TestMessengerProfileShowcase) TestShareShowcasePreferences() {
|
||||||
// // Set Display name to pass shouldPublishChatIdentity check
|
// Set Display name to pass shouldPublishChatIdentity check
|
||||||
// profileKp := accounts.GetProfileKeypairForTest(true, false, false)
|
profileKp := accounts.GetProfileKeypairForTest(true, false, false)
|
||||||
// profileKp.KeyUID = s.m.account.KeyUID
|
profileKp.KeyUID = s.m.account.KeyUID
|
||||||
// profileKp.Accounts[0].KeyUID = s.m.account.KeyUID
|
profileKp.Accounts[0].KeyUID = s.m.account.KeyUID
|
||||||
|
|
||||||
// err := s.m.settings.SaveOrUpdateKeypair(profileKp)
|
err := s.m.settings.SaveOrUpdateKeypair(profileKp)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// err = s.m.SetDisplayName("bobby")
|
err = s.m.SetDisplayName("bobby")
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// // Add mutual contact
|
// Add mutual contact
|
||||||
// mutualContact := s.newMessenger()
|
mutualContact := s.newMessenger()
|
||||||
// _, err = mutualContact.Start()
|
_, err = mutualContact.Start()
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// defer TearDownMessenger(&s.Suite, mutualContact)
|
defer TearDownMessenger(&s.Suite, mutualContact)
|
||||||
|
|
||||||
// s.mutualContact(mutualContact)
|
s.mutualContact(mutualContact)
|
||||||
|
|
||||||
// // Add identity verified contact
|
// Add identity verified contact
|
||||||
// verifiedContact := s.newMessenger()
|
verifiedContact := s.newMessenger()
|
||||||
// _, err = verifiedContact.Start()
|
_, err = verifiedContact.Start()
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// defer TearDownMessenger(&s.Suite, verifiedContact)
|
defer TearDownMessenger(&s.Suite, verifiedContact)
|
||||||
|
|
||||||
// s.mutualContact(verifiedContact)
|
s.mutualContact(verifiedContact)
|
||||||
// s.verifiedContact(verifiedContact)
|
s.verifiedContact(verifiedContact)
|
||||||
|
|
||||||
// // Save preferences to dispatch changes
|
// Save preferences to dispatch changes
|
||||||
// request := DummyProfileShowcasePreferences()
|
request := DummyProfileShowcasePreferences()
|
||||||
// err = s.m.SetProfileShowcasePreferences(request, false)
|
err = s.m.SetProfileShowcasePreferences(request, false)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// contactID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey))
|
contactID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey))
|
||||||
// // Get summarised profile data for mutual contact
|
// Get summarised profile data for mutual contact
|
||||||
// resp, err := WaitOnMessengerResponse(
|
resp, err := WaitOnMessengerResponse(
|
||||||
// mutualContact,
|
mutualContact,
|
||||||
// func(r *MessengerResponse) bool {
|
func(r *MessengerResponse) bool {
|
||||||
// return len(r.updatedProfileShowcases) > 0 && r.updatedProfileShowcases[contactID] != nil
|
return len(r.updatedProfileShowcases) > 0 && r.updatedProfileShowcases[contactID] != nil
|
||||||
// },
|
},
|
||||||
// "no messages",
|
"no messages",
|
||||||
// )
|
)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(resp.updatedProfileShowcases, 1)
|
s.Require().Len(resp.updatedProfileShowcases, 1)
|
||||||
|
|
||||||
// profileShowcase := resp.updatedProfileShowcases[contactID]
|
profileShowcase := resp.updatedProfileShowcases[contactID]
|
||||||
|
|
||||||
// s.Require().Len(profileShowcase.Accounts, 2)
|
s.Require().Len(profileShowcase.Accounts, 2)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[0].Address, request.Accounts[0].Address)
|
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].Name, request.Accounts[0].Name)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[0].ColorID, request.Accounts[0].ColorID)
|
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].Emoji, request.Accounts[0].Emoji)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[0].Order, request.Accounts[0].Order)
|
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].Address, request.Accounts[1].Address)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[1].Name, request.Accounts[1].Name)
|
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].ColorID, request.Accounts[1].ColorID)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[1].Emoji, request.Accounts[1].Emoji)
|
s.Require().Equal(profileShowcase.Accounts[1].Emoji, request.Accounts[1].Emoji)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[1].Order, request.Accounts[1].Order)
|
s.Require().Equal(profileShowcase.Accounts[1].Order, request.Accounts[1].Order)
|
||||||
|
|
||||||
// s.Require().Len(profileShowcase.Collectibles, 1)
|
s.Require().Len(profileShowcase.Collectibles, 1)
|
||||||
// s.Require().Equal(profileShowcase.Collectibles[0].TokenID, request.Collectibles[0].TokenID)
|
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].ChainID, request.Collectibles[0].ChainID)
|
||||||
// s.Require().Equal(profileShowcase.Collectibles[0].ContractAddress, request.Collectibles[0].ContractAddress)
|
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].AccountAddress, request.Collectibles[0].AccountAddress)
|
||||||
// s.Require().Equal(profileShowcase.Collectibles[0].CommunityID, request.Collectibles[0].CommunityID)
|
s.Require().Equal(profileShowcase.Collectibles[0].CommunityID, request.Collectibles[0].CommunityID)
|
||||||
// s.Require().Equal(profileShowcase.Collectibles[0].Order, request.Collectibles[0].Order)
|
s.Require().Equal(profileShowcase.Collectibles[0].Order, request.Collectibles[0].Order)
|
||||||
|
|
||||||
// s.Require().Len(profileShowcase.VerifiedTokens, 1)
|
s.Require().Len(profileShowcase.VerifiedTokens, 1)
|
||||||
// s.Require().Equal(profileShowcase.VerifiedTokens[0].Symbol, request.VerifiedTokens[0].Symbol)
|
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[0].Order, request.VerifiedTokens[0].Order)
|
||||||
|
|
||||||
// s.Require().Len(profileShowcase.UnverifiedTokens, 2)
|
s.Require().Len(profileShowcase.UnverifiedTokens, 2)
|
||||||
// s.Require().Equal(profileShowcase.UnverifiedTokens[0].ContractAddress, request.UnverifiedTokens[0].ContractAddress)
|
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].ChainID, request.UnverifiedTokens[0].ChainID)
|
||||||
// s.Require().Equal(profileShowcase.UnverifiedTokens[0].Order, request.UnverifiedTokens[0].Order)
|
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].ContractAddress, request.UnverifiedTokens[1].ContractAddress)
|
||||||
// s.Require().Equal(profileShowcase.UnverifiedTokens[1].ChainID, request.UnverifiedTokens[1].ChainID)
|
s.Require().Equal(profileShowcase.UnverifiedTokens[1].ChainID, request.UnverifiedTokens[1].ChainID)
|
||||||
// s.Require().Equal(profileShowcase.UnverifiedTokens[1].Order, request.UnverifiedTokens[1].Order)
|
s.Require().Equal(profileShowcase.UnverifiedTokens[1].Order, request.UnverifiedTokens[1].Order)
|
||||||
|
|
||||||
// // Get summarised profile data for verified contact
|
// Get summarised profile data for verified contact
|
||||||
// resp, err = WaitOnMessengerResponse(
|
resp, err = WaitOnMessengerResponse(
|
||||||
// verifiedContact,
|
verifiedContact,
|
||||||
// func(r *MessengerResponse) bool {
|
func(r *MessengerResponse) bool {
|
||||||
// return len(r.updatedProfileShowcases) > 0
|
return len(r.updatedProfileShowcases) > 0
|
||||||
// },
|
},
|
||||||
// "no messages",
|
"no messages",
|
||||||
// )
|
)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
// s.Require().Len(resp.updatedProfileShowcases, 1)
|
s.Require().Len(resp.updatedProfileShowcases, 1)
|
||||||
|
|
||||||
// // Here let's try synchronous
|
// Here let's try synchronous
|
||||||
// profileShowcase, err = verifiedContact.GetProfileShowcaseForContact(contactID)
|
profileShowcase, err = verifiedContact.GetProfileShowcaseForContact(contactID)
|
||||||
// s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// s.Require().Len(profileShowcase.Accounts, 2)
|
s.Require().Len(profileShowcase.Accounts, 2)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[0].Address, request.Accounts[0].Address)
|
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].Name, request.Accounts[0].Name)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[0].ColorID, request.Accounts[0].ColorID)
|
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].Emoji, request.Accounts[0].Emoji)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[0].Order, request.Accounts[0].Order)
|
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].Address, request.Accounts[1].Address)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[1].Name, request.Accounts[1].Name)
|
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].ColorID, request.Accounts[1].ColorID)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[1].Emoji, request.Accounts[1].Emoji)
|
s.Require().Equal(profileShowcase.Accounts[1].Emoji, request.Accounts[1].Emoji)
|
||||||
// s.Require().Equal(profileShowcase.Accounts[1].Order, request.Accounts[1].Order)
|
s.Require().Equal(profileShowcase.Accounts[1].Order, request.Accounts[1].Order)
|
||||||
|
|
||||||
// s.Require().Len(profileShowcase.Collectibles, 1)
|
s.Require().Len(profileShowcase.Collectibles, 1)
|
||||||
// s.Require().Equal(profileShowcase.Collectibles[0].ContractAddress, request.Collectibles[0].ContractAddress)
|
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].ChainID, request.Collectibles[0].ChainID)
|
||||||
// s.Require().Equal(profileShowcase.Collectibles[0].TokenID, request.Collectibles[0].TokenID)
|
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].CommunityID, request.Collectibles[0].CommunityID)
|
||||||
// s.Require().Equal(profileShowcase.Collectibles[0].Order, request.Collectibles[0].Order)
|
s.Require().Equal(profileShowcase.Collectibles[0].Order, request.Collectibles[0].Order)
|
||||||
|
|
||||||
// s.Require().Len(profileShowcase.VerifiedTokens, 2)
|
s.Require().Len(profileShowcase.VerifiedTokens, 2)
|
||||||
// s.Require().Equal(profileShowcase.VerifiedTokens[0].Symbol, request.VerifiedTokens[0].Symbol)
|
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[0].Order, request.VerifiedTokens[0].Order)
|
||||||
// s.Require().Equal(profileShowcase.VerifiedTokens[1].Symbol, request.VerifiedTokens[1].Symbol)
|
s.Require().Equal(profileShowcase.VerifiedTokens[1].Symbol, request.VerifiedTokens[1].Symbol)
|
||||||
// s.Require().Equal(profileShowcase.VerifiedTokens[1].Order, request.VerifiedTokens[1].Order)
|
s.Require().Equal(profileShowcase.VerifiedTokens[1].Order, request.VerifiedTokens[1].Order)
|
||||||
|
|
||||||
// s.Require().Len(profileShowcase.UnverifiedTokens, 2)
|
s.Require().Len(profileShowcase.UnverifiedTokens, 2)
|
||||||
// s.Require().Equal(profileShowcase.UnverifiedTokens[0].ContractAddress, request.UnverifiedTokens[0].ContractAddress)
|
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].ChainID, request.UnverifiedTokens[0].ChainID)
|
||||||
// s.Require().Equal(profileShowcase.UnverifiedTokens[0].Order, request.UnverifiedTokens[0].Order)
|
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].ContractAddress, request.UnverifiedTokens[1].ContractAddress)
|
||||||
// s.Require().Equal(profileShowcase.UnverifiedTokens[1].ChainID, request.UnverifiedTokens[1].ChainID)
|
s.Require().Equal(profileShowcase.UnverifiedTokens[1].ChainID, request.UnverifiedTokens[1].ChainID)
|
||||||
// s.Require().Equal(profileShowcase.UnverifiedTokens[1].Order, request.UnverifiedTokens[1].Order)
|
s.Require().Equal(profileShowcase.UnverifiedTokens[1].Order, request.UnverifiedTokens[1].Order)
|
||||||
// }
|
}
|
||||||
|
|
||||||
func (s *TestMessengerProfileShowcase) TestProfileShowcaseProofOfMembershipUnencryptedCommunities() {
|
func (s *TestMessengerProfileShowcase) TestProfileShowcaseProofOfMembershipUnencryptedCommunities() {
|
||||||
alice := s.m
|
alice := s.m
|
||||||
|
|
|
@ -3,9 +3,7 @@ package pairing
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
//"errors"
|
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -19,9 +17,7 @@ import (
|
||||||
"github.com/status-im/status-go/common/dbsetup"
|
"github.com/status-im/status-go/common/dbsetup"
|
||||||
"github.com/status-im/status-go/eth-node/crypto"
|
"github.com/status-im/status-go/eth-node/crypto"
|
||||||
"github.com/status-im/status-go/protocol"
|
"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/status-im/status-go/protocol/tt"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
@ -45,22 +41,22 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
pathWalletRoot = "m/44'/60'/0'/0"
|
pathWalletRoot = "m/44'/60'/0'/0"
|
||||||
pathEIP1581 = "m/43'/60'/1581'"
|
pathEIP1581 = "m/43'/60'/1581'"
|
||||||
pathDefaultChat = pathEIP1581 + "/0'/0"
|
pathDefaultChat = pathEIP1581 + "/0'/0"
|
||||||
pathDefaultWallet = pathWalletRoot + "/0"
|
pathDefaultWallet = pathWalletRoot + "/0"
|
||||||
currentNetwork = "mainnet_rpc"
|
currentNetwork = "mainnet_rpc"
|
||||||
socialLinkURL = "https://github.com/status-im"
|
socialLinkURL = "https://github.com/status-im"
|
||||||
ensUsername = "bob.stateofus.eth"
|
ensUsername = "bob.stateofus.eth"
|
||||||
ensChainID = 1
|
ensChainID = 1
|
||||||
publicChatID = "localpairtest"
|
publicChatID = "localpairtest"
|
||||||
profileKeypairMnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon"
|
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"
|
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"
|
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"
|
seedKeypairMnemonic1 = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about abandon"
|
||||||
path0 = "m/44'/60'/0'/0/0"
|
path0 = "m/44'/60'/0'/0/0"
|
||||||
path1 = "m/44'/60'/0'/0/1"
|
path1 = "m/44'/60'/0'/0/1"
|
||||||
expectedKDFIterations = 1024
|
expectedKDFIterations = 1024
|
||||||
)
|
)
|
||||||
|
|
||||||
var paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWallet}
|
var paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWallet}
|
||||||
|
@ -883,304 +879,303 @@ func (s *SyncDeviceSuite) TestTransferringKeystoreFiles() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
func (s *SyncDeviceSuite) TestTransferringKeystoreFilesAfterStopUisngKeycard() {
|
||||||
func (s *SyncDeviceSuite) TestTransferringKeystoreFilesAfterStopUisngKeycard() {
|
ctx := context.TODO()
|
||||||
ctx := context.TODO()
|
|
||||||
|
|
||||||
// Prepare server
|
// Prepare server
|
||||||
serverTmpDir := filepath.Join(s.clientAsReceiverTmpdir, "server")
|
serverTmpDir := filepath.Join(s.clientAsReceiverTmpdir, "server")
|
||||||
serverBackend := s.prepareBackendWithAccount(profileKeypairMnemonic1, serverTmpDir)
|
serverBackend := s.prepareBackendWithAccount(profileKeypairMnemonic1, serverTmpDir)
|
||||||
serverMessenger := serverBackend.Messenger()
|
serverMessenger := serverBackend.Messenger()
|
||||||
serverAccountsAPI := serverBackend.StatusNode().AccountService().APIs()[1].Service.(*accservice.API)
|
serverAccountsAPI := serverBackend.StatusNode().AccountService().APIs()[1].Service.(*accservice.API)
|
||||||
|
|
||||||
// Prepare client
|
// Prepare client
|
||||||
clientTmpDir := filepath.Join(s.clientAsReceiverTmpdir, "client")
|
clientTmpDir := filepath.Join(s.clientAsReceiverTmpdir, "client")
|
||||||
clientBackend := s.prepareBackendWithAccount(profileKeypairMnemonic1, clientTmpDir)
|
clientBackend := s.prepareBackendWithAccount(profileKeypairMnemonic1, clientTmpDir)
|
||||||
clientMessenger := clientBackend.Messenger()
|
clientMessenger := clientBackend.Messenger()
|
||||||
clientAccountsAPI := clientBackend.StatusNode().AccountService().APIs()[1].Service.(*accservice.API)
|
clientAccountsAPI := clientBackend.StatusNode().AccountService().APIs()[1].Service.(*accservice.API)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
require.NoError(s.T(), clientBackend.Logout())
|
require.NoError(s.T(), clientBackend.Logout())
|
||||||
require.NoError(s.T(), serverBackend.Logout())
|
require.NoError(s.T(), serverBackend.Logout())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Pair server and client
|
// Pair server and client
|
||||||
im1 := &multidevice.InstallationMetadata{
|
im1 := &multidevice.InstallationMetadata{
|
||||||
Name: "client-device",
|
Name: "client-device",
|
||||||
DeviceType: "client-device-type",
|
DeviceType: "client-device-type",
|
||||||
}
|
}
|
||||||
settings, err := clientBackend.GetSettings()
|
settings, err := clientBackend.GetSettings()
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
err = clientMessenger.SetInstallationMetadata(settings.InstallationID, im1)
|
err = clientMessenger.SetInstallationMetadata(settings.InstallationID, im1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := clientMessenger.SendPairInstallation(context.Background(), nil)
|
response, err := clientMessenger.SendPairInstallation(context.Background(), nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
s.Require().False(response.Chats()[0].Active)
|
s.Require().False(response.Chats()[0].Active)
|
||||||
|
|
||||||
response, err = protocol.WaitOnMessengerResponse(
|
response, err = protocol.WaitOnMessengerResponse(
|
||||||
serverMessenger,
|
serverMessenger,
|
||||||
func(r *protocol.MessengerResponse) bool {
|
func(r *protocol.MessengerResponse) bool {
|
||||||
for _, i := range r.Installations {
|
for _, i := range r.Installations {
|
||||||
if i.ID == settings.InstallationID {
|
if i.ID == settings.InstallationID {
|
||||||
return true
|
return true
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
"installation not received",
|
|
||||||
)
|
|
||||||
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
found := false
|
|
||||||
for _, i := range response.Installations {
|
|
||||||
found = i.ID == settings.InstallationID &&
|
|
||||||
i.InstallationMetadata != nil &&
|
|
||||||
i.InstallationMetadata.Name == im1.Name &&
|
|
||||||
i.InstallationMetadata.DeviceType == im1.DeviceType
|
|
||||||
if found {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.Require().True(found)
|
|
||||||
|
|
||||||
err = serverMessenger.EnableInstallation(settings.InstallationID)
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
// Check if the logged in account is the same on server and client
|
|
||||||
serverActiveAccount, err := serverBackend.GetActiveAccount()
|
|
||||||
require.NoError(s.T(), err)
|
|
||||||
clientActiveAccount, err := clientBackend.GetActiveAccount()
|
|
||||||
require.NoError(s.T(), err)
|
|
||||||
require.True(s.T(), serverActiveAccount.KeyUID == clientActiveAccount.KeyUID)
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// From this point this test is trying to simulate the following scenario:
|
|
||||||
// - add a new seed phrase keypair on server
|
|
||||||
// - sync it to client
|
|
||||||
// - convert it to a keycard keypair on server
|
|
||||||
// - sync it to client
|
|
||||||
// - stop using keycard on server
|
|
||||||
// - sync it to client
|
|
||||||
// - try to transfer keystore files from server to client
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Add new seed phrase keypair to server and sync it to client
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
serverSeedPhraseKp := s.getSeedPhraseKeypairForTest(serverBackend, seedKeypairMnemonic1, true)
|
|
||||||
err = serverAccountsAPI.ImportMnemonic(ctx, seedKeypairMnemonic1, s.password)
|
|
||||||
require.NoError(s.T(), err, "importing mnemonic for new keypair on server")
|
|
||||||
err = serverAccountsAPI.AddKeypair(ctx, s.password, serverSeedPhraseKp)
|
|
||||||
require.NoError(s.T(), err, "saving seed phrase keypair on server with keystore files created")
|
|
||||||
|
|
||||||
// Wait for sync messages to be received on client
|
|
||||||
err = tt.RetryWithBackOff(func() error {
|
|
||||||
response, err := clientMessenger.RetrieveAll()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, kp := range response.Keypairs {
|
|
||||||
if kp.KeyUID == serverSeedPhraseKp.KeyUID {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
"installation not received",
|
||||||
|
)
|
||||||
|
|
||||||
return errors.New("no sync keypair received")
|
s.Require().NoError(err)
|
||||||
})
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
// Check if the keypair saved on client is the same as the one on server
|
found := false
|
||||||
serverKp, err := serverAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
for _, i := range response.Installations {
|
||||||
s.Require().NoError(err)
|
found = i.ID == settings.InstallationID &&
|
||||||
clientKp, err := clientAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
i.InstallationMetadata != nil &&
|
||||||
s.Require().NoError(err)
|
i.InstallationMetadata.Name == im1.Name &&
|
||||||
|
i.InstallationMetadata.DeviceType == im1.DeviceType
|
||||||
s.Require().True(serverKp.KeyUID == clientKp.KeyUID &&
|
if found {
|
||||||
serverKp.Name == clientKp.Name &&
|
break
|
||||||
serverKp.Type == clientKp.Type &&
|
|
||||||
serverKp.DerivedFrom == clientKp.DerivedFrom &&
|
|
||||||
serverKp.LastUsedDerivationIndex == clientKp.LastUsedDerivationIndex &&
|
|
||||||
serverKp.Clock == clientKp.Clock &&
|
|
||||||
len(serverKp.Accounts) == len(clientKp.Accounts) &&
|
|
||||||
len(serverKp.Keycards) == len(clientKp.Keycards))
|
|
||||||
|
|
||||||
// Check server - server should contain keystore files for imported seed phrase
|
|
||||||
serverKeystorePath := filepath.Join(serverTmpDir, keystoreDir, serverActiveAccount.KeyUID)
|
|
||||||
require.True(s.T(), containsKeystoreFile(serverKeystorePath, serverKp.DerivedFrom[2:]))
|
|
||||||
for _, acc := range serverKp.Accounts {
|
|
||||||
require.True(s.T(), containsKeystoreFile(serverKeystorePath, acc.Address.String()[2:]))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check client - client should not contain keystore files for imported seed phrase
|
|
||||||
clientKeystorePath := filepath.Join(clientTmpDir, keystoreDir, clientActiveAccount.KeyUID)
|
|
||||||
require.False(s.T(), containsKeystoreFile(clientKeystorePath, clientKp.DerivedFrom[2:]))
|
|
||||||
for _, acc := range clientKp.Accounts {
|
|
||||||
require.False(s.T(), containsKeystoreFile(clientKeystorePath, acc.Address.String()[2:]))
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Convert it to a keycard keypair on server and sync it to client
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
err = serverAccountsAPI.SaveOrUpdateKeycard(ctx, &accounts.Keycard{
|
|
||||||
KeycardUID: "1234",
|
|
||||||
KeycardName: "new-keycard",
|
|
||||||
KeyUID: serverKp.KeyUID,
|
|
||||||
AccountsAddresses: []types.Address{serverKp.Accounts[0].Address, serverKp.Accounts[1].Address},
|
|
||||||
}, false)
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
// Wait for sync messages to be received on client
|
|
||||||
err = tt.RetryWithBackOff(func() error {
|
|
||||||
response, err := clientMessenger.RetrieveAll()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, kp := range response.Keypairs {
|
|
||||||
if kp.KeyUID == serverKp.KeyUID {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return errors.New("no sync keypair received")
|
|
||||||
})
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
// Check if the keypair saved on client is the same as the one on server
|
|
||||||
serverKp, err = serverAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
|
||||||
s.Require().NoError(err)
|
|
||||||
clientKp, err = clientAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
s.Require().True(serverKp.KeyUID == clientKp.KeyUID &&
|
|
||||||
serverKp.Name == clientKp.Name &&
|
|
||||||
serverKp.Type == clientKp.Type &&
|
|
||||||
serverKp.DerivedFrom == clientKp.DerivedFrom &&
|
|
||||||
serverKp.LastUsedDerivationIndex == clientKp.LastUsedDerivationIndex &&
|
|
||||||
serverKp.Clock == clientKp.Clock &&
|
|
||||||
len(serverKp.Accounts) == len(clientKp.Accounts) &&
|
|
||||||
len(serverKp.Keycards) == len(clientKp.Keycards) &&
|
|
||||||
len(serverKp.Keycards) == 1)
|
|
||||||
|
|
||||||
// Check server - server should not contain keystore files for imported seed phrase
|
|
||||||
require.False(s.T(), containsKeystoreFile(serverKeystorePath, serverKp.DerivedFrom[2:]))
|
|
||||||
for _, acc := range serverKp.Accounts {
|
|
||||||
require.False(s.T(), containsKeystoreFile(serverKeystorePath, acc.Address.String()[2:]))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check client - client should not contain keystore files for imported seed phrase
|
|
||||||
require.False(s.T(), containsKeystoreFile(clientKeystorePath, clientKp.DerivedFrom[2:]))
|
|
||||||
for _, acc := range clientKp.Accounts {
|
|
||||||
require.False(s.T(), containsKeystoreFile(clientKeystorePath, acc.Address.String()[2:]))
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Stop using keycard on server and sync it to client
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
err = serverAccountsAPI.MigrateNonProfileKeycardKeypairToApp(ctx, seedKeypairMnemonic1, s.password)
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
// Wait for sync messages to be received on client
|
|
||||||
err = tt.RetryWithBackOff(func() error {
|
|
||||||
response, err := clientMessenger.RetrieveAll()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, kp := range response.Keypairs {
|
|
||||||
if kp.KeyUID == serverKp.KeyUID {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return errors.New("no sync keypair received")
|
|
||||||
})
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
// Check if the keypair saved on client is the same as the one on server
|
|
||||||
serverKp, err = serverAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
|
||||||
s.Require().NoError(err)
|
|
||||||
clientKp, err = clientAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
|
||||||
s.Require().NoError(err)
|
|
||||||
|
|
||||||
s.Require().True(serverKp.KeyUID == clientKp.KeyUID &&
|
|
||||||
serverKp.Name == clientKp.Name &&
|
|
||||||
serverKp.Type == clientKp.Type &&
|
|
||||||
serverKp.DerivedFrom == clientKp.DerivedFrom &&
|
|
||||||
serverKp.LastUsedDerivationIndex == clientKp.LastUsedDerivationIndex &&
|
|
||||||
serverKp.Clock == clientKp.Clock &&
|
|
||||||
len(serverKp.Accounts) == len(clientKp.Accounts) &&
|
|
||||||
len(serverKp.Keycards) == len(clientKp.Keycards) &&
|
|
||||||
len(serverKp.Keycards) == 0)
|
|
||||||
|
|
||||||
// Check server - server should contain keystore files for imported seed phrase
|
|
||||||
require.True(s.T(), containsKeystoreFile(serverKeystorePath, serverKp.DerivedFrom[2:]))
|
|
||||||
for _, acc := range serverKp.Accounts {
|
|
||||||
require.True(s.T(), containsKeystoreFile(serverKeystorePath, acc.Address.String()[2:]))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check client - client should not contain keystore files for imported seed phrase
|
|
||||||
require.False(s.T(), containsKeystoreFile(clientKeystorePath, clientKp.DerivedFrom[2:]))
|
|
||||||
for _, acc := range clientKp.Accounts {
|
|
||||||
require.False(s.T(), containsKeystoreFile(clientKeystorePath, acc.Address.String()[2:]))
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Try to transfer keystore files from server to client
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
serverMessenger.SetLocalPairing(true)
|
|
||||||
clientMessenger.SetLocalPairing(true)
|
|
||||||
|
|
||||||
// prepare sender
|
|
||||||
var config = KeystoreFilesSenderServerConfig{
|
|
||||||
SenderConfig: &KeystoreFilesSenderConfig{
|
|
||||||
KeystoreFilesConfig: KeystoreFilesConfig{
|
|
||||||
KeystorePath: serverKeystorePath,
|
|
||||||
LoggedInKeyUID: serverActiveAccount.KeyUID,
|
|
||||||
Password: s.password,
|
|
||||||
},
|
|
||||||
KeypairsToExport: []string{serverKp.KeyUID},
|
|
||||||
},
|
|
||||||
ServerConfig: new(ServerConfig),
|
|
||||||
}
|
|
||||||
configBytes, err := json.Marshal(config)
|
|
||||||
require.NoError(s.T(), err)
|
|
||||||
cs, err := StartUpKeystoreFilesSenderServer(serverBackend, string(configBytes))
|
|
||||||
require.NoError(s.T(), err)
|
|
||||||
|
|
||||||
// prepare receiver
|
|
||||||
clientPayloadSourceConfig := KeystoreFilesReceiverClientConfig{
|
|
||||||
ReceiverConfig: &KeystoreFilesReceiverConfig{
|
|
||||||
KeystoreFilesConfig: KeystoreFilesConfig{
|
|
||||||
KeystorePath: clientKeystorePath,
|
|
||||||
LoggedInKeyUID: clientActiveAccount.KeyUID,
|
|
||||||
Password: s.password,
|
|
||||||
},
|
|
||||||
KeypairsToImport: []string{clientKp.KeyUID},
|
|
||||||
},
|
|
||||||
ClientConfig: new(ClientConfig),
|
|
||||||
}
|
|
||||||
clientConfigBytes, err := json.Marshal(clientPayloadSourceConfig)
|
|
||||||
require.NoError(s.T(), err)
|
|
||||||
err = StartUpKeystoreFilesReceivingClient(clientBackend, cs, string(clientConfigBytes))
|
|
||||||
require.NoError(s.T(), err)
|
|
||||||
|
|
||||||
// Check server - server should contain keystore files for imported seed phrase
|
|
||||||
require.True(s.T(), containsKeystoreFile(serverKeystorePath, serverKp.DerivedFrom[2:]))
|
|
||||||
for _, acc := range serverKp.Accounts {
|
|
||||||
require.True(s.T(), containsKeystoreFile(serverKeystorePath, acc.Address.String()[2:]))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check client - client should contain keystore files for imported seed phrase
|
|
||||||
require.True(s.T(), containsKeystoreFile(clientKeystorePath, clientKp.DerivedFrom[2:]))
|
|
||||||
for _, acc := range clientKp.Accounts {
|
|
||||||
require.True(s.T(), containsKeystoreFile(clientKeystorePath, acc.Address.String()[2:]))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
s.Require().True(found)
|
||||||
|
|
||||||
|
err = serverMessenger.EnableInstallation(settings.InstallationID)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
// Check if the logged in account is the same on server and client
|
||||||
|
serverActiveAccount, err := serverBackend.GetActiveAccount()
|
||||||
|
require.NoError(s.T(), err)
|
||||||
|
clientActiveAccount, err := clientBackend.GetActiveAccount()
|
||||||
|
require.NoError(s.T(), err)
|
||||||
|
require.True(s.T(), serverActiveAccount.KeyUID == clientActiveAccount.KeyUID)
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// From this point this test is trying to simulate the following scenario:
|
||||||
|
// - add a new seed phrase keypair on server
|
||||||
|
// - sync it to client
|
||||||
|
// - convert it to a keycard keypair on server
|
||||||
|
// - sync it to client
|
||||||
|
// - stop using keycard on server
|
||||||
|
// - sync it to client
|
||||||
|
// - try to transfer keystore files from server to client
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Add new seed phrase keypair to server and sync it to client
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
serverSeedPhraseKp := s.getSeedPhraseKeypairForTest(serverBackend, seedKeypairMnemonic1, true)
|
||||||
|
err = serverAccountsAPI.ImportMnemonic(ctx, seedKeypairMnemonic1, s.password)
|
||||||
|
require.NoError(s.T(), err, "importing mnemonic for new keypair on server")
|
||||||
|
err = serverAccountsAPI.AddKeypair(ctx, s.password, serverSeedPhraseKp)
|
||||||
|
require.NoError(s.T(), err, "saving seed phrase keypair on server with keystore files created")
|
||||||
|
|
||||||
|
// Wait for sync messages to be received on client
|
||||||
|
err = tt.RetryWithBackOff(func() error {
|
||||||
|
response, err := clientMessenger.RetrieveAll()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, kp := range response.Keypairs {
|
||||||
|
if kp.KeyUID == serverSeedPhraseKp.KeyUID {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors.New("no sync keypair received")
|
||||||
|
})
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
// Check if the keypair saved on client is the same as the one on server
|
||||||
|
serverKp, err := serverAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
clientKp, err := clientAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
s.Require().True(serverKp.KeyUID == clientKp.KeyUID &&
|
||||||
|
serverKp.Name == clientKp.Name &&
|
||||||
|
serverKp.Type == clientKp.Type &&
|
||||||
|
serverKp.DerivedFrom == clientKp.DerivedFrom &&
|
||||||
|
serverKp.LastUsedDerivationIndex == clientKp.LastUsedDerivationIndex &&
|
||||||
|
serverKp.Clock == clientKp.Clock &&
|
||||||
|
len(serverKp.Accounts) == len(clientKp.Accounts) &&
|
||||||
|
len(serverKp.Keycards) == len(clientKp.Keycards))
|
||||||
|
|
||||||
|
// Check server - server should contain keystore files for imported seed phrase
|
||||||
|
serverKeystorePath := filepath.Join(serverTmpDir, keystoreDir, serverActiveAccount.KeyUID)
|
||||||
|
require.True(s.T(), containsKeystoreFile(serverKeystorePath, serverKp.DerivedFrom[2:]))
|
||||||
|
for _, acc := range serverKp.Accounts {
|
||||||
|
require.True(s.T(), containsKeystoreFile(serverKeystorePath, acc.Address.String()[2:]))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check client - client should not contain keystore files for imported seed phrase
|
||||||
|
clientKeystorePath := filepath.Join(clientTmpDir, keystoreDir, clientActiveAccount.KeyUID)
|
||||||
|
require.False(s.T(), containsKeystoreFile(clientKeystorePath, clientKp.DerivedFrom[2:]))
|
||||||
|
for _, acc := range clientKp.Accounts {
|
||||||
|
require.False(s.T(), containsKeystoreFile(clientKeystorePath, acc.Address.String()[2:]))
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Convert it to a keycard keypair on server and sync it to client
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
err = serverAccountsAPI.SaveOrUpdateKeycard(ctx, &accounts.Keycard{
|
||||||
|
KeycardUID: "1234",
|
||||||
|
KeycardName: "new-keycard",
|
||||||
|
KeyUID: serverKp.KeyUID,
|
||||||
|
AccountsAddresses: []types.Address{serverKp.Accounts[0].Address, serverKp.Accounts[1].Address},
|
||||||
|
}, false)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
// Wait for sync messages to be received on client
|
||||||
|
err = tt.RetryWithBackOff(func() error {
|
||||||
|
response, err := clientMessenger.RetrieveAll()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, kp := range response.Keypairs {
|
||||||
|
if kp.KeyUID == serverKp.KeyUID {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return errors.New("no sync keypair received")
|
||||||
|
})
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
// Check if the keypair saved on client is the same as the one on server
|
||||||
|
serverKp, err = serverAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
clientKp, err = clientAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
s.Require().True(serverKp.KeyUID == clientKp.KeyUID &&
|
||||||
|
serverKp.Name == clientKp.Name &&
|
||||||
|
serverKp.Type == clientKp.Type &&
|
||||||
|
serverKp.DerivedFrom == clientKp.DerivedFrom &&
|
||||||
|
serverKp.LastUsedDerivationIndex == clientKp.LastUsedDerivationIndex &&
|
||||||
|
serverKp.Clock == clientKp.Clock &&
|
||||||
|
len(serverKp.Accounts) == len(clientKp.Accounts) &&
|
||||||
|
len(serverKp.Keycards) == len(clientKp.Keycards) &&
|
||||||
|
len(serverKp.Keycards) == 1)
|
||||||
|
|
||||||
|
// Check server - server should not contain keystore files for imported seed phrase
|
||||||
|
require.False(s.T(), containsKeystoreFile(serverKeystorePath, serverKp.DerivedFrom[2:]))
|
||||||
|
for _, acc := range serverKp.Accounts {
|
||||||
|
require.False(s.T(), containsKeystoreFile(serverKeystorePath, acc.Address.String()[2:]))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check client - client should not contain keystore files for imported seed phrase
|
||||||
|
require.False(s.T(), containsKeystoreFile(clientKeystorePath, clientKp.DerivedFrom[2:]))
|
||||||
|
for _, acc := range clientKp.Accounts {
|
||||||
|
require.False(s.T(), containsKeystoreFile(clientKeystorePath, acc.Address.String()[2:]))
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Stop using keycard on server and sync it to client
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
err = serverAccountsAPI.MigrateNonProfileKeycardKeypairToApp(ctx, seedKeypairMnemonic1, s.password)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
// Wait for sync messages to be received on client
|
||||||
|
err = tt.RetryWithBackOff(func() error {
|
||||||
|
response, err := clientMessenger.RetrieveAll()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, kp := range response.Keypairs {
|
||||||
|
if kp.KeyUID == serverKp.KeyUID {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return errors.New("no sync keypair received")
|
||||||
|
})
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
// Check if the keypair saved on client is the same as the one on server
|
||||||
|
serverKp, err = serverAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
clientKp, err = clientAccountsAPI.GetKeypairByKeyUID(ctx, serverSeedPhraseKp.KeyUID)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
s.Require().True(serverKp.KeyUID == clientKp.KeyUID &&
|
||||||
|
serverKp.Name == clientKp.Name &&
|
||||||
|
serverKp.Type == clientKp.Type &&
|
||||||
|
serverKp.DerivedFrom == clientKp.DerivedFrom &&
|
||||||
|
serverKp.LastUsedDerivationIndex == clientKp.LastUsedDerivationIndex &&
|
||||||
|
serverKp.Clock == clientKp.Clock &&
|
||||||
|
len(serverKp.Accounts) == len(clientKp.Accounts) &&
|
||||||
|
len(serverKp.Keycards) == len(clientKp.Keycards) &&
|
||||||
|
len(serverKp.Keycards) == 0)
|
||||||
|
|
||||||
|
// Check server - server should contain keystore files for imported seed phrase
|
||||||
|
require.True(s.T(), containsKeystoreFile(serverKeystorePath, serverKp.DerivedFrom[2:]))
|
||||||
|
for _, acc := range serverKp.Accounts {
|
||||||
|
require.True(s.T(), containsKeystoreFile(serverKeystorePath, acc.Address.String()[2:]))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check client - client should not contain keystore files for imported seed phrase
|
||||||
|
require.False(s.T(), containsKeystoreFile(clientKeystorePath, clientKp.DerivedFrom[2:]))
|
||||||
|
for _, acc := range clientKp.Accounts {
|
||||||
|
require.False(s.T(), containsKeystoreFile(clientKeystorePath, acc.Address.String()[2:]))
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Try to transfer keystore files from server to client
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
serverMessenger.SetLocalPairing(true)
|
||||||
|
clientMessenger.SetLocalPairing(true)
|
||||||
|
|
||||||
|
// prepare sender
|
||||||
|
var config = KeystoreFilesSenderServerConfig{
|
||||||
|
SenderConfig: &KeystoreFilesSenderConfig{
|
||||||
|
KeystoreFilesConfig: KeystoreFilesConfig{
|
||||||
|
KeystorePath: serverKeystorePath,
|
||||||
|
LoggedInKeyUID: serverActiveAccount.KeyUID,
|
||||||
|
Password: s.password,
|
||||||
|
},
|
||||||
|
KeypairsToExport: []string{serverKp.KeyUID},
|
||||||
|
},
|
||||||
|
ServerConfig: new(ServerConfig),
|
||||||
|
}
|
||||||
|
configBytes, err := json.Marshal(config)
|
||||||
|
require.NoError(s.T(), err)
|
||||||
|
cs, err := StartUpKeystoreFilesSenderServer(serverBackend, string(configBytes))
|
||||||
|
require.NoError(s.T(), err)
|
||||||
|
|
||||||
|
// prepare receiver
|
||||||
|
clientPayloadSourceConfig := KeystoreFilesReceiverClientConfig{
|
||||||
|
ReceiverConfig: &KeystoreFilesReceiverConfig{
|
||||||
|
KeystoreFilesConfig: KeystoreFilesConfig{
|
||||||
|
KeystorePath: clientKeystorePath,
|
||||||
|
LoggedInKeyUID: clientActiveAccount.KeyUID,
|
||||||
|
Password: s.password,
|
||||||
|
},
|
||||||
|
KeypairsToImport: []string{clientKp.KeyUID},
|
||||||
|
},
|
||||||
|
ClientConfig: new(ClientConfig),
|
||||||
|
}
|
||||||
|
clientConfigBytes, err := json.Marshal(clientPayloadSourceConfig)
|
||||||
|
require.NoError(s.T(), err)
|
||||||
|
err = StartUpKeystoreFilesReceivingClient(clientBackend, cs, string(clientConfigBytes))
|
||||||
|
require.NoError(s.T(), err)
|
||||||
|
|
||||||
|
// Check server - server should contain keystore files for imported seed phrase
|
||||||
|
require.True(s.T(), containsKeystoreFile(serverKeystorePath, serverKp.DerivedFrom[2:]))
|
||||||
|
for _, acc := range serverKp.Accounts {
|
||||||
|
require.True(s.T(), containsKeystoreFile(serverKeystorePath, acc.Address.String()[2:]))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check client - client should contain keystore files for imported seed phrase
|
||||||
|
require.True(s.T(), containsKeystoreFile(clientKeystorePath, clientKp.DerivedFrom[2:]))
|
||||||
|
for _, acc := range clientKp.Accounts {
|
||||||
|
require.True(s.T(), containsKeystoreFile(clientKeystorePath, acc.Address.String()[2:]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SyncDeviceSuite) TestPreventLoggedInAccountLocalPairingClientAsReceiver() {
|
func (s *SyncDeviceSuite) TestPreventLoggedInAccountLocalPairingClientAsReceiver() {
|
||||||
clientTmpDir := filepath.Join(s.clientAsSenderTmpdir, "client")
|
clientTmpDir := filepath.Join(s.clientAsSenderTmpdir, "client")
|
||||||
clientBackend := s.prepareBackendWithAccount("", clientTmpDir)
|
clientBackend := s.prepareBackendWithAccount("", clientTmpDir)
|
||||||
|
|
Loading…
Reference in New Issue