-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shentu prefix revoke certificate (#754)
* fix revoke-certificate, platform cmd * fix revoke-certificate, platform cmd * fix revoke-certificate, platform cmd
- Loading branch information
1 parent
d65c976
commit e180d1e
Showing
7 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
"time" | ||
|
||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
shentuapp "github.com/shentufoundation/shentu/v2/app" | ||
"github.com/shentufoundation/shentu/v2/x/cert/keeper" | ||
"github.com/shentufoundation/shentu/v2/x/cert/types" | ||
) | ||
|
||
func TestMsgServer_Certificate(t *testing.T) { | ||
ctx, certKeeper, msgServer, addrs := DoInit(t) | ||
|
||
content := types.AssembleContent("identity", addrs[1].String()) | ||
_, err := msgServer.IssueCertificate(sdk.WrapSDKContext(ctx), types.NewMsgIssueCertificate(content, "", "", "", addrs[0])) | ||
require.NoError(t, err) | ||
|
||
certificateID := uint64(1) | ||
_, err = msgServer.RevokeCertificate(sdk.WrapSDKContext(ctx), types.NewMsgRevokeCertificate(addrs[0], certificateID, "")) | ||
require.NoError(t, err) | ||
|
||
_, err = certKeeper.GetCertificateByID(ctx, certificateID) | ||
require.Error(t, err) | ||
} | ||
|
||
func DoInit(t *testing.T) (sdk.Context, keeper.Keeper, types.MsgServer, []sdk.AccAddress) { | ||
app := shentuapp.Setup(false) | ||
ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now().UTC()}) | ||
addrs := shentuapp.AddTestAddrs(app, ctx, 5, sdk.NewInt(80000*1e6)) | ||
ok := app.CertKeeper | ||
msgServer := keeper.NewMsgServerImpl(ok) | ||
ctx = ctx.WithValue("msgServer", msgServer).WithValue("t", t).WithValue("ok", ok) | ||
|
||
ok.SetCertifier(ctx, types.Certifier{ | ||
Address: addrs[0].String(), | ||
}) | ||
return ctx, ok, msgServer, addrs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters