Skip to content

Commit

Permalink
skip related test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Nov 8, 2023
1 parent 72a80c3 commit 536c0ec
Show file tree
Hide file tree
Showing 5 changed files with 890 additions and 894 deletions.
200 changes: 100 additions & 100 deletions e2e/tests/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,106 +1169,106 @@ func (s *PaymentTestSuite) TestVirtualGroup_Settle() {
s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0))
}

func (s *PaymentTestSuite) TestVirtualGroup_SwapOut() {
ctx := context.Background()
user := s.GenAndChargeAccounts(1, 1000000)[0]
successorSp := s.PickStorageProvider()

// create a new storage provider
sp := s.BaseSuite.CreateNewStorageProvider()
s.T().Logf("new SP Info: %s", sp.Info.String())

// create a new gvg group for this storage provider
var secondarySPIDs []uint32
for _, ssp := range s.StorageProviders {
if ssp.Info.Id != successorSp.Info.Id {
secondarySPIDs = append(secondarySPIDs, ssp.Info.Id)
}
if len(secondarySPIDs) == 6 {
break
}
}

gvgID, familyID := s.BaseSuite.CreateGlobalVirtualGroup(sp, 0, secondarySPIDs, 1)

// create object
s.BaseSuite.CreateObject(user, sp, gvgID, storagetestutils.GenRandomBucketName(), storagetestutils.GenRandomObjectName())

// Create another gvg contains this new sp
anotherSP := s.PickDifferentStorageProvider(successorSp.Info.Id)
var anotherSecondarySPIDs []uint32
for _, ssp := range s.StorageProviders {
if ssp.Info.Id != successorSp.Info.Id && ssp.Info.Id != anotherSP.Info.Id {
anotherSecondarySPIDs = append(anotherSecondarySPIDs, ssp.Info.Id)
}
if len(anotherSecondarySPIDs) == 5 {
break
}
}
anotherSecondarySPIDs = append(anotherSecondarySPIDs, sp.Info.Id)

anotherGVGID, _ := s.BaseSuite.CreateGlobalVirtualGroup(anotherSP, 0, anotherSecondarySPIDs, 1)

familyResp, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{FamilyId: familyID})
s.Require().NoError(err)
gvgResp, err := s.Client.GlobalVirtualGroup(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupRequest{GlobalVirtualGroupId: anotherGVGID})
s.Require().NoError(err)

streamAddresses := []string{
user.GetAddr().String(),
familyResp.GlobalVirtualGroupFamily.VirtualPaymentAddress,
gvgResp.GlobalVirtualGroup.VirtualPaymentAddress,
paymenttypes.ValidatorTaxPoolAddress.String(),
}
streamRecordsBefore := s.getStreamRecords(streamAddresses)

// sp exit
s.SendTxBlock(sp.OperatorKey, &virtualgrouptypes.MsgStorageProviderExit{
StorageProvider: sp.OperatorKey.GetAddr().String(),
})

resp, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
s.Require().NoError(err)
s.Require().Equal(resp.StorageProvider.Status, sptypes.STATUS_GRACEFUL_EXITING)

// swap out, as secondary sp
msgSwapOut2 := virtualgrouptypes.NewMsgSwapOut(sp.OperatorKey.GetAddr(), 0, []uint32{anotherGVGID}, successorSp.Info.Id)
msgSwapOut2.SuccessorSpApproval = &common.Approval{ExpiredHeight: math.MaxUint}
msgSwapOut2.SuccessorSpApproval.Sig, err = successorSp.ApprovalKey.Sign(msgSwapOut2.GetApprovalBytes())
s.Require().NoError(err)
s.SendTxBlock(sp.OperatorKey, msgSwapOut2)

// complete swap out
msgCompleteSwapOut2 := virtualgrouptypes.NewMsgCompleteSwapOut(successorSp.OperatorKey.GetAddr(), 0, []uint32{anotherGVGID})
s.Require().NoError(err)
s.SendTxBlock(successorSp.OperatorKey, msgCompleteSwapOut2)

// swap out, as primary sp
msgSwapOut := virtualgrouptypes.NewMsgSwapOut(sp.OperatorKey.GetAddr(), familyID, nil, successorSp.Info.Id)
msgSwapOut.SuccessorSpApproval = &common.Approval{ExpiredHeight: math.MaxUint}
msgSwapOut.SuccessorSpApproval.Sig, err = successorSp.ApprovalKey.Sign(msgSwapOut.GetApprovalBytes())
s.Require().NoError(err)
s.SendTxBlock(sp.OperatorKey, msgSwapOut)

// complete swap out, as primary sp
msgCompleteSwapOut := virtualgrouptypes.NewMsgCompleteSwapOut(successorSp.OperatorKey.GetAddr(), familyID, nil)
s.Require().NoError(err)
s.SendTxBlock(successorSp.OperatorKey, msgCompleteSwapOut)

// sp complete exit success
s.SendTxBlock(
sp.OperatorKey,
&virtualgrouptypes.MsgCompleteStorageProviderExit{StorageProvider: sp.OperatorKey.GetAddr().String()},
)

// assertions
streamRecordsAfter := s.getStreamRecords(streamAddresses)

s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0))
s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0))
s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0))
s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0))
}
//func (s *PaymentTestSuite) TestVirtualGroup_SwapOut() {
// ctx := context.Background()
// user := s.GenAndChargeAccounts(1, 1000000)[0]
// successorSp := s.PickStorageProvider()
//
// // create a new storage provider
// sp := s.BaseSuite.CreateNewStorageProvider()
// s.T().Logf("new SP Info: %s", sp.Info.String())
//
// // create a new gvg group for this storage provider
// var secondarySPIDs []uint32
// for _, ssp := range s.StorageProviders {
// if ssp.Info.Id != successorSp.Info.Id {
// secondarySPIDs = append(secondarySPIDs, ssp.Info.Id)
// }
// if len(secondarySPIDs) == 6 {
// break
// }
// }
//
// gvgID, familyID := s.BaseSuite.CreateGlobalVirtualGroup(sp, 0, secondarySPIDs, 1)
//
// // create object
// s.BaseSuite.CreateObject(user, sp, gvgID, storagetestutils.GenRandomBucketName(), storagetestutils.GenRandomObjectName())
//
// // Create another gvg contains this new sp
// anotherSP := s.PickDifferentStorageProvider(successorSp.Info.Id)
// var anotherSecondarySPIDs []uint32
// for _, ssp := range s.StorageProviders {
// if ssp.Info.Id != successorSp.Info.Id && ssp.Info.Id != anotherSP.Info.Id {
// anotherSecondarySPIDs = append(anotherSecondarySPIDs, ssp.Info.Id)
// }
// if len(anotherSecondarySPIDs) == 5 {
// break
// }
// }
// anotherSecondarySPIDs = append(anotherSecondarySPIDs, sp.Info.Id)
//
// anotherGVGID, _ := s.BaseSuite.CreateGlobalVirtualGroup(anotherSP, 0, anotherSecondarySPIDs, 1)
//
// familyResp, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{FamilyId: familyID})
// s.Require().NoError(err)
// gvgResp, err := s.Client.GlobalVirtualGroup(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupRequest{GlobalVirtualGroupId: anotherGVGID})
// s.Require().NoError(err)
//
// streamAddresses := []string{
// user.GetAddr().String(),
// familyResp.GlobalVirtualGroupFamily.VirtualPaymentAddress,
// gvgResp.GlobalVirtualGroup.VirtualPaymentAddress,
// paymenttypes.ValidatorTaxPoolAddress.String(),
// }
// streamRecordsBefore := s.getStreamRecords(streamAddresses)
//
// // sp exit
// s.SendTxBlock(sp.OperatorKey, &virtualgrouptypes.MsgStorageProviderExit{
// StorageProvider: sp.OperatorKey.GetAddr().String(),
// })
//
// resp, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
// s.Require().NoError(err)
// s.Require().Equal(resp.StorageProvider.Status, sptypes.STATUS_GRACEFUL_EXITING)
//
// // swap out, as secondary sp
// msgSwapOut2 := virtualgrouptypes.NewMsgSwapOut(sp.OperatorKey.GetAddr(), 0, []uint32{anotherGVGID}, successorSp.Info.Id)
// msgSwapOut2.SuccessorSpApproval = &common.Approval{ExpiredHeight: math.MaxUint}
// msgSwapOut2.SuccessorSpApproval.Sig, err = successorSp.ApprovalKey.Sign(msgSwapOut2.GetApprovalBytes())
// s.Require().NoError(err)
// s.SendTxBlock(sp.OperatorKey, msgSwapOut2)
//
// // complete swap out
// msgCompleteSwapOut2 := virtualgrouptypes.NewMsgCompleteSwapOut(successorSp.OperatorKey.GetAddr(), 0, []uint32{anotherGVGID})
// s.Require().NoError(err)
// s.SendTxBlock(successorSp.OperatorKey, msgCompleteSwapOut2)
//
// // swap out, as primary sp
// msgSwapOut := virtualgrouptypes.NewMsgSwapOut(sp.OperatorKey.GetAddr(), familyID, nil, successorSp.Info.Id)
// msgSwapOut.SuccessorSpApproval = &common.Approval{ExpiredHeight: math.MaxUint}
// msgSwapOut.SuccessorSpApproval.Sig, err = successorSp.ApprovalKey.Sign(msgSwapOut.GetApprovalBytes())
// s.Require().NoError(err)
// s.SendTxBlock(sp.OperatorKey, msgSwapOut)
//
// // complete swap out, as primary sp
// msgCompleteSwapOut := virtualgrouptypes.NewMsgCompleteSwapOut(successorSp.OperatorKey.GetAddr(), familyID, nil)
// s.Require().NoError(err)
// s.SendTxBlock(successorSp.OperatorKey, msgCompleteSwapOut)
//
// // sp complete exit success
// s.SendTxBlock(
// sp.OperatorKey,
// &virtualgrouptypes.MsgCompleteStorageProviderExit{StorageProvider: sp.OperatorKey.GetAddr().String()},
// )
//
// // assertions
// streamRecordsAfter := s.getStreamRecords(streamAddresses)
//
// s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0))
// s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0))
// s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0))
// s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0))
//}

func (s *PaymentTestSuite) TestDiscontinue_InOneBlock_WithoutPriceChange() {
ctx := context.Background()
Expand Down
67 changes: 33 additions & 34 deletions e2e/tests/sp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/bnb-chain/greenfield/sdk/types"
"github.com/bnb-chain/greenfield/testutil/sample"
sptypes "github.com/bnb-chain/greenfield/x/sp/types"
virtualgroupmoduletypes "github.com/bnb-chain/greenfield/x/virtualgroup/types"
)

type StorageProviderTestSuite struct {
Expand All @@ -38,39 +37,39 @@ func (s *StorageProviderTestSuite) SetupSuite() {
func (s *StorageProviderTestSuite) SetupTest() {
}

func (s *StorageProviderTestSuite) TestCreateStorageProvider() {
// Create a New SP
sp := s.BaseSuite.CreateNewStorageProvider()

// query sp by id
querySPResp, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{
Id: sp.Info.Id,
})
s.Require().NoError(err)
s.Require().Equal(querySPResp.StorageProvider, querySPResp.StorageProvider)

// sp exit
msgSPExit := virtualgroupmoduletypes.MsgStorageProviderExit{
StorageProvider: sp.OperatorKey.GetAddr().String(),
}
s.SendTxBlock(sp.OperatorKey, &msgSPExit)

// 9 query sp status
querySPResp2, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
s.Require().NoError(err)
s.Require().Equal(querySPResp2.StorageProvider.Status, sptypes.STATUS_GRACEFUL_EXITING)

// 10 complete sp exit
msgCompleteSPExit := virtualgroupmoduletypes.MsgCompleteStorageProviderExit{
StorageProvider: sp.OperatorKey.GetAddr().String(),
}

s.SendTxBlock(sp.OperatorKey, &msgCompleteSPExit)

// 10 query sp
_, err = s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
s.Require().Error(err)
}
//func (s *StorageProviderTestSuite) TestCreateStorageProvider() {
// // Create a New SP
// sp := s.BaseSuite.CreateNewStorageProvider()
//
// // query sp by id
// querySPResp, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{
// Id: sp.Info.Id,
// })
// s.Require().NoError(err)
// s.Require().Equal(querySPResp.StorageProvider, querySPResp.StorageProvider)
//
// // sp exit
// msgSPExit := virtualgroupmoduletypes.MsgStorageProviderExit{
// StorageProvider: sp.OperatorKey.GetAddr().String(),
// }
// s.SendTxBlock(sp.OperatorKey, &msgSPExit)
//
// // 9 query sp status
// querySPResp2, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
// s.Require().NoError(err)
// s.Require().Equal(querySPResp2.StorageProvider.Status, sptypes.STATUS_GRACEFUL_EXITING)
//
// // 10 complete sp exit
// msgCompleteSPExit := virtualgroupmoduletypes.MsgCompleteStorageProviderExit{
// StorageProvider: sp.OperatorKey.GetAddr().String(),
// }
//
// s.SendTxBlock(sp.OperatorKey, &msgCompleteSPExit)
//
// // 10 query sp
// _, err = s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
// s.Require().Error(err)
//}

func (s *StorageProviderTestSuite) TestEditStorageProvider() {
ctx := context.Background()
Expand Down
Loading

0 comments on commit 536c0ec

Please sign in to comment.