Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Dec 12, 2023
1 parent 6ae1971 commit 18998e1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
26 changes: 21 additions & 5 deletions e2e/tests/virtualgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,9 @@ func (s *VirtualGroupTestSuite) TestSPExit() {

// 7. SP-x complete exit, it would fail due to there are family and GVG binded to it.
s.SendTxBlockWithExpectErrorString(
&virtualgroupmoduletypes.MsgCompleteStorageProviderExit{StorageProvider: spx.OperatorKey.GetAddr().String()},
&virtualgroupmoduletypes.MsgCompleteStorageProviderExit{
Operator: spx.OperatorKey.GetAddr().String(),
StorageProvider: spx.OperatorKey.GetAddr().String()},
spx.OperatorKey,
"not swap out from all the family")

Expand Down Expand Up @@ -772,7 +774,9 @@ func (s *VirtualGroupTestSuite) TestSPExit() {

// 15. SP-x tries to complete exit, but would fail, since SP-2 has a GVG that includes SP-x [2|x,3,4,5,6,7]
s.SendTxBlockWithExpectErrorString(
&virtualgroupmoduletypes.MsgCompleteStorageProviderExit{StorageProvider: spx.OperatorKey.GetAddr().String()},
&virtualgroupmoduletypes.MsgCompleteStorageProviderExit{
Operator: spx.OperatorKey.GetAddr().String(),
StorageProvider: spx.OperatorKey.GetAddr().String()},
spx.OperatorKey,
"not swap out from all the gvgs")

Expand Down Expand Up @@ -870,7 +874,9 @@ func (s *VirtualGroupTestSuite) TestSPExit2() {
// 6. SP-x now can complete the exit, since it has only 1 family and it has been taken by SP-y
s.SendTxBlock(
spx.OperatorKey,
&virtualgroupmoduletypes.MsgCompleteStorageProviderExit{StorageProvider: spx.OperatorKey.GetAddr().String()},
&virtualgroupmoduletypes.MsgCompleteStorageProviderExit{
Operator: spx.OperatorKey.GetAddr().String(),
StorageProvider: spx.OperatorKey.GetAddr().String()},
)
_, err = s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: spx.Info.Id})
s.Require().Error(err)
Expand Down Expand Up @@ -913,10 +919,12 @@ func (s *VirtualGroupTestSuite) TestSPExit2() {
s.Require().Equal(familyID, gvgAfterSwapIn.GlobalVirtualGroup.FamilyId)
s.Require().Equal([]uint32{spz.Info.Id, 3, 4, 5, 6, 7}, gvgAfterSwapIn.GlobalVirtualGroup.SecondarySpIds)

// 11 SP-y complete the exit
// 11 SP-y complete the exit by sp-z
s.SendTxBlock(
spy.OperatorKey,
&virtualgroupmoduletypes.MsgCompleteStorageProviderExit{StorageProvider: spy.OperatorKey.GetAddr().String()},
&virtualgroupmoduletypes.MsgCompleteStorageProviderExit{
Operator: spz.OperatorKey.GetAddr().String(),
StorageProvider: spy.OperatorKey.GetAddr().String()},
)
_, err = s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: spy.Info.Id})
s.Require().Error(err)
Expand Down Expand Up @@ -1037,6 +1045,14 @@ func (s *VirtualGroupTestSuite) TestSPForceExit() {
s.Require().Equal(spy.Info.Id, gvgAfterSwapIn.GlobalVirtualGroup.PrimarySpId)
s.Require().Equal(familyID, gvgAfterSwapIn.GlobalVirtualGroup.FamilyId)
s.Require().Equal([]uint32{2, 3, 4, 5, 6, 7}, gvgAfterSwapIn.GlobalVirtualGroup.SecondarySpIds)

// 11 SP-y help complete the exit
s.SendTxBlock(
spy.OperatorKey,
&virtualgroupmoduletypes.MsgCompleteStorageProviderExit{Operator: spy.OperatorKey.GetAddr().String(), StorageProvider: spx.OperatorKey.GetAddr().String()},
)
_, err = s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: spy.Info.Id})
s.Require().Error(err)
}

func (s *VirtualGroupTestSuite) updateParams(params virtualgroupmoduletypes.Params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ func (msg *MsgCompleteStorageProviderExit) GetSignBytes() []byte {
}

func (msg *MsgCompleteStorageProviderExit) ValidateBasic() error {
_, err := sdk.AccAddressFromHexUnsafe(msg.StorageProvider)

_, err := sdk.AccAddressFromHexUnsafe(msg.Operator)
if err != nil {
return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid operator address (%s)", err)
}
_, err = sdk.AccAddressFromHexUnsafe(msg.StorageProvider)
if err != nil {
return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
return errors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid storage provider address (%s)", err)
}
return nil
}

0 comments on commit 18998e1

Please sign in to comment.