Skip to content

Commit

Permalink
Improve superfluid grpc-query
Browse files Browse the repository at this point in the history
  • Loading branch information
mattverse committed Mar 14, 2022
1 parent 9b857d2 commit 85ed361
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion x/superfluid/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (k Keeper) TotalSuperfluidDelegations(goCtx context.Context, req *types.Tot

delegation, found := k.sk.GetDelegation(ctx, intermediaryAccount.GetAccAddress(), valAddr)
if !found {
return nil, stakingtypes.ErrNoDelegation
continue
}

syntheticOsmoAmt := delegation.Shares.Quo(val.DelegatorShares).MulInt(val.Tokens).RoundInt()
Expand Down
20 changes: 19 additions & 1 deletion x/superfluid/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (suite *KeeperTestSuite) TestGRPCQuerySuperfluidDelegations() {
}

// setup superfluid delegations
suite.SetupSuperfluidDelegations(delAddrs, valAddrs, superfluidDelegations, denoms)
_, locks := suite.SetupSuperfluidDelegations(delAddrs, valAddrs, superfluidDelegations, denoms)

// for each superfluid delegation, query the amount and make sure it is 1000000
for _, delegation := range superfluidDelegations {
Expand Down Expand Up @@ -108,6 +108,20 @@ func (suite *KeeperTestSuite) TestGRPCQuerySuperfluidDelegations() {
totalSuperfluidDelegationsRes, err := suite.queryClient.TotalSuperfluidDelegations(sdk.WrapSDKContext(suite.Ctx), &types.TotalSuperfluidDelegationsRequest{})
suite.Require().NoError(err)
suite.Require().Equal(sdk.NewInt(40000000), totalSuperfluidDelegationsRes.TotalDelegations)

for _, lockID := range locks {
connectedIntermediaryAccountRes, err := suite.queryClient.ConnectedIntermediaryAccount(sdk.WrapSDKContext(suite.Ctx), &types.ConnectedIntermediaryAccountRequest{LockId: lockID.ID})
suite.Require().NoError(err)
suite.Require().NotEqual("", connectedIntermediaryAccountRes.Account.Denom)
suite.Require().NotEqual("", connectedIntermediaryAccountRes.Account.Address)
suite.Require().NotEqual(uint64(0), connectedIntermediaryAccountRes.Account.GaugeId)

}
connectedIntermediaryAccountRes, err := suite.queryClient.ConnectedIntermediaryAccount(sdk.WrapSDKContext(suite.Ctx), &types.ConnectedIntermediaryAccountRequest{LockId: 123})
suite.Require().NoError(err)
suite.Require().Equal("", connectedIntermediaryAccountRes.Account.Denom)
suite.Require().Equal("", connectedIntermediaryAccountRes.Account.ValAddr)
suite.Require().Equal(uint64(0), connectedIntermediaryAccountRes.Account.GaugeId)
}

func (suite *KeeperTestSuite) TestGRPCQuerySuperfluidDelegationsDontIncludeUnbonding() {
Expand Down Expand Up @@ -171,4 +185,8 @@ func (suite *KeeperTestSuite) TestGRPCQuerySuperfluidDelegationsDontIncludeUnbon
})
suite.Require().NoError(err)
suite.Require().Len(delegationsRes.SuperfluidDelegationRecords, 1)

totalSuperfluidDelegationsRes, err := suite.queryClient.TotalSuperfluidDelegations(sdk.WrapSDKContext(suite.Ctx), &types.TotalSuperfluidDelegationsRequest{})
suite.Require().NoError(err)
suite.Require().Equal(totalSuperfluidDelegationsRes.TotalDelegations, sdk.NewInt(30000000))
}

0 comments on commit 85ed361

Please sign in to comment.